diff --git a/.~lock.Schrick-Noah_Case-Study-1.docx# b/.~lock.Schrick-Noah_Case-Study-1.docx# new file mode 100644 index 0000000..602c240 --- /dev/null +++ b/.~lock.Schrick-Noah_Case-Study-1.docx# @@ -0,0 +1 @@ +,noah,NovaArchSys,30.08.2022 20:00,file:///home/noah/.config/libreoffice/4; \ No newline at end of file diff --git a/README.md b/README.md index 40da840..0aa276d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ - Use the Cape\_Codd database - Use only the Inventory table -- Deliver a single sql file +- Deliver a single sql file, along with a document that contains all the content from the sql file - Each query should start with a comment line that looks like: /* *** CS1-\ *** \*/ Example for Exercies 2.17: @@ -14,38 +14,38 @@ ## Exercises 2.17 - 2.33 -2.17) Write an SQL statement to display SKU and SKU\_Description. +2.17) Write a SQL statement to display SKU and SKU\_Description. -2.18) Write an SQL statement to display SKU\_Description and SKU. +2.18) Write a SQL statement to display SKU\_Description and SKU. -2.19) Write an SQL statement to display WarehouseID. +2.19) Write a SQL statement to display WarehouseID. -2.20) Write an SQL statement to display unique WarehouseIDs. +2.20) Write a SQL statement to display unique WarehouseIDs. -2.21) Write an SQL statement to display all of the columns without using the SQL asterisk (wildcard character). +2.21) Write a SQL statement to display all of the columns without using the SQL asterisk (wildcard character). -2.22) Write an SQL statement to display all of the columns using the SQL asterisk (wildcard character) +2.22) Write a SQL statement to display all of the columns using the SQL asterisk (wildcard character) -2.23) Write an SQL statement to display all data on products having a QuantityOnHand greater than 0. +2.23) Write a SQL statement to display all data on products having a QuantityOnHand greater than 0. -2.24) Write an SQL statement to display the SKU and SKU\_Description for products having QuantityOnHand equal to 0. +2.24) Write a SQL statement to display the SKU and SKU\_Description for products having QuantityOnHand equal to 0. -2.25) Write an SQL statement to display the SKU, SKU\_Description, and WarehouseID for products that have a QuantityOnHand equal to 0. Sort the results in ascending order by WarehouseID. +2.25) Write a SQL statement to display the SKU, SKU\_Description, and WarehouseID for products that have a QuantityOnHand equal to 0. Sort the results in ascending order by WarehouseID. -2.26) Write an SQL statement to display the SKU, SKU\_Description, and WarehouseID for products that have a QuantityOnHand greater than 0. Sort the results in descending order by WarehouseID and in ascending order by SKU. +2.26) Write a SQL statement to display the SKU, SKU\_Description, and WarehouseID for products that have a QuantityOnHand greater than 0. Sort the results in descending order by WarehouseID and in ascending order by SKU. -2.27) Write an SQL statement to display SKU, SKU\_Description, and WarehouseID for all products that have a QuantityOnHand equal to 0 and a QuantityOnOrder greater than 0. Sort the results in descending order by WarehouseID and in ascending order by SKU. +2.27) Write a SQL statement to display SKU, SKU\_Description, and WarehouseID for all products that have a QuantityOnHand equal to 0 and a QuantityOnOrder greater than 0. Sort the results in descending order by WarehouseID and in ascending order by SKU. -2.28) Write an SQL statement to display SKU, SKU\_Description, and WarehouseID for all products that have a QuantityOnHand equal to 0 or a QuantityOnOrder equal to 0. Sort the results in descending order by WarehouseID and in ascending order by SKU. +2.28) Write a SQL statement to display SKU, SKU\_Description, and WarehouseID for all products that have a QuantityOnHand equal to 0 or a QuantityOnOrder equal to 0. Sort the results in descending order by WarehouseID and in ascending order by SKU. -2.29) Write an SQL statement to display the SKU, SKU\_Description, WarehouseID, and QuantityOnHand for all products having a QuantityOnHand greater than 1 and less than 10. Do not use the BETWEEN keyword. +2.29) Write a SQL statement to display the SKU, SKU\_Description, WarehouseID, and QuantityOnHand for all products having a QuantityOnHand greater than 1 and less than 10. Do not use the BETWEEN keyword. -2.30) Write an SQL statement to display the SKU, SKU\_Description, WarehouseID, and QuantityOnHand for all products having a QuantityOnHand greater than 1 and less than 10. Use the BETWEEN keyword. +2.30) Write a SQL statement to display the SKU, SKU\_Description, WarehouseID, and QuantityOnHand for all products having a QuantityOnHand greater than 1 and less than 10. Use the BETWEEN keyword. -2.31) Write an SQL statement to show a unique SKU and SKU\_Description for all products with an SKU description starting with ‘Half-Dome’. +2.31) Write a SQL statement to show a unique SKU and SKU\_Description for all products with an SKU description starting with ‘Half-Dome’. -2.32) Write an SQL statement to show a unique SKU and SKU\_Description for all products with a description that includes the word ‘Climb’. +2.32) Write a SQL statement to show a unique SKU and SKU\_Description for all products with a description that includes the word ‘Climb’. -2.33) Write an SQL statement to show a unique SKU and SKU\_Description for all products with a ‘d’ in the third position from the left in SKU\_Description. +2.33) Write a SQL statement to show a unique SKU and SKU\_Description for all products with a ‘d’ in the third position from the left in SKU\_Description. diff --git a/Schrick-Noah_Case-Study-1.docx b/Schrick-Noah_Case-Study-1.docx new file mode 100644 index 0000000..dbb57f8 Binary files /dev/null and b/Schrick-Noah_Case-Study-1.docx differ diff --git a/Schrick-Noah_Case-Study-1.pdf b/Schrick-Noah_Case-Study-1.pdf new file mode 100644 index 0000000..ad50540 Binary files /dev/null and b/Schrick-Noah_Case-Study-1.pdf differ diff --git a/Schrick-Noah_Case-Study-1.sql b/Schrick-Noah_Case-Study-1.sql new file mode 100644 index 0000000..f118ad2 --- /dev/null +++ b/Schrick-Noah_Case-Study-1.sql @@ -0,0 +1,101 @@ +/* *** CS1-2.17 *** */ +SELECT SKU, SKU_Description + FROM INVENTORY + ; + +/* *** CS1-2.18 *** */ +SELECT SKU_Description, SKU + FROM INVENTORY + ; + +/* *** CS1-2.19 *** */ +SELECT WarehouseID + FROM INVENTORY + ; + +/* *** CS1-2.20 *** */ +SELECT DISTINCT WarehouseID + FROM INVENTORY + ; + +/* *** CS1-2.21 *** */ +SELECT WarehouseID, SKU, SKU_Description, QuantityOnHand, QuantityOnOrder + FROM INVENTORY + ; + +/* *** CS1-2.22 *** */ +SELECT * + FROM INVENTORY + ; + +/* *** CS1-2.23 *** */ +SELECT * + FROM INVENTORY + WHERE QuantityOnHand > 0 + ; + +/* *** CS1-2.24 *** */ +SELECT SKU, SKU_Description + FROM INVENTORY + WHERE QuantityOnHand = 0 + ; + +/* *** CS1-2.25 *** */ +SELECT SKU, SKU_Description, WarehouseID + FROM INVENTORY + WHERE QuantityOnHand = 0 + ORDER BY WarehouseID ASC + ; + +/* *** CS1-2.26 *** */ +SELECT SKU, SKU_Description, WarehouseID + FROM INVENTORY + WHERE QuantityOnHand > 0 + ORDER BY WarehouseID DESC, SKU ASC + ; + +/* *** CS1-2.27 *** */ +SELECT SKU, SKU_Description, WarehouseID + FROM INVENTORY + WHERE QuantityOnHand = 0 AND QuantityOnOrder > 0 + ORDER BY WarehouseID DESC, SKU ASC + ; + +/* *** CS1-2.28 *** */ +SELECT SKU, SKU_Description, WarehouseID + FROM INVENTORY + WHERE QuantityOnHand = 0 OR QuantityOnOrder = 0 + ORDER BY WarehouseID DESC, SKU ASC + ; + +/* *** CS1-2.29 *** */ +SELECT SKU, SKU_Description, WarehouseID, QuantityOnHand + FROM INVENTORY + WHERE QuantityOnHand > 1 AND QuantityOnHand < 10 + ; + +/* *** CS1-2.30 *** */ +SELECT SKU, SKU_Description, WarehouseID, QuantityOnHand + FROM INVENTORY + WHERE QuantityOnHand BETWEEN 2 AND 9 + ; + +/* *** CS1-2.31 *** */ +SELECT DISTINCT SKU, SKU_Description + FROM INVENTORY + WHERE SKU_Description LIKE 'Half-Dome%' + ; + +/* *** CS1-2.32 *** */ +SELECT DISTINCT SKU, SKU_Description + FROM INVENTORY + WHERE SKU_Description LIKE '%Climb%' + ; + +/* *** CS1-2.33 *** */ +SELECT DISTINCT SKU, SKU_Description + FROM INVENTORY + WHERE SKU_Description LIKE '__d%' + ; + +