Your question is SQL for Week-Over-Week Shrink. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Nordstrom operations managers review inventory shrinkage by region and department. Write a PostgreSQL query that compares each department's shrinkage rate with the immediately preceding week.
Shrinkage units are defined as expected_units - counted_units. The shrinkage rate is shrinkage units divided by expected units, expressed as a percentage.
| Column | Type | Description |
|---|---|---|
| department_idPK | INTEGER | Unique department identifier |
| region | VARCHAR(50) | Nordstrom operating region |
| department_name | VARCHAR(100) | Department name |
| Column | Type | Description |
|---|---|---|
| count_idPK | INTEGER | Unique inventory count identifier |
| department_id | INTEGER | Department associated with the count |
| count_date | DATE | Date of the physical inventory count |
| expected_units | INTEGER | Units expected according to inventory records |
| counted_units | INTEGER | Units physically counted |
| audit_note | VARCHAR(200) | Optional inventory audit note |