-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
solvesql/난이도 4: 가구 판매의 비중이 높았던 날 찾기 (#52)
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
SELECT | ||
order_date, | ||
COUNT( | ||
DISTINCT ( | ||
CASE | ||
WHEN category = 'Furniture' THEN order_id | ||
END | ||
) | ||
) AS 'furniture', | ||
ROUND( | ||
COUNT( | ||
DISTINCT ( | ||
CASE | ||
WHEN category = 'Furniture' THEN order_id | ||
END | ||
) | ||
) * 100.0 / COUNT(DISTINCT order_id), | ||
2 | ||
) AS 'furniture_pct' | ||
FROM | ||
records | ||
GROUP BY | ||
order_date | ||
HAVING | ||
COUNT(DISTINCT order_id) >= 10 | ||
AND furniture_pct >= 40 | ||
ORDER BY | ||
furniture_pct DESC, | ||
order_date |