diff --git a/data/questions_gen_postgres.csv b/data/questions_gen_postgres.csv index 83b2870..ed5e514 100644 --- a/data/questions_gen_postgres.csv +++ b/data/questions_gen_postgres.csv @@ -219,4 +219,14 @@ How many check-ins occurred on Mondays at businesses in the state of California? Filter strings of state using exact upper case matches. Assume the rating of a business to be its average rating, and compute it before computing other aggregates on it. Always truncate dates in the question to its current month and year (if applicable) before filtering on `review.year` and `review.month`. -" \ No newline at end of file +" +"Return the customer who made the most sell transactions in 2023-04-01. Return the id, name and number of transactions.","WITH SellTransactions AS (SELECT sbTxCustId, COUNT(*) AS num_tx FROM sbTransaction WHERE sbTxDateTime::date = '2023-04-01' AND sbTxType = 'sell' GROUP BY sbTxCustId) SELECT c.sbCustId, c.sbCustName, st.num_tx FROM sbCustomer c JOIN SellTransactions st ON c.sbCustId = st.sbTxCustId ORDER BY st.num_tx DESC LIMIT 1;",broker,date_functions, +"What is the monthly average transaction price for successful transactions in the 1st quarter of 2023?","SELECT DATE_TRUNC('month', sbTxDateTime) AS MONTH, AVG(sbTxPrice) AS avg_price FROM sbTransaction WHERE sbTxType = 'sell' AND sbTxStatus = 'success' AND sbTxDateTime BETWEEN '2023-01-01' AND '2023-03-31' GROUP BY MONTH ORDER BY MONTH;",broker,date_functions, +"Lowest daily closest price for symbol `VTI` in the past 7 days","CURRENT_DATE - INTERVAL '6 days', 205.00, 207.50, 203.75, 206.25, 8000000, EXTRACT(EPOCH FROM CURRENT_TIMESTAMP - INTERVAL '6 days') * 1000, 'NYSE'),",broker,date_functions, +"customer id and their time from joining to their first transaction. ignore customers who haven't made any transactions.","SELECT c.sbCustId, c.sbCustJoinDate - MIN(t.sbTxDateTime) AS DaysFromJoinToFirstTransaction FROM sbCustomer c JOIN sbTransaction t ON c.sbCustId = t.sbTxCustId GROUP BY c.sbCustId",broker,date_functions, +"number of transactions by users who joined in the past 70 days","SELECT COUNT(t.sbTxCustId) AS transaction_count FROM sbTransaction t JOIN sbCustomer c ON t.sbTxCustId = c.sbCustId WHERE c.sbCustJoinDate >= CURRENT_DATE - INTERVAL '70' DAY;",broker,date_functions, +"Return the name and phone number of the salesperson with the shortest time from being hired to getting fired. Return the number of days he/she was employed for.","SELECT s.first_name, s.last_name, s.phone, s.termination_date - s.hire_date AS days_employed FROM salespersons s ORDER BY days_employed ASC LIMIT 1;",broker,date_functions, +"Return the number of payments made on weekends to the vendor named 'Utility Company'","SELECT COUNT(*) AS weekend_payments FROM payments_made WHERE vendor_name = 'Utility Company' AND EXTRACT(DOW FROM payment_date) IN (0, 6);",broker,date_functions, +"show me the daily total amount of payments received in the whole of last week, split by the payment_method","SELECT payment_date, payment_method, SUM(payment_amount) AS total_amount FROM payments_received WHERE payment_date BETWEEN DATE_TRUNC('WEEK', CURRENT_DATE) - INTERVAL '1 week' AND DATE_TRUNC('WEEK', CURRENT_DATE) GROUP BY payment_date, payment_method ORDER BY payment_date DESC, payment_method ASC;",broker,date_functions, +"Which cars were in inventory in the latest snapshot for march 2023? Return the car id, make, model, and year.","WITH latest_snapshot AS (SELECT MAX(snapshot_date) AS snapshot_date FROM inventory_snapshots WHERE snapshot_date BETWEEN '2023-03-01' AND '2023-03-31' ), latest_snapshot_data AS (SELECT inv.car_id FROM inventory_snapshots inv JOIN latest_snapshot ls ON inv.snapshot_date = ls.snapshot_date WHERE inv.is_in_inventory = TRUE ) SELECT c.id, c.make, c.model, c.year FROM cars c JOIN latest_snapshot_data lsd ON c.id = lsd.car_id;",broker,date_functions, +"What were the total quarterly sales in 2023 grouped by customer's state? Represent each quarter as the first date in the quarter.","SELECT DATE_TRUNC('QUARTER', s.sale_date) AS QUARTER, c.state, SUM(s.sale_price) AS total_sales FROM sales s JOIN customers c ON s.customer_id = c.id WHERE EXTRACT(YEAR FROM s.sale_date) = 2023 GROUP BY c.state, QUARTER HAVING SUM(s.sale_price) > 0 ORDER BY QUARTER, c.state ;",broker,date_functions, \ No newline at end of file