Skip to main content

This assignment will test your understanding of conditional

Page 1

This assignment will test your understanding of conditional logic, views, ranking and windowing functions, and transactions This assignment will test your understanding of conditional logic, views, ranking and windowing functions, and transactions, as shown in the videos. The prompt includes 10 questions. You will need to create your own test database and tables using the criteria below. Please submit your answers using only one file. The preferable format is a text file with a .sql extension. You can easily edit the file using a text editor such as Notepad ++, which is available online for free. Prompt : A manufacturing company’s data warehouse contains the following tables. Region region_id (p) region_name super_region_id (f) 101 North America 102 USA Canada USA-Northeast USA-Southeast USA-West Mexico 101 Note: (p) = "primary key" and (f) = "foreign key". They are not part of the column names. Product product_id (p) product_name 1256 Gear - Large 4437 Gear - Small 5567 Crankshaft 7684 Sprocket Sales_Totals product_id (p)(f) region_id (p)(f) year (p) month (p) sales Answer the following questions using the above tables/data: Write a CASE expression that can be used to return the quarter number (1, 2, 3, or 4) only based on the month.

Paper For Above instruction The following comprehensive SQL solutions address each of the ten questions based on the provided manufacturing data warehouse schema. The queries demonstrate fundamental and advanced SQL techniques, including conditional logic, pivoting, ranking, transactions, view creation, and joins, necessary for robust data analysis in a warehousing environment. 1. Generating Quarter Number Using a CASE Expression To determine the quarter based on the month, a simple CASE expression is used. The logic maps months 1-3 to Q1, 4-6 to Q2, 7-9 to Q3, and 10-12 to Q4. SELECT month, CASE WHEN month BETWEEN 1 AND 3 THEN 1


Turn static files into dynamic content formats.

Create a flipbook