Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 43 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
* This can be done with SELECT and WHERE clauses
</details>

```SQL

```SQL
SELECT *
FROM customers
WHERE city = 'London'`
```

* [ ] ***find all customers with postal code 1010. Returns 3 customers***
Expand All @@ -48,7 +51,9 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
</details>

```SQL

SELECT *
FROM customers
WHERE postal_code = '1010';
```

* [ ] ***find the phone number for the supplier with the id 11. Should be (010) 9984510***
Expand All @@ -59,7 +64,9 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
</details>

```SQL

SELECT phone
FROM suppliers
WHERE supplier_id = 11
```

* [ ] ***list orders descending by the order date. The order with date 1998-05-06 should be at the top***
Expand All @@ -70,7 +77,9 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
</details>

```SQL

SELECT *
FROM orders
ORDER BY (order_date) DESC
```

* [ ] ***find all suppliers who have names longer than 20 characters. Returns 11 records***
Expand All @@ -82,7 +91,9 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
</details>

```SQL

SELECT *
FROM suppliers
WHERE length(company_name) > 20
```

* [ ] ***find all customers that include the word 'MARKET' in the contact title. Should return 19 records***
Expand All @@ -95,7 +106,9 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
</details>

```SQL

SELECT *
FROM customers
WHERE upper(contact_title) LIKE '%MARKET%'
```

* [ ] ***add a customer record for***
Expand All @@ -112,7 +125,8 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
</details>

```SQL

INSERT INTO customers
VALUES ('SHIRE', 'The Shire', 'Bilbo Baggins', '', '1 Hobbit-Hole', 'Bag End', 'Middle Earth', '111');
```

* [ ] ***update _Bilbo Baggins_ record so that the postal code changes to _"11122"_***
Expand All @@ -123,7 +137,9 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
</details>

```SQL

UPDATE customers
SET postal_code = '11122'
WHERE customer_id = 'SHIRE';
```

* [ ] ***list orders grouped and ordered by customer company name showing the number of orders per customer company name. _Rattlesnake Canyon Grocery_ should have 18 orders***
Expand All @@ -135,6 +151,10 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
</details>

```SQL
SELECT customers.company_name, count(*)
FROM orders
INNER JOIN customers ON orders.customer_id = customers.customer_id
GROUP BY customers.company_name

```

Expand All @@ -146,7 +166,11 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
</details>

```SQL

SELECT customers.contact_name, count(*)
FROM orders
INNER JOIN customers ON orders.customer_id = customers.customer_id
GROUP BY customers.contact_name
ORDER BY count DESC
```

* [ ] ***list orders grouped by customer's city showing the number of orders per city. Returns 69 Records with _Aachen_ showing 6 orders and _Albuquerque_ showing 18 orders***
Expand All @@ -157,7 +181,11 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
</details>

```SQL

SELECT customers.city, count(*)
FROM orders
INNER JOIN customers ON orders.customer_id = customers.customer_id
GROUP BY customers.city
ORDER BY customers.city
```

## Data Normalization
Expand All @@ -177,13 +205,13 @@ Below are some empty tables to be used to normalize the database
* Not all of the cells will contain data in the final solution
* Feel free to edit these tables as necessary

Table Name:
Table Name: Person Table

| | | | | | | | | |
| Person Id | Name |City Dweller| | | | | | |
|------------|------------|------------|------------|------------|------------|------------|------------|------------|
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| 1 | Jane | Yes | | | | | | |
| 2 | Bob | No | | | | | | |
| 3 | Sam | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
Expand Down