Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions part1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT productName AS "Name", productLine AS "Product Line", buyPrice AS "Buy Price"
FROM products
ORDER BY buyPrice DESC;
8 changes: 8 additions & 0 deletions part2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*Write a query to display the first name, last name, and city for all customers from Germany.
Columns should display as First Name, Last Name, and City.
The output should be sorted by the customer’s last name (ascending).*/

SELECT contactFirstName AS "First Name", contactLastName AS "Last Name", city AS "City"
FROM customers
WHERE country = "Germany"
ORDER BY contactLastName ASC;
8 changes: 8 additions & 0 deletions part3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*Write a query to display each of the unique values of the status field in the orders table.
The output should be sorted alphabetically increasing.
Hint: the output should show exactly 6 rows.*/

SELECT status
FROM orders
GROUP BY STATUS
ORDER BY STATUS ASC;
7 changes: 7 additions & 0 deletions part4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*Part 4
Select all fields from the payments table for payments made on or after January 1, 2005.
Output should be sorted by increasing payment date.*/
SELECT *
FROM payments
WHERE paymentDate >= "2005-01-01"
ORDER BY paymentDate ASC;
10 changes: 10 additions & 0 deletions part5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*Part 5
Write a query to display all Last Name, First Name, Email and Job Title of all employees working out of the San Francisco office.
Output should be sorted by last name.*/

SELECT e.lastName AS "Last Name", e.firstName AS "First Name", e.email AS "Email", e.jobTitle AS "Job Title"
FROM employees e
INNER JOIN offices o
ON e.officeCode = o.officeCode
AND o.city = "San Francisco";

9 changes: 9 additions & 0 deletions part6.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*Part 6
Write a query to display the Name, Product Line, Scale, and Vendor of all of the car products – both classic and vintage.
The output should display all vintage cars first (sorted alphabetically by name), and all classic cars last (also sorted alphabetically by name).*/

SELECT productName AS "Name", productLine AS "Product Line",
productScale AS "Scale", productVendor AS "Vendor"
FROM products
WHERE productLine IN ("Vintage Cars", "Classic Cars")
ORDER BY productLine DESC, productName ASC;