P-Karthik-Mohan commited on
Commit
c49ad7e
·
1 Parent(s): 4d850bf

Fix normalize function

Browse files
Files changed (1) hide show
  1. main.py +8 -9
main.py CHANGED
@@ -59,7 +59,7 @@ TASKS = {
59
  "hint": "JOIN orders with customers, GROUP BY customer, filter completed, ORDER and LIMIT",
60
  "answer_query": """
61
  SELECT c.first_name, c.last_name,
62
- ROUND(SUM(o.total_amount), 2) AS total_revenue
63
  FROM orders o
64
  JOIN customers c ON o.customer_id = c.customer_id
65
  WHERE o.status = 'completed'
@@ -133,8 +133,7 @@ TASKS = {
133
  "description": (
134
  "Calculate the month-over-month revenue growth percentage for completed orders in 2024. "
135
  "For each month show total revenue and percentage change vs previous month. "
136
- "Return columns: month, total_revenue, prev_revenue, growth_pct. "
137
- "Format month as YYYY-MM (e.g. 2024-01). "
138
  "Order by month ascending. Round growth_pct to 2 decimal places. "
139
  "For the first month, prev_revenue and growth_pct should be NULL."
140
  ),
@@ -142,8 +141,8 @@ TASKS = {
142
  "hint": "Use LAG() window function to get previous month revenue, then calculate (current - prev) / prev * 100",
143
  "answer_query": """
144
  WITH monthly AS (
145
- SELECT STRFTIME('%Y-%m', order_date) AS month,
146
- SUM(o.total_amount) AS total_revenue
147
  FROM orders
148
  WHERE status = 'completed'
149
  AND order_date LIKE '2024%'
@@ -207,12 +206,12 @@ TASKS = {
207
  SELECT c.customer_id,
208
  c.first_name,
209
  c.last_name,
210
- ROUND(SUM(CASE
211
  WHEN STRFTIME('%m', o.order_date) BETWEEN '01' AND '06'
212
- THEN o.total_amount ELSE 0 END), 1) AS h1_revenue,
213
- ROUND(SUM(CASE
214
  WHEN STRFTIME('%m', o.order_date) BETWEEN '07' AND '12'
215
- THEN o.total_amount ELSE 0 END), 1) AS h2_revenue
216
  FROM orders o
217
  JOIN customers c ON o.customer_id = c.customer_id
218
  WHERE o.status = 'completed'
 
59
  "hint": "JOIN orders with customers, GROUP BY customer, filter completed, ORDER and LIMIT",
60
  "answer_query": """
61
  SELECT c.first_name, c.last_name,
62
+ SUM(o.total_amount) AS total_revenue
63
  FROM orders o
64
  JOIN customers c ON o.customer_id = c.customer_id
65
  WHERE o.status = 'completed'
 
133
  "description": (
134
  "Calculate the month-over-month revenue growth percentage for completed orders in 2024. "
135
  "For each month show total revenue and percentage change vs previous month. "
136
+ "Return columns: month, total_revenue, prev_revenue, growth_pct. "
 
137
  "Order by month ascending. Round growth_pct to 2 decimal places. "
138
  "For the first month, prev_revenue and growth_pct should be NULL."
139
  ),
 
141
  "hint": "Use LAG() window function to get previous month revenue, then calculate (current - prev) / prev * 100",
142
  "answer_query": """
143
  WITH monthly AS (
144
+ SELECT STRFTIME('%m', order_date) AS month,
145
+ ROUND(SUM(total_amount), 2) AS total_revenue
146
  FROM orders
147
  WHERE status = 'completed'
148
  AND order_date LIKE '2024%'
 
206
  SELECT c.customer_id,
207
  c.first_name,
208
  c.last_name,
209
+ SUM(CASE
210
  WHEN STRFTIME('%m', o.order_date) BETWEEN '01' AND '06'
211
+ THEN o.total_amount ELSE 0 END) AS h1_revenue,
212
+ SUM(CASE
213
  WHEN STRFTIME('%m', o.order_date) BETWEEN '07' AND '12'
214
+ THEN o.total_amount ELSE 0 END) AS h2_revenue
215
  FROM orders o
216
  JOIN customers c ON o.customer_id = c.customer_id
217
  WHERE o.status = 'completed'