Created
June 24, 2026 17:05
-
-
Save deletosh/80f0e386610b2dc16bf705101ff7417a to your computer and use it in GitHub Desktop.
week7-demo-report.sql
This file contains hidden or 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
| --- win rate: | |
| ----- All Deals Won / All Closed Deals | |
| --- All deals won: | |
| -- "Closed Won" / "Closed Lost" | |
| -- "Closed Won" | |
| select * from deals | |
| WHERE stage = 'Closed Won'; | |
| -- "Closed Lost" | |
| select * from deals | |
| WHERE stage = 'Closed Lost'; | |
| -- "All Closed Deals" | |
| select deal_id, deal_name from deals | |
| WHERE stage IN ('Closed Lost', 'Closed Won'); | |
| --- Show deal name and "YES" for every closed won deal | |
| SELECT | |
| deal_name | |
| , CASE | |
| WHEN stage = 'Closed Won' | |
| THEN 'YES' | |
| ELSE 'NO' | |
| END | |
| FROM deals | |
| WHERE stage = 'Closed Won'; | |
| --- Show deal name and "YES" for every closed deals | |
| SELECT | |
| deal_name | |
| , CASE | |
| WHEN stage IN ( 'Closed Won', 'Closed Lost') | |
| THEN 'YES' | |
| ELSE 'NO' | |
| END | |
| FROM deals | |
| WHERE stage IN ( 'Closed Won', 'Closed Lost'); | |
| --- Show deal name and 1 for every closed deals | |
| -- and 0 otherwise | |
| select | |
| deal_name | |
| , CASE | |
| WHEN stage In ('Closed Won','Closed Lost') | |
| THEN 1 | |
| ELSE 0 | |
| END deal_c | |
| FROM deals | |
| WHERE stage In ('Closed Won','Closed Lost'); | |
| ----- ### YOUR LUNCH SPECIAL #####----- | |
| --- [Part 1] Show the summation (or total count) of ALL | |
| --- 'Closed Won' | |
| -- | |
| --- [Part 2] Show the summation (or total count) count of ALL | |
| --- 'Closed Won','Closed Lost' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment