├── dvdrental.zip └── README.md /dvdrental.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innarticles/Data-Analytics-Training-at-Utiva/HEAD/dvdrental.zip -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Data Analytics Training at Utiva 2 | Training Resources and Links 3 | [Slides](https://docs.google.com/presentation/d/1hveKHs6rw_eU9p7Hia77B0RfjHOQiRhozguMjdvtb7o/edit?usp=sharing) 4 | 5 | ## SQL Installations (Postgres) 6 | - Windows - https://www.enterprisedb.com/downloads/postgres-postgresql-downloads 7 | - Mac OS - https://www.enterprisedb.com/downloads/postgres-postgresql-downloads 8 | - Ubuntu - https://www.postgresql.org/download/linux/ubuntu/ 9 | - Others - https://www.postgresql.org/download/ 10 | 11 | ## Sample Datasets 12 | - Film Business Data [Click to download](https://www.postgresqltutorial.com/wp-content/uploads/2019/05/dvdrental.zip) 13 | - Extract to .tar file 14 | - Using PgAdmin, create a database and restore the database by pointing to the .tar file (dvdrental.tar) 15 | 16 | ## Practise online 17 | - https://www.w3resource.com/sql-exercises/ 18 | 19 | ## Instructions on getting updates for on this page 20 | - Watch and Follow this repository (Click on the Watch and Star button at the top right corner of this page). This will enable you get email notification once there is a new update. 21 | 22 | ## Sample Tables Demostrating types of SQL Joins 23 | ``` 24 | CREATE TABLE basket_a ( 25 | id INT PRIMARY KEY, 26 | fruit VARCHAR (100) NOT NULL 27 | ); 28 | 29 | CREATE TABLE basket_b ( 30 | id INT PRIMARY KEY, 31 | fruit VARCHAR (100) NOT NULL 32 | ); 33 | 34 | INSERT INTO basket_a (id, fruit) 35 | VALUES 36 | (1, 'Apple'), 37 | (2, 'Orange'), 38 | (3, 'Banana'), 39 | (4, 'Cucumber'); 40 | 41 | 42 | INSERT INTO basket_b (id, fruit) 43 | VALUES 44 | (1, 'Orange'), 45 | (2, 'Apple'), 46 | (3, 'Watermelon'), 47 | (4, 'Pear'); 48 | ``` 49 | 50 | ## Update on in-class exercise on using `WHERE IN ()` with `INNER JOIN` 51 | Proposed Solution that failed 52 | ``` 53 | SELECT 54 | * 55 | FROM 56 | customer 57 | INNER JOIN payment on (payment.customer_id = customer.customer_id) 58 | WHERE payment.customer_id IN ( 59 | SELECT 60 | Distinct payment.customer_id 61 | FROM payment 62 | WHERE payment.amount > 5.0 63 | ); 64 | ``` 65 | Working Solution - Even simpler!! 66 | ``` 67 | 68 | SELECT 69 | * 70 | FROM 71 | customer 72 | INNER JOIN payment on (payment.customer_id = customer.customer_id) 73 | WHERE payment.amount > 5.0 74 | 75 | ``` 76 | --------------------------------------------------------------------------------