{"question":"What percentage of orders included a promotional item?","ground_truth_query":"SELECT ROUND((COUNT(DISTINCT CASE WHEN total_discount_before_tax > 0 THEN order_id ELSE NULL END) * 100.0) \/ COUNT(DISTINCT order_id), 2) AS percentage_of_orders_with_promotional_items FROM order_values WHERE order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12));","execution_status_gtu":"Success","execution_result_gtu":" percentage_of_orders_with_promotional_items\n0 48.91","llama_sqlcoder_3_few_promp":"SELECT CAST(COUNT(DISTINCT CASE WHEN product_category = 'Promotional Item' THEN order_line_item_id END) AS FLOAT) \/ NULLIF(COUNT(DISTINCT order_line_item_id), 0) AS proportion FROM order_values;","execution_status_llama":"Success","execution_result_llama":" proportion\n0 0.0","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"What percentage of orders included a promotional item?","role":"user"},{"content":"SELECT ROUND((COUNT(DISTINCT CASE WHEN total_discount_before_tax > 0 THEN order_id ELSE NULL END) * 100.0) \/ COUNT(DISTINCT order_id), 2) AS percentage_of_orders_with_promotional_items FROM order_values WHERE order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12));","role":"assistant"}]} {"question":"what is the percentage of non-metro \/ non-tier-1 city revenue","ground_truth_query":"SELECT ROUND((SUM(CASE WHEN LOWER(billing_address_city) NOT IN ('mumbai', 'delhi', 'kolkata', 'chennai', 'bangalore', 'hyderabad', 'ahmedabad', 'pune') THEN net_sales_before_tax ELSE 0 END) \/ SUM(net_sales_before_tax)) * 100, 2) AS non_metro_revenue_percentage FROM fabric_master_data.processed_tables.order_values_auth0_65fab45d0ad102735d51c77b WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND net_sales_before_tax IS NOT NULL;","execution_status_gtu":"Failed","execution_result_gtu":"[INSUFFICIENT_PERMISSIONS] Insufficient privileges:\nUser does not have USE SCHEMA on Schema 'fabric_master_data.processed_tables'. SQLSTATE: 42501","llama_sqlcoder_3_few_promp":"SELECT (SUM(CASE WHEN LOWER(billing_address_city) NOT IN ('mumbai', 'delhi', 'bangalore', 'hyderabad', 'chennai', 'kolkata', 'pune') THEN COALESCE(net_sales_before_tax, 0) ELSE 0 END) * 100.0 \/ NULLIF(SUM(COALESCE(net_sales_before_tax, 0)), 0)) AS percentage_non_metror_tier_1 FROM order_values WHERE order_year = 2024 AND order_month = 4 AND billing_address_city IS NOT NULL;","execution_status_llama":"Success","execution_result_llama":" percentage_non_metror_tier_1\n0 90.25988","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"what is the percentage of non-metro \/ non-tier-1 city revenue","role":"user"},{"content":"SELECT ROUND((SUM(CASE WHEN LOWER(billing_address_city) NOT IN ('mumbai', 'delhi', 'kolkata', 'chennai', 'bangalore', 'hyderabad', 'ahmedabad', 'pune') THEN net_sales_before_tax ELSE 0 END) \/ SUM(net_sales_before_tax)) * 100, 2) AS non_metro_revenue_percentage FROM fabric_master_data.processed_tables.order_values_auth0_65fab45d0ad102735d51c77b WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND net_sales_before_tax IS NOT NULL;","role":"assistant"}]} {"question":"Which are the states with the lowest return rate in terms of revenue?","ground_truth_query":"SELECT LOWER(billing_address_state) AS state, ROUND(SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) \/ COUNT(*) * 100.0, 2) AS return_rate FROM order_values WHERE billing_address_state IS NOT NULL AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY LOWER(billing_address_state) ORDER BY return_rate ASC;","execution_status_gtu":"Success","execution_result_gtu":" state return_rate\n0 daman and diu 0.00\n1 dadra and nagar haveli and daman and diu 0.00\n2 nagaland 0.00\n3 chandigarh 0.00\n4 dadra and nagar haveli 0.00\n5 tripura 0.00\n6 jammu & kashmir 0.00\n7 sikkim 0.00\n8 mizoram 0.00\n9 manipur 0.00\n10 arunachal pradesh 0.00\n11 goa 0.00\n12 daman & diu 0.00\n13 puducherry 0.00\n14 gujarat 4.00\n15 telangana 4.39\n16 andhra pradesh 4.44\n17 uttarakhand 6.35\n18 assam 6.45\n19 odisha 6.74\n20 punjab 7.14\n21 karnataka 8.20\n22 west bengal 8.90\n23 tamil nadu 8.94\n24 delhi 9.31\n25 jharkhand 9.68\n26 haryana 9.86\n27 kerala 10.00\n28 madhya pradesh 10.19\n29 maharashtra 11.11\n30 meghalaya 11.11\n31 bihar 11.95\n32 uttar pradesh 12.50\n33 rajasthan 16.43\n34 jammu and kashmir 22.00\n35 himachal pradesh 23.81\n36 chhattisgarh 30.77\n37 andaman and nicobar islands 100.00","llama_sqlcoder_3_few_promp":"SELECT LOWER(billing_address_state) AS state, SUM(COALESCE(total_returns_before_tax, 0)) AS total_returns FROM order_values GROUP BY LOWER(billing_address_state) ORDER BY total_returns ASC LIMIT 5;","execution_status_llama":"Success","execution_result_llama":" state total_returns\n0 ka 0.0\n1 new delhi 0.0\n2 ontario 0.0\n3 andaman & nicobar islands 0.0\n4 dadra and nagar haveli and daman and diu 0.0","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Which are the states with the lowest return rate in terms of revenue?","role":"user"},{"content":"SELECT LOWER(billing_address_state) AS state, ROUND(SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) \/ COUNT(*) * 100.0, 2) AS return_rate FROM order_values WHERE billing_address_state IS NOT NULL AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY LOWER(billing_address_state) ORDER BY return_rate ASC;","role":"assistant"}]} {"question":"Split of revenue by state in south india","ground_truth_query":"SELECT LOWER(billing_address_state) AS state, SUM(net_sales_before_tax) AS net_sales FROM order_values WHERE LOWER(billing_address_state) IN ('andhra pradesh', 'karnataka', 'kerala', 'tamil nadu', 'telangana') AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY LOWER(billing_address_state) ORDER BY net_sales DESC;","execution_status_gtu":"Success","execution_result_gtu":" state net_sales\n0 telangana 117150.225116\n1 karnataka 97635.591711\n2 tamil nadu 93132.711026\n3 andhra pradesh 77241.147340\n4 kerala 33999.341690","llama_sqlcoder_3_few_promp":"SELECT LOWER(billing_address_state) AS state, SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales FROM order_values WHERE LOWER(billing_address_state) IN ('andhra pradesh', 'karnataka', 'tamil nadu', 'kerala') GROUP BY LOWER(billing_address_state) ORDER BY total_sales DESC;","execution_status_llama":"Success","execution_result_llama":" state total_sales\n0 karnataka 1.911360e+06\n1 tamil nadu 1.532524e+06\n2 andhra pradesh 1.431457e+06\n3 kerala 4.382533e+05","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Split of revenue by state in south india","role":"user"},{"content":"SELECT LOWER(billing_address_state) AS state, SUM(net_sales_before_tax) AS net_sales FROM order_values WHERE LOWER(billing_address_state) IN ('andhra pradesh', 'karnataka', 'kerala', 'tamil nadu', 'telangana') AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY LOWER(billing_address_state) ORDER BY net_sales DESC;","role":"assistant"}]} {"question":"Which are the top 5 cities by sales in April 2024?","ground_truth_query":"SELECT LOWER(billing_address_city) AS city, SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales FROM order_values WHERE order_month = 4 AND order_year = 2024 AND billing_address_city IS NOT NULL GROUP BY LOWER(billing_address_city) ORDER BY total_sales DESC LIMIT 5;","execution_status_gtu":"Success","execution_result_gtu":" city total_sales\n0 new delhi 2710.16\n1 gorakhpur 1355.08\n2 silvassa 1355.08\n3 patiala 1355.08\n4 prayagraj 1355.08","llama_sqlcoder_3_few_promp":"SELECT LOWER(billing_address_city) AS city, SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales FROM order_values WHERE order_month = 4 AND order_year = 2024 AND billing_address_city IS NOT NULL GROUP BY LOWER(billing_address_city) ORDER BY total_sales DESC LIMIT 5;","execution_status_llama":"Success","execution_result_llama":" city total_sales\n0 new delhi 2710.16\n1 gorakhpur 1355.08\n2 silvassa 1355.08\n3 patiala 1355.08\n4 prayagraj 1355.08","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Which are the top 5 cities by sales in April 2024?","role":"user"},{"content":"SELECT LOWER(billing_address_city) AS city, SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales FROM order_values WHERE order_month = 4 AND order_year = 2024 AND billing_address_city IS NOT NULL GROUP BY LOWER(billing_address_city) ORDER BY total_sales DESC LIMIT 5;","role":"assistant"}]} {"question":"AOV for the last month on Shopify","ground_truth_query":"WITH order_totals AS (SELECT order_id, SUM(net_sales_before_tax) AS total_net_sales_before_tax FROM order_values WHERE refund_status = 'false' AND cancellation_status = 'false' AND source = 'shopify' AND order_year = YEAR(DATE_SUB(CURRENT_DATE, DAY(CURRENT_DATE))) AND order_month = MONTH(DATE_SUB(CURRENT_DATE, DAY(CURRENT_DATE))) GROUP BY order_id) SELECT ROUND(AVG(total_net_sales_before_tax), 2) AS avg_net_sales_aov FROM order_totals;","execution_status_gtu":"Success","execution_result_gtu":" avg_net_sales_aov\n0 919.75","llama_sqlcoder_3_few_promp":"SELECT AVG(COALESCE(order_values.net_sales_before_tax, 0)) AS average_order_value FROM order_values WHERE LOWER(order_values.source) ='shopify' AND order_values.order_date >= (DATE_TRUNC('month', CURRENT_DATE) - INTERVAL '1 month') AND order_values.order_date < DATE_TRUNC('month', CURRENT_DATE);","execution_status_llama":"Success","execution_result_llama":" average_order_value\n0 823.770779","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"AOV for the last month on Shopify","role":"user"},{"content":"WITH order_totals AS (SELECT order_id, SUM(net_sales_before_tax) AS total_net_sales_before_tax FROM order_values WHERE refund_status = 'false' AND cancellation_status = 'false' AND source = 'shopify' AND order_year = YEAR(DATE_SUB(CURRENT_DATE, DAY(CURRENT_DATE))) AND order_month = MONTH(DATE_SUB(CURRENT_DATE, DAY(CURRENT_DATE))) GROUP BY order_id) SELECT ROUND(AVG(total_net_sales_before_tax), 2) AS avg_net_sales_aov FROM order_totals;","role":"assistant"}]} {"question":"Compare the sales performance of products before and after a price change.","ground_truth_query":"WITH price_changes AS (SELECT product_id, product_title, product_price, order_date, LAG(product_price) OVER (PARTITION BY product_id ORDER BY order_date) AS previous_price FROM order_values WHERE order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12))) , price_comparison AS (SELECT product_id, product_title, order_date, product_price, previous_price, CASE WHEN product_price > previous_price THEN 'after_price_increase' WHEN product_price < previous_price THEN 'after_price_decrease' ELSE 'no_change' END AS price_change FROM price_changes WHERE previous_price IS NOT NULL) SELECT price_change, SUM(net_sales_before_tax) AS total_net_sales FROM price_comparison pc JOIN order_values ov ON pc.product_id = ov.product_id AND pc.order_date = ov.order_date GROUP BY price_change;","execution_status_gtu":"Success","execution_result_gtu":" price_change total_net_sales\n0 after_price_decrease 3.059964e+05\n1 after_price_increase 3.286410e+05\n2 no_change 8.929041e+06","llama_sqlcoder_3_few_promp":"SELECT product_id, product_title, gross_sales_price_before_tax, gross_sales_price_after_tax, (gross_sales_price_after_tax - gross_sales_price_before_tax) AS change_in_price, (gross_sales_price_after_tax - gross_sales_price_before_tax) \/ NULLIF(gross_sales_price_before_tax, 0) AS percentage_change FROM order_values WHERE product_category = 'Insulated Sipper' AND gross_sales_price_before_tax > 0 AND gross_sales_price_after_tax > 0 ORDER BY product_id NULLS LAST;","execution_status_llama":"Success","execution_result_llama":"Empty DataFrame\nColumns: [product_id, product_title, gross_sales_price_before_tax, gross_sales_price_after_tax, change_in_price, percentage_change]\nIndex: []","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Compare the sales performance of products before and after a price change.","role":"user"},{"content":"WITH price_changes AS (SELECT product_id, product_title, product_price, order_date, LAG(product_price) OVER (PARTITION BY product_id ORDER BY order_date) AS previous_price FROM order_values WHERE order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12))) , price_comparison AS (SELECT product_id, product_title, order_date, product_price, previous_price, CASE WHEN product_price > previous_price THEN 'after_price_increase' WHEN product_price < previous_price THEN 'after_price_decrease' ELSE 'no_change' END AS price_change FROM price_changes WHERE previous_price IS NOT NULL) SELECT price_change, SUM(net_sales_before_tax) AS total_net_sales FROM price_comparison pc JOIN order_values ov ON pc.product_id = ov.product_id AND pc.order_date = ov.order_date GROUP BY price_change;","role":"assistant"}]} {"question":"What is the average lifetime value of a customer as of 2024?","ground_truth_query":"SELECT ROUND(AVG(customer_lifetime_value), 2) AS avg_lifetime_value FROM (SELECT customer_id, SUM(net_sales_before_tax) AS customer_lifetime_value FROM order_values WHERE order_year <= 2024 GROUP BY customer_id) AS customer_lifetime_values;","execution_status_gtu":"Success","execution_result_gtu":" avg_lifetime_value\n0 1138.79","llama_sqlcoder_3_few_promp":"SELECT AVG(CASE WHEN o.order_date >= '2024-01-01' AND o.order_date < '2024-12-31' THEN o.gross_merchandise_value ELSE NULL END) AS avg_ltv FROM order_values o WHERE o.customer_id IN (SELECT customer_id FROM order_values WHERE order_date >= '2024-01-01' AND order_date < '2024-12-31') GROUP BY o.customer_id HAVING COUNT(DISTINCT CASE WHEN o.order_date >= '2024-01-01' AND o.order_date < '2024-12-31' THEN o.order_date END) >= 1;","execution_status_llama":"Success","execution_result_llama":" avg_ltv\n0 1199.000000\n1 1249.000000\n2 999.000000\n3 1599.000000\n4 999.000000\n5 1199.000000\n6 1199.000000\n7 1049.000000\n8 1599.000000\n9 1099.000000\n10 999.000000\n11 999.000000\n12 999.000000\n13 1299.000000\n14 1299.000000\n15 1049.000000\n16 1099.000000\n17 1099.000000\n18 1399.000000\n19 1199.000000\n20 1599.000000\n21 1099.000000\n22 1049.000000\n23 1132.333333\n24 1599.000000\n25 999.000000\n26 1299.000000\n27 1199.000000\n28 1299.000000\n29 999.000000\n30 3398.000000\n31 1299.000000\n32 1099.000000\n33 1499.000000\n34 1499.000000\n35 1499.000000\n36 1299.000000\n37 999.000000\n38 1299.000000\n39 999.000000\n40 1699.000000\n41 1099.000000\n42 399.000000\n43 1299.000000\n44 1299.000000\n45 1099.000000\n46 999.000000\n47 999.000000\n48 1049.000000\n49 1499.000000\n50 999.000000\n51 1699.000000\n52 1699.000000\n53 399.000000\n54 1199.000000\n55 1199.000000\n56 1099.000000\n57 1299.000000\n58 1049.000000\n59 1099.000000\n60 1599.000000\n61 1099.000000\n62 1399.000000\n63 1199.000000\n64 1099.000000\n65 1199.000000\n66 1599.000000\n67 1199.000000\n68 1099.000000\n69 899.000000\n70 1099.000000\n71 1299.000000\n72 999.000000\n73 1199.000000\n74 999.000000\n75 1099.000000\n76 1199.000000\n77 1099.000000\n78 1299.000000\n79 999.000000\n80 1299.000000\n81 1399.000000\n82 1299.000000\n83 1199.000000\n84 1299.000000\n85 1149.000000\n86 999.000000\n87 1249.000000\n88 1499.000000\n89 1532.333333\n90 999.000000\n91 1399.000000\n92 999.000000\n93 1099.000000\n94 1199.000000\n95 1049.000000\n96 1199.000000\n97 1599.000000\n98 999.000000\n99 1299.000000\n100 999.000000\n101 1299.000000\n102 1099.000000\n103 1199.000000\n104 1299.000000\n105 1099.000000\n106 1299.000000\n107 1599.000000\n108 1299.000000\n109 1099.000000\n110 1399.000000\n111 1199.000000\n112 1399.000000\n113 999.000000\n114 1299.000000\n115 1399.000000\n116 999.000000\n117 1199.000000\n118 999.000000\n119 999.000000\n120 1099.000000\n121 399.000000\n122 1099.000000\n123 1199.000000\n124 1199.000000\n125 999.000000\n126 1199.000000\n127 999.000000\n128 1299.000000\n129 1099.000000\n130 1099.000000\n131 1099.000000\n132 1499.000000\n133 999.000000\n134 999.000000\n135 599.000000\n136 1099.000000\n137 899.000000\n138 999.000000\n139 1332.333333\n140 1299.000000\n141 1299.000000\n142 1099.000000\n143 999.000000\n144 1199.000000\n145 999.000000\n146 999.000000\n147 1599.000000\n148 1299.000000\n149 1099.000000\n150 999.000000\n151 1399.000000\n152 899.000000\n153 1199.000000\n154 999.000000\n155 1299.000000\n156 1299.000000\n157 1099.000000\n158 1599.000000\n159 999.000000\n160 399.000000\n161 1199.000000\n162 999.000000\n163 1399.000000\n164 1099.000000\n165 1399.000000\n166 1299.000000\n167 1299.000000\n168 999.000000\n169 1099.000000\n170 999.000000\n171 999.000000\n172 1299.000000\n173 1299.000000\n174 999.000000\n175 999.000000\n176 1199.000000\n177 1299.000000\n178 1099.000000\n179 999.000000\n180 1099.000000\n181 1049.000000\n182 1299.000000\n183 999.000000\n184 399.000000\n185 999.000000\n186 999.000000\n187 999.000000\n188 999.000000\n189 1199.000000\n190 1499.000000\n191 1199.000000\n192 1099.000000\n193 1399.000000\n194 51.000000\n195 1099.000000\n196 1299.000000\n197 1099.000000\n198 1099.000000\n199 1265.666667\n200 1099.000000\n201 1199.000000\n202 999.000000\n203 999.000000\n204 1099.000000\n205 1199.000000\n206 1499.000000\n207 1399.000000\n208 1299.000000\n209 999.000000\n210 1.000000\n211 1299.000000\n212 1599.000000\n213 699.000000\n214 999.000000\n215 1399.000000\n216 999.000000\n217 1199.000000\n218 1199.000000\n219 999.000000\n220 1399.000000\n221 999.000000\n222 999.000000\n223 1299.000000\n224 999.000000\n225 499.000000\n226 1299.000000\n227 999.000000\n228 1099.000000\n229 1299.000000\n230 1199.000000\n231 1599.000000\n232 1199.000000\n233 1099.000000\n234 1299.000000\n235 1099.000000\n236 999.000000\n237 1299.000000\n238 899.000000\n239 1299.000000\n240 999.000000\n241 1699.000000\n242 999.000000\n243 1099.000000\n244 1099.000000\n245 999.000000\n246 1199.000000\n247 999.000000\n248 1099.000000\n249 1199.000000\n250 399.000000\n251 1299.000000\n252 1499.000000\n253 1099.000000\n254 399.000000\n255 1099.000000\n256 999.000000\n257 1299.000000\n258 999.000000\n259 1599.000000\n260 1099.000000\n261 1132.333333\n262 999.000000\n263 999.000000\n264 1599.000000\n265 999.000000\n266 1299.000000\n267 1599.000000\n268 1199.000000\n269 999.000000\n270 1199.000000\n271 1399.000000\n272 1099.000000\n273 1599.000000\n274 1099.000000\n275 1299.000000\n276 1199.000000\n277 1499.000000\n278 999.000000\n279 1099.000000\n280 1499.000000\n281 999.000000\n282 999.000000\n283 1599.000000\n284 999.000000\n285 499.000000\n286 1299.000000\n287 1099.000000\n288 1199.000000\n289 1299.000000\n290 1199.000000\n291 1199.000000\n292 1299.000000\n293 999.000000\n294 999.000000\n295 1299.000000\n296 1399.000000\n297 1299.000000\n298 1099.000000\n299 999.000000\n300 1299.000000\n301 1299.000000\n302 1199.000000\n303 1099.000000\n304 1099.000000\n305 1399.000000\n306 1099.000000\n307 1099.000000\n308 1299.000000\n309 999.000000\n310 1299.000000\n311 500.000000\n312 1199.000000\n313 1399.000000\n314 999.000000\n315 999.000000\n316 1199.000000\n317 999.000000\n318 1499.000000\n319 1099.000000\n320 1199.000000\n321 1199.000000\n322 1199.000000\n323 1099.000000\n324 999.000000\n325 1099.000000\n326 999.000000\n327 1399.000000\n328 1199.000000\n329 999.000000\n330 1099.000000\n331 1199.000000\n332 999.000000\n333 1199.000000\n334 1199.000000\n335 1032.333333\n336 999.000000\n337 1599.000000\n338 1.000000\n339 1599.000000\n340 1299.000000\n341 1299.000000\n342 999.000000\n343 1199.000000\n344 999.000000\n345 999.000000\n346 999.000000\n347 2398.000000\n348 1199.000000\n349 999.000000\n350 999.000000\n351 1199.000000\n352 1599.000000\n353 1299.000000\n354 1099.000000\n355 999.000000\n356 999.000000\n357 999.000000\n358 1599.000000\n359 1299.000000\n360 999.000000\n361 1299.000000\n362 499.000000\n363 1299.000000\n364 899.000000\n365 1299.000000\n366 1099.000000\n367 1599.000000\n368 1299.000000\n369 999.000000\n370 999.000000\n371 999.000000\n372 999.000000\n373 1099.000000\n374 1199.000000\n375 999.000000\n376 1199.000000\n377 1599.000000\n378 999.000000\n379 1099.000000\n380 1099.000000\n381 1299.000000\n382 999.000000\n383 1065.666667\n384 999.000000\n385 999.000000\n386 499.000000\n387 1599.000000\n388 1199.000000\n389 1299.000000\n390 999.000000\n391 1499.000000\n392 1099.000000\n393 999.000000\n394 899.000000\n395 1199.000000\n396 1299.000000\n397 399.000000\n398 1299.000000\n399 1099.000000\n400 999.000000\n401 1199.000000\n402 1099.000000\n403 1199.000000\n404 1199.000000\n405 999.000000\n406 999.000000\n407 999.000000\n408 1499.000000\n409 999.000000\n410 999.000000\n411 999.000000\n412 1399.000000\n413 999.000000\n414 999.000000\n415 999.000000\n416 1599.000000\n417 1099.000000\n418 1099.000000\n419 1199.000000\n420 1049.000000\n421 1399.000000\n422 1299.000000\n423 399.000000\n424 1099.000000\n425 999.000000\n426 2099.000000\n427 999.000000\n428 1299.000000\n429 1199.000000\n430 1099.000000\n431 1099.000000\n432 1099.000000\n433 1299.000000\n434 999.000000\n435 1299.000000\n436 1899.000000\n437 999.000000\n438 1599.000000\n439 1299.000000\n440 499.000000\n441 1499.000000\n442 399.000000\n443 399.000000\n444 1099.000000\n445 999.000000\n446 1199.000000\n447 999.000000\n448 999.000000\n449 1249.000000\n450 1099.000000\n451 1199.000000\n452 1499.000000\n453 1099.000000\n454 999.000000\n455 1099.000000\n456 999.000000\n457 1199.000000\n458 999.000000\n459 999.000000\n460 1399.000000\n461 999.000000\n462 999.000000\n463 1249.000000\n464 1399.000000\n465 1299.000000\n466 999.000000\n467 1099.000000\n468 1599.000000\n469 999.000000\n470 999.000000\n471 1599.000000\n472 1199.000000\n473 1499.000000\n474 1599.000000\n475 999.000000\n476 1499.000000\n477 1099.000000\n478 1599.000000\n479 1199.000000\n480 1299.000000\n481 1299.000000\n482 999.000000\n483 1299.000000\n484 1199.000000\n485 999.000000\n486 999.000000\n487 1599.000000\n488 1399.000000\n489 999.000000\n490 999.000000\n491 999.000000\n492 1299.000000\n493 999.000000\n494 1299.000000\n495 999.000000\n496 1499.000000\n497 849.000000\n498 1299.000000\n499 2099.000000\n500 1299.000000\n501 1399.000000\n502 1099.000000\n503 1399.000000\n504 999.000000\n505 999.000000\n506 999.000000\n507 999.000000\n508 999.000000\n509 1199.000000\n510 1299.000000\n511 1599.000000\n512 1749.000000\n513 1149.000000\n514 999.000000\n515 499.000000\n516 999.000000\n517 999.000000\n518 1199.000000\n519 1299.000000\n520 1099.000000\n521 1199.000000\n522 999.000000\n523 1099.000000\n524 1099.000000\n525 1199.000000\n526 1099.000000\n527 1199.000000\n528 1199.000000\n529 1199.000000\n530 1099.000000\n531 1099.000000\n532 1199.000000\n533 1299.000000\n534 1049.000000\n535 1199.000000\n536 1299.000000\n537 2498.000000\n538 999.000000\n539 999.000000\n540 1599.000000\n541 499.000000\n542 999.000000\n543 1099.000000\n544 999.000000\n545 999.000000\n546 1399.000000\n547 1199.000000\n548 1299.000000\n549 1199.000000\n550 999.000000\n551 1299.000000\n552 1099.000000\n553 1099.000000\n554 1199.000000\n555 1199.000000\n556 1599.000000\n557 1599.000000\n558 1199.000000\n559 1199.000000\n560 999.000000\n561 999.000000\n562 1399.000000\n563 1199.000000\n564 1599.000000\n565 1099.000000\n566 999.000000\n567 1099.000000\n568 1399.000000\n569 999.000000\n570 999.000000\n571 1199.000000\n572 1399.000000\n573 999.000000\n574 1499.000000\n575 1249.000000\n576 1199.000000\n577 999.000000\n578 1099.000000\n579 1299.000000\n580 1599.000000\n581 1199.000000\n582 1299.000000\n583 999.000000\n584 599.000000\n585 1249.000000\n586 999.000000\n587 1399.000000\n588 1099.000000\n589 1199.000000\n590 1099.000000\n591 999.000000\n592 999.000000\n593 999.000000\n594 1299.000000\n595 999.000000\n596 1215.666667\n597 999.000000\n598 1099.000000\n599 999.000000\n600 1099.000000\n601 1199.000000\n602 1199.000000\n603 1299.000000\n604 1199.000000\n605 1199.000000\n606 999.000000\n607 999.000000\n608 999.000000\n609 1099.000000\n610 1249.000000\n611 1099.000000\n612 999.000000\n613 1199.000000\n614 1199.000000\n615 999.000000\n616 1299.000000\n617 999.000000\n618 999.000000\n619 1599.000000\n620 1099.000000\n621 1199.000000\n622 1099.000000\n623 1299.000000\n624 1199.000000\n625 999.000000\n626 1349.000000\n627 1199.000000\n628 1399.000000\n629 999.000000\n630 1099.000000\n631 999.000000\n632 999.000000\n633 999.000000\n634 1399.000000\n635 2498.000000\n636 1099.000000\n637 999.000000\n638 1599.000000\n639 1099.000000\n640 1199.000000\n641 1249.000000\n642 1099.000000\n643 1599.000000\n644 1099.000000\n645 1099.000000\n646 1099.000000\n647 1299.000000\n648 1099.000000\n649 999.000000\n650 1299.000000\n651 1099.000000\n652 1099.000000\n653 1399.000000\n654 699.000000\n655 999.000000\n656 999.000000\n657 999.000000\n658 1299.000000\n659 1399.000000\n660 1599.000000\n661 1299.000000\n662 1099.000000\n663 999.000000\n664 999.000000\n665 1099.000000\n666 999.000000\n667 1299.000000\n668 1299.000000\n669 1599.000000\n670 1049.000000\n671 1299.000000\n672 999.000000\n673 1499.000000\n674 999.000000\n675 999.000000\n676 999.000000\n677 1599.000000\n678 1299.000000\n679 1.000000\n680 999.000000\n681 899.000000\n682 1099.000000\n683 1099.000000\n684 999.000000\n685 999.000000\n686 1399.000000\n687 999.000000\n688 1199.000000\n689 1299.000000\n690 999.000000\n691 1199.000000\n692 1099.000000\n693 1199.000000\n694 1199.000000\n695 999.000000\n696 1599.000000\n697 1199.000000\n698 999.000000\n699 1099.000000\n700 999.000000\n701 1299.000000\n702 1199.000000\n703 999.000000\n704 1299.000000\n705 1199.000000\n706 1099.000000\n707 1099.000000\n708 1049.000000\n709 1549.000000\n710 999.000000\n711 1399.000000\n712 1299.000000\n713 999.000000\n714 1299.000000\n715 1099.000000\n716 1349.000000\n717 1099.000000\n718 1299.000000\n719 999.000000\n720 1299.000000\n721 1199.000000\n722 999.000000\n723 1299.000000\n724 1499.000000\n725 999.000000\n726 999.000000\n727 599.000000\n728 1199.000000\n729 1199.000000\n730 1399.000000\n731 1099.000000\n732 984.714286\n733 899.000000\n734 499.000000\n735 999.000000\n736 1099.000000\n737 999.000000\n738 1099.000000\n739 999.000000\n740 999.000000\n741 999.000000\n742 1249.000000\n743 1065.666667\n744 1299.000000\n745 999.000000\n746 1099.000000\n747 1099.000000\n748 1599.000000\n749 1199.000000\n750 999.000000\n751 1199.000000\n752 1799.000000\n753 999.000000\n754 1099.000000\n755 999.000000\n756 1599.000000\n757 999.000000\n758 999.000000\n759 1099.000000\n760 999.000000\n761 1099.000000\n762 1099.000000\n763 999.000000\n764 999.000000\n765 1099.000000\n766 1299.000000\n767 1299.000000\n768 1099.000000\n769 999.000000\n770 1299.000000\n771 1599.000000\n772 1099.000000\n773 999.000000\n774 999.000000\n775 1599.000000\n776 1099.000000\n777 1099.000000\n778 1099.000000\n779 1099.000000\n780 999.000000\n781 1099.000000\n782 1299.000000\n783 999.000000\n784 999.000000\n785 1099.000000\n786 1199.000000\n787 1149.000000\n788 1199.000000\n789 899.000000\n790 1399.000000\n791 999.000000\n792 1399.000000\n793 1699.000000\n794 1199.000000\n795 1299.000000\n796 1399.000000\n797 999.000000\n798 1099.000000\n799 1099.000000\n800 1899.000000\n801 1299.000000\n802 1999.000000\n803 999.000000\n804 1099.000000\n805 1399.000000\n806 1099.000000\n807 1099.000000\n808 1199.000000\n809 999.000000\n810 1099.000000\n811 999.000000\n812 1399.000000\n813 1399.000000\n814 1199.000000\n815 1299.000000\n816 999.000000\n817 1199.000000\n818 1099.000000\n819 1099.000000\n820 1299.000000\n821 1199.000000\n822 1199.000000\n823 1699.000000\n824 1199.000000\n825 1099.000000\n826 1199.000000\n827 999.000000\n828 999.000000\n829 599.000000\n830 1099.000000\n831 999.000000\n832 1099.000000\n833 1699.000000\n834 1299.000000\n835 999.000000\n836 1799.000000\n837 1299.000000\n838 1199.000000\n839 999.000000\n840 999.000000\n841 499.000000\n842 999.000000\n843 2099.000000\n844 1199.000000\n845 1399.000000\n846 1199.000000\n847 1099.000000\n848 999.000000\n849 999.000000\n850 1499.000000\n851 1299.000000\n852 999.000000\n853 999.000000\n854 999.000000\n855 1299.000000\n856 1099.000000\n857 1299.000000\n858 1299.000000\n859 1099.000000\n860 999.000000\n861 1099.000000\n862 1099.000000\n863 1199.000000\n864 1299.000000\n865 1199.000000\n866 999.000000\n867 1099.000000\n868 999.000000\n869 999.000000\n870 1199.000000\n871 1799.000000\n872 999.000000\n873 999.000000\n874 1599.000000\n875 1199.000000\n876 999.000000\n877 1199.000000\n878 999.000000\n879 999.000000\n880 1099.000000\n881 999.000000\n882 1599.000000\n883 1099.000000\n884 2099.000000\n885 999.000000\n886 1299.000000\n887 1599.000000\n888 1099.000000\n889 1199.000000\n890 1299.000000\n891 999.000000\n892 999.000000\n893 1399.000000\n894 1599.000000\n895 999.000000\n896 1099.000000\n897 1099.000000\n898 1099.000000\n899 999.000000\n900 1199.000000\n901 1199.000000\n902 1299.000000\n903 1799.000000\n904 1599.000000\n905 1299.000000\n906 1099.000000\n907 1099.000000\n908 999.000000\n909 1199.000000\n910 1599.000000\n911 1199.000000\n912 999.000000\n913 1199.000000\n914 1299.000000\n915 999.000000\n916 999.000000\n917 999.000000\n918 1099.000000\n919 1199.000000\n920 1299.000000\n921 1049.000000\n922 1199.000000\n923 1499.000000\n924 999.000000\n925 999.000000\n926 1599.000000\n927 1099.000000\n928 1399.000000\n929 1299.000000\n930 2099.000000\n931 1299.000000\n932 1299.000000\n933 1299.000000\n934 1099.000000\n935 999.000000\n936 1099.000000\n937 699.000000\n938 1299.000000\n939 999.000000\n940 1099.000000\n941 1299.000000\n942 1599.000000\n943 1099.000000\n944 1099.000000\n945 1499.000000\n946 1299.000000\n947 999.000000\n948 1599.000000\n949 999.000000\n950 1099.000000\n951 1199.000000\n952 1499.000000\n953 999.000000\n954 1299.000000\n955 1199.000000\n956 999.000000\n957 1099.000000\n958 999.000000\n959 999.000000\n960 999.000000\n961 1399.000000\n962 1599.000000\n963 999.000000\n964 999.000000\n965 999.000000\n966 1199.000000\n967 1299.000000\n968 1299.000000\n969 999.000000\n970 1199.000000\n971 1299.000000\n972 999.000000\n973 1199.000000\n974 1099.000000\n975 1199.000000\n976 333.666667\n977 1199.000000\n978 1299.000000\n979 1049.000000\n980 1349.000000\n981 1299.000000\n982 1399.000000\n983 1499.000000\n984 999.000000\n985 1199.000000\n986 1599.000000\n987 1299.000000\n988 1099.000000\n989 1599.000000\n990 1524.000000\n991 1199.000000\n992 1299.000000\n993 1099.000000\n994 1299.000000\n995 1299.000000\n996 999.000000\n997 1349.000000\n998 999.000000\n999 1232.333333\n1000 1399.000000\n1001 1199.000000\n1002 1199.000000\n1003 1299.000000\n1004 999.000000\n1005 999.000000\n1006 999.000000\n1007 1199.000000\n1008 1099.000000\n1009 1399.000000\n1010 1299.000000\n1011 999.000000\n1012 999.000000\n1013 999.000000\n1014 1099.000000\n1015 1299.000000\n1016 999.000000\n1017 1099.000000\n1018 1299.000000\n1019 1099.000000\n1020 999.000000\n1021 1099.000000\n1022 1099.000000\n1023 1199.000000\n1024 1099.000000\n1025 1099.000000\n1026 1549.000000\n1027 1099.000000\n1028 599.000000\n1029 999.000000\n1030 999.000000\n1031 1099.000000\n1032 2099.000000\n1033 1199.000000\n1034 1299.000000\n1035 1099.000000\n1036 1399.000000\n1037 1065.666667\n1038 999.000000\n1039 1099.000000\n1040 1299.000000\n1041 999.000000\n1042 399.000000\n1043 1099.000000\n1044 1499.000000\n1045 1299.000000\n1046 1199.000000\n1047 1199.000000\n1048 1199.000000\n1049 999.000000\n1050 999.000000\n1051 999.000000\n1052 1299.000000\n1053 999.000000\n1054 1299.000000\n1055 1099.000000\n1056 999.000000\n1057 999.000000\n1058 999.000000\n1059 1299.000000\n1060 1599.000000\n1061 999.000000\n1062 999.000000\n1063 1399.000000\n1064 1599.000000\n1065 1099.000000\n1066 999.000000\n1067 1099.000000\n1068 1099.000000\n1069 999.000000\n1070 1249.000000\n1071 1299.000000\n1072 999.000000\n1073 1299.000000\n1074 1199.000000\n1075 999.000000\n1076 1099.000000\n1077 1599.000000\n1078 1099.000000\n1079 999.000000\n1080 999.000000\n1081 999.000000\n1082 999.000000\n1083 999.000000\n1084 1499.000000\n1085 1199.000000\n1086 1199.000000\n1087 899.000000\n1088 1299.000000\n1089 1599.000000\n1090 1199.000000\n1091 1599.000000\n1092 1399.000000\n1093 1299.000000\n1094 999.000000\n1095 1399.000000\n1096 799.000000\n1097 1049.000000\n1098 999.000000\n1099 999.000000\n1100 1599.000000\n1101 999.000000\n1102 999.000000\n1103 1299.000000\n1104 1049.000000\n1105 999.000000\n1106 1049.000000\n1107 1099.000000\n1108 1399.000000\n1109 999.000000\n1110 999.000000\n1111 1199.000000\n1112 1299.000000\n1113 1199.000000\n1114 1299.000000\n1115 999.000000\n1116 1299.000000\n1117 999.000000\n1118 999.000000\n1119 1199.000000\n1120 1299.000000\n1121 1099.000000\n1122 1199.000000\n1123 1199.000000\n1124 1299.000000\n1125 999.000000\n1126 1299.000000\n1127 1499.000000\n1128 999.000000\n1129 1399.000000\n1130 1099.000000\n1131 999.000000\n1132 1299.000000\n1133 999.000000\n1134 1199.000000\n1135 999.000000\n1136 1199.000000\n1137 1499.000000\n1138 1299.000000\n1139 1099.000000\n1140 549.500000\n1141 34.333333\n1142 1599.000000\n1143 999.000000\n1144 999.000000\n1145 1199.000000\n1146 1199.000000\n1147 999.000000\n1148 1199.000000\n1149 1099.000000\n1150 1199.000000\n1151 1599.000000\n1152 1099.000000\n1153 1099.000000\n1154 1699.000000\n1155 1099.000000\n1156 1132.333333\n1157 1299.000000\n1158 1599.000000\n1159 1149.000000\n1160 1299.000000\n1161 999.000000\n1162 1199.000000\n1163 1299.000000\n1164 1599.000000\n1165 1099.000000\n1166 1099.000000\n1167 1499.000000\n1168 999.000000\n1169 1299.000000\n1170 1099.000000\n1171 1299.000000\n1172 1599.000000\n1173 999.000000\n1174 599.000000\n1175 999.000000\n1176 1399.000000\n1177 1199.000000\n1178 1299.000000\n1179 1099.000000\n1180 1099.000000\n1181 999.000000\n1182 999.000000\n1183 1299.000000\n1184 999.000000\n1185 1099.000000\n1186 1099.000000\n1187 1199.000000\n1188 1599.000000\n1189 1199.000000\n1190 1299.000000\n1191 1099.000000\n1192 1099.000000\n1193 998.000000\n1194 1499.000000\n1195 999.000000\n1196 1199.000000\n1197 51.000000\n1198 1099.000000\n1199 1299.000000\n1200 1099.000000\n1201 19.750000\n1202 1099.000000\n1203 1099.000000\n1204 999.000000\n1205 1349.000000\n1206 1599.000000\n1207 1099.000000\n1208 1099.000000\n1209 1099.000000\n1210 999.000000\n1211 1199.000000\n1212 1299.000000\n1213 1599.000000\n1214 999.000000\n1215 1299.000000\n1216 999.000000\n1217 1599.000000\n1218 1099.000000\n1219 1199.000000\n1220 999.000000\n1221 1099.000000\n1222 999.000000\n1223 999.000000\n1224 1099.000000\n1225 1099.000000\n1226 1099.000000\n1227 999.000000\n1228 999.000000\n1229 1299.000000\n1230 1299.000000\n1231 1099.000000\n1232 1199.000000\n1233 1099.000000\n1234 399.000000\n1235 1599.000000\n1236 999.000000\n1237 1299.000000\n1238 999.000000\n1239 1299.000000\n1240 1299.000000\n1241 999.000000\n1242 1399.000000\n1243 1099.000000\n1244 999.000000\n1245 999.000000\n1246 1199.000000\n1247 999.000000\n1248 1399.000000\n1249 1265.666667\n1250 999.000000\n1251 1199.000000\n1252 1299.000000\n1253 1099.000000\n1254 1499.000000\n1255 999.000000\n1256 1299.000000\n1257 999.000000\n1258 1099.000000\n1259 1599.000000\n1260 999.000000\n1261 1399.000000\n1262 699.000000\n1263 999.000000\n1264 1399.000000\n1265 1099.000000\n1266 1699.000000\n1267 999.000000\n1268 1099.000000\n1269 1199.000000\n1270 999.000000\n1271 999.000000\n1272 1099.000000\n1273 999.000000\n1274 1599.000000\n1275 999.000000\n1276 999.000000\n1277 1199.000000\n1278 999.000000\n1279 1399.000000\n1280 1579.000000\n1281 1349.000000\n1282 1099.000000\n1283 1099.000000\n1284 1099.000000\n1285 999.000000\n1286 1599.000000\n1287 1699.000000\n1288 999.000000\n1289 1199.000000\n1290 1399.000000\n1291 1099.000000\n1292 1099.000000\n1293 1599.000000\n1294 1199.000000\n1295 1099.000000\n1296 999.000000\n1297 1199.000000\n1298 1299.000000\n1299 999.000000\n1300 1199.000000\n1301 1599.000000\n1302 1099.000000\n1303 999.000000\n1304 1699.000000\n1305 999.000000\n1306 1099.000000\n1307 1599.000000\n1308 999.000000\n1309 999.000000\n1310 999.000000\n1311 999.000000\n1312 1099.000000\n1313 1099.000000\n1314 999.000000\n1315 1199.000000\n1316 999.000000\n1317 1299.000000\n1318 1599.000000\n1319 999.000000\n1320 1599.000000\n1321 1099.000000\n1322 1199.000000\n1323 1299.000000\n1324 1299.000000\n1325 1199.000000\n1326 1199.000000\n1327 1199.000000\n1328 1299.000000\n1329 1599.000000\n1330 1299.000000\n1331 1399.000000\n1332 1299.000000\n1333 1299.000000\n1334 1299.000000\n1335 1099.000000\n1336 1199.000000\n1337 1099.000000\n1338 1799.000000\n1339 999.000000\n1340 999.000000\n1341 1599.000000\n1342 1299.000000\n1343 1799.000000\n1344 1399.000000\n1345 1599.000000\n1346 499.000000\n1347 1099.000000\n1348 1399.000000\n1349 1599.000000\n1350 1099.000000\n1351 999.000000\n1352 999.000000\n1353 1499.000000\n1354 2698.000000\n1355 1299.000000\n1356 1099.000000\n1357 999.000000\n1358 1199.000000\n1359 999.000000\n1360 1199.000000\n1361 1199.000000\n1362 1199.000000\n1363 999.000000\n1364 1299.000000\n1365 1099.000000\n1366 999.000000\n1367 1699.000000\n1368 1499.000000\n1369 1099.000000\n1370 999.000000\n1371 899.000000\n1372 1099.000000\n1373 999.000000\n1374 999.000000\n1375 999.000000\n1376 999.000000\n1377 1199.000000\n1378 599.000000\n1379 1199.000000\n1380 1099.000000\n1381 1649.000000\n1382 1599.000000\n1383 699.000000\n1384 1099.000000\n1385 999.000000\n1386 1349.000000\n1387 1099.000000\n1388 1599.000000\n1389 999.000000\n1390 1299.000000\n1391 1399.000000\n1392 1399.000000\n1393 1199.000000\n1394 974.642553\n1395 1099.000000\n1396 1299.000000\n1397 499.500000\n1398 999.000000\n1399 999.000000\n1400 1299.000000\n1401 999.000000\n1402 999.000000\n1403 1299.000000\n1404 1199.000000\n1405 1599.000000\n1406 1299.000000\n1407 1099.000000\n1408 1199.000000\n1409 1799.000000\n1410 1199.000000\n1411 1399.000000\n1412 1599.000000\n1413 1299.000000\n1414 899.000000\n1415 1.500000\n1416 999.000000\n1417 1099.000000\n1418 1299.000000\n1419 999.000000\n1420 999.000000\n1421 799.000000\n1422 999.000000\n1423 1099.000000\n1424 999.000000\n1425 999.000000\n1426 999.000000\n1427 2099.000000\n1428 1399.000000\n1429 1199.000000\n1430 1299.000000\n1431 1199.000000\n1432 999.000000\n1433 999.000000\n1434 1099.000000\n1435 1099.000000\n1436 1099.000000\n1437 1099.000000\n1438 1099.000000\n1439 1199.000000\n1440 1399.000000\n1441 999.000000\n1442 1099.000000\n1443 999.000000\n1444 1249.000000\n1445 1099.000000\n1446 1599.000000\n1447 1599.000000\n1448 1299.000000\n1449 1199.000000\n1450 1399.000000\n1451 1099.000000\n1452 399.000000\n1453 999.000000\n1454 1099.000000\n1455 999.000000\n1456 999.000000\n1457 965.666667\n1458 1099.000000\n1459 1299.000000\n1460 999.000000\n1461 999.000000\n1462 999.000000\n1463 999.000000\n1464 1299.000000\n1465 1399.000000\n1466 999.000000\n1467 1099.000000\n1468 999.000000\n1469 999.000000\n1470 1299.000000\n1471 1299.000000\n1472 999.000000\n1473 999.000000\n1474 999.000000\n1475 999.000000\n1476 1099.000000\n1477 1199.000000\n1478 1399.000000\n1479 1199.000000\n1480 1449.000000\n1481 1599.000000\n1482 1299.000000\n1483 1099.000000\n1484 999.000000\n1485 1099.000000\n1486 1199.000000\n1487 1099.000000\n1488 999.000000\n1489 2498.000000\n1490 999.000000\n1491 1499.000000\n1492 999.000000\n1493 1099.000000\n1494 1399.000000\n1495 1199.000000\n1496 1199.000000\n1497 1199.000000\n1498 999.000000\n1499 1199.000000\n1500 999.000000\n1501 1199.000000\n1502 1299.000000\n1503 1599.000000\n1504 1599.000000\n1505 599.000000\n1506 1299.000000\n1507 1299.000000\n1508 1599.000000\n1509 1099.000000\n1510 1049.000000\n1511 999.000000\n1512 999.000000\n1513 1199.000000\n1514 999.000000\n1515 1199.000000\n1516 1599.000000\n1517 1099.000000\n1518 999.000000\n1519 1199.000000\n1520 1099.000000\n1521 999.000000\n1522 1199.000000\n1523 599.000000\n1524 1299.000000\n1525 1099.000000\n1526 999.000000\n1527 999.000000\n1528 1699.000000\n1529 749.000000\n1530 899.000000\n1531 399.000000\n1532 999.000000\n1533 1199.000000\n1534 1099.000000\n1535 1099.000000\n1536 1499.000000\n1537 1399.000000\n1538 1099.000000\n1539 1049.000000\n1540 1599.000000\n1541 1199.000000\n1542 1699.000000\n1543 1199.000000\n1544 1299.000000\n1545 1599.000000\n1546 1499.000000\n1547 999.000000\n1548 1754.333333\n1549 1499.000000\n1550 999.000000\n1551 1099.000000\n1552 1299.000000\n1553 999.000000\n1554 999.000000\n1555 1599.000000\n1556 999.000000\n1557 999.000000\n1558 1299.000000\n1559 1599.000000\n1560 999.000000\n1561 1199.000000\n1562 1099.000000\n1563 999.000000\n1564 1099.000000\n1565 1199.000000\n1566 1399.000000\n1567 1399.000000\n1568 1099.000000\n1569 1199.000000\n1570 999.000000\n1571 1399.000000\n1572 999.000000\n1573 999.000000\n1574 999.000000\n1575 1199.000000\n1576 1199.000000\n1577 999.000000\n1578 1149.000000\n1579 1599.000000\n1580 999.000000\n1581 1099.000000\n1582 999.000000\n1583 1299.000000\n1584 1099.000000\n1585 1399.000000\n1586 1699.000000\n1587 999.000000\n1588 1299.000000\n1589 1299.000000\n1590 1399.000000\n1591 1099.000000\n1592 999.000000\n1593 1199.000000\n1594 1099.000000\n1595 1199.000000\n1596 1399.000000\n1597 1099.000000\n1598 1599.000000\n1599 1199.000000\n1600 1399.000000\n1601 1499.000000\n1602 1399.000000\n1603 1099.000000\n1604 999.000000\n1605 1299.000000\n1606 1299.000000\n1607 999.000000\n1608 1199.000000\n1609 999.000000\n1610 1099.000000\n1611 1099.000000\n1612 1699.000000\n1613 999.000000\n1614 999.000000\n1615 999.000000\n1616 1599.000000\n1617 1299.000000\n1618 1099.000000\n1619 1049.000000\n1620 1299.000000\n1621 1599.000000\n1622 999.000000\n1623 999.000000\n1624 1199.000000\n1625 1399.000000\n1626 1299.000000\n1627 1599.000000\n1628 1199.000000\n1629 1399.000000\n1630 1.000000\n1631 599.000000\n1632 999.000000\n1633 1049.000000\n1634 1599.000000\n1635 999.000000\n1636 1599.000000\n1637 1099.000000\n1638 1099.000000\n1639 1599.000000\n1640 1599.000000\n1641 999.000000\n1642 1299.000000\n1643 1299.000000\n1644 1199.000000\n1645 1199.000000\n1646 1099.000000\n1647 1099.000000\n1648 999.000000\n1649 1099.000000\n1650 1299.000000\n1651 899.000000\n1652 1199.000000\n1653 1299.000000\n1654 1499.000000\n1655 999.000000\n1656 1199.000000\n1657 999.000000\n1658 1199.000000\n1659 1049.000000\n1660 1099.000000\n1661 1299.000000\n1662 999.000000\n1663 1.000000\n1664 999.000000\n1665 599.000000\n1666 1199.000000\n1667 1199.000000\n1668 1199.000000\n1669 999.000000\n1670 1799.000000\n1671 1299.000000\n1672 999.000000\n1673 999.000000\n1674 999.000000\n1675 499.000000\n1676 999.000000\n1677 1299.000000\n1678 1199.000000\n1679 999.000000\n1680 999.000000\n1681 1999.000000\n1682 1099.000000\n1683 999.000000\n1684 1099.000000\n1685 1999.000000\n1686 1099.000000\n1687 999.000000\n1688 1299.000000\n1689 1099.000000\n1690 999.000000\n1691 1199.000000\n1692 1699.000000\n1693 999.000000\n1694 1599.000000\n1695 1099.000000\n1696 1299.000000\n1697 999.000000\n1698 1499.000000\n1699 1099.000000\n1700 1199.000000\n1701 1099.000000\n1702 1599.000000\n1703 999.000000\n1704 1199.000000\n1705 999.000000\n1706 1599.000000\n1707 1099.000000\n1708 1149.000000\n1709 999.000000\n1710 1299.000000\n1711 1099.000000\n1712 699.000000\n1713 999.000000\n1714 1199.000000\n1715 999.000000\n1716 1299.000000\n1717 999.000000\n1718 1499.000000\n1719 999.000000\n1720 1149.000000\n1721 1199.000000\n1722 1299.000000\n1723 1049.000000\n1724 1299.000000\n1725 1665.666667\n1726 999.000000\n1727 1099.000000\n1728 999.000000\n1729 1199.000000\n1730 1099.000000\n1731 1299.000000\n1732 999.000000\n1733 1199.000000\n1734 999.000000\n1735 1399.000000\n1736 1799.000000\n1737 1332.333333\n1738 999.000000\n1739 1299.000000\n1740 999.000000\n1741 1099.000000\n1742 999.000000\n1743 1149.000000\n1744 999.000000\n1745 899.000000\n1746 1299.000000\n1747 1299.000000\n1748 1299.000000\n1749 1199.000000\n1750 1099.000000\n1751 1199.000000\n1752 1599.000000\n1753 1199.000000\n1754 1199.000000\n1755 999.000000\n1756 1399.000000\n1757 1099.000000\n1758 1299.000000\n1759 1399.000000\n1760 1099.000000\n1761 1499.000000\n1762 1199.000000\n1763 1199.000000\n1764 1399.000000\n1765 1299.000000\n1766 999.000000\n1767 999.000000\n1768 999.000000\n1769 1099.000000\n1770 1099.000000\n1771 1099.000000\n1772 1599.000000\n1773 1199.000000\n1774 999.000000\n1775 1299.000000\n1776 1165.666667\n1777 1599.000000\n1778 999.000000\n1779 999.000000\n1780 1299.000000\n1781 1199.000000\n1782 1299.000000\n1783 3697.000000\n1784 1199.000000\n1785 1099.000000\n1786 499.000000\n1787 1499.000000\n1788 1099.000000\n1789 1199.000000\n1790 1099.000000\n1791 1099.000000\n1792 1399.000000\n1793 999.000000\n1794 1299.000000\n1795 1199.000000\n1796 999.000000\n1797 1099.000000\n1798 999.000000\n1799 1299.000000\n1800 499.000000\n1801 1599.000000\n1802 1099.000000\n1803 999.000000\n1804 1299.000000\n1805 1299.000000\n1806 1599.000000\n1807 499.000000\n1808 999.000000\n1809 1199.000000\n1810 1299.000000\n1811 1199.000000\n1812 1399.000000\n1813 999.000000\n1814 999.000000\n1815 1399.000000\n1816 1099.000000\n1817 1099.000000\n1818 1299.000000\n1819 1299.000000\n1820 1499.000000\n1821 1199.000000\n1822 1299.000000\n1823 999.000000\n1824 1199.000000\n1825 1299.000000\n1826 1199.000000\n1827 1099.000000\n1828 1299.000000\n1829 1099.000000\n1830 999.000000\n1831 1599.000000\n1832 1099.000000\n1833 1299.000000\n1834 899.000000\n1835 999.000000\n1836 999.000000\n1837 999.000000\n1838 499.000000\n1839 1099.000000\n1840 999.000000\n1841 999.000000\n1842 1299.000000\n1843 1099.000000\n1844 1199.000000\n1845 999.000000\n1846 1599.000000\n1847 1099.000000\n1848 999.000000\n1849 1049.000000\n1850 999.000000\n1851 1299.000000\n1852 999.000000\n1853 1065.666667\n1854 1299.000000\n1855 1099.000000\n1856 1099.000000\n1857 1299.000000\n1858 1099.000000\n1859 1199.000000\n1860 1049.000000\n1861 999.000000\n1862 1299.000000\n1863 999.000000\n1864 999.000000\n1865 999.000000\n1866 1199.000000\n1867 1299.000000\n1868 1199.000000\n1869 1299.000000\n1870 999.000000\n1871 1299.000000\n1872 1199.000000\n1873 1299.000000\n1874 1399.000000\n1875 1499.000000\n1876 999.000000\n1877 1199.000000\n1878 2498.000000\n1879 1599.000000\n1880 1299.000000\n1881 1099.000000\n1882 1399.000000\n1883 1399.000000\n1884 399.000000\n1885 1249.000000\n1886 499.000000\n1887 1299.000000\n1888 999.000000\n1889 1099.000000\n1890 1099.000000\n1891 1099.000000\n1892 1199.000000\n1893 1299.000000\n1894 1049.000000\n1895 1599.000000\n1896 999.000000\n1897 1499.000000\n1898 1299.000000\n1899 999.000000\n1900 999.000000\n1901 1399.000000\n1902 1365.666667\n1903 999.000000\n1904 1099.000000\n1905 1199.000000\n1906 999.000000\n1907 399.000000\n1908 1099.000000\n1909 1299.000000\n1910 999.000000\n1911 999.000000\n1912 1199.000000\n1913 499.000000\n1914 1299.000000\n1915 1099.000000\n1916 999.000000\n1917 999.000000\n1918 1699.000000\n1919 1099.000000\n1920 1099.000000\n1921 1099.000000\n1922 1199.000000\n1923 999.000000\n1924 1499.000000\n1925 1249.000000\n1926 999.000000\n1927 1299.000000\n1928 999.000000\n1929 1299.000000\n1930 499.000000\n1931 1199.000000\n1932 1099.000000\n1933 1299.000000\n1934 499.000000\n1935 1465.611078\n1936 1599.000000\n1937 999.000000\n1938 999.000000\n1939 999.000000\n1940 999.000000\n1941 1599.000000\n1942 1199.000000\n1943 999.000000\n1944 999.000000\n1945 999.000000\n1946 1199.000000\n1947 1199.000000\n1948 1049.000000\n1949 1399.000000\n1950 999.000000\n1951 999.000000\n1952 1399.000000\n1953 1299.000000\n1954 1099.000000\n1955 1099.000000\n1956 1599.000000\n1957 999.000000\n1958 1299.000000\n1959 1099.000000\n1960 999.000000\n1961 1099.000000\n1962 2498.000000\n1963 1699.000000\n1964 999.000000\n1965 1599.000000\n1966 999.000000\n1967 1199.000000\n1968 999.000000\n1969 1299.000000\n1970 999.000000\n1971 1199.000000\n1972 1299.000000\n1973 999.000000\n1974 1199.000000\n1975 1199.000000\n1976 1699.000000\n1977 1599.000000\n1978 1599.000000\n1979 999.000000\n1980 999.000000\n1981 1499.000000\n1982 1099.000000\n1983 999.000000\n1984 1049.000000\n1985 999.000000\n1986 1199.000000\n1987 1699.000000\n1988 1599.000000\n1989 1299.000000\n1990 1799.000000\n1991 1099.000000\n1992 1099.000000\n1993 1699.000000\n1994 1099.000000\n1995 1099.000000\n1996 1299.000000\n1997 1199.000000\n1998 999.000000\n1999 999.000000\n2000 1099.000000\n2001 1299.000000\n2002 1299.000000\n2003 999.000000\n2004 999.000000\n2005 1499.000000\n2006 1199.000000\n2007 999.000000\n2008 1099.000000\n2009 999.000000\n2010 1599.000000\n2011 1499.000000\n2012 1099.000000\n2013 1099.000000\n2014 999.000000\n2015 1599.000000\n2016 999.000000\n2017 1149.000000\n2018 1699.000000\n2019 699.000000\n2020 1299.000000\n2021 1099.000000\n2022 1099.000000\n2023 999.000000\n2024 1399.000000\n2025 1099.000000\n2026 1299.000000\n2027 1599.000000\n2028 999.000000\n2029 999.000000\n2030 1099.000000\n2031 1099.000000\n2032 1599.000000\n2033 1599.000000\n2034 499.000000\n2035 1099.000000\n2036 1299.000000\n2037 1599.000000\n2038 999.000000\n2039 1099.000000\n2040 1299.000000\n2041 999.000000\n2042 1299.000000\n2043 1099.000000\n2044 1399.000000\n2045 999.000000\n2046 999.000000\n2047 1199.000000\n2048 1099.000000\n2049 1049.000000\n2050 999.000000\n2051 1099.000000\n2052 499.000000\n2053 1099.000000\n2054 999.000000\n2055 999.000000\n2056 999.000000\n2057 1299.000000\n2058 1399.000000\n2059 1099.000000\n2060 1249.000000\n2061 999.000000\n2062 1049.000000\n2063 1299.000000\n2064 1249.000000\n2065 1999.000000\n2066 1299.000000\n2067 1699.000000\n2068 1299.000000\n2069 999.000000\n2070 1299.000000\n2071 999.000000\n2072 499.000000\n2073 1299.000000\n2074 999.000000\n2075 1199.000000\n2076 1199.000000\n2077 999.000000\n2078 999.000000\n2079 1399.000000\n2080 1299.000000\n2081 1039.000000\n2082 999.000000\n2083 999.000000\n2084 999.000000\n2085 1099.000000\n2086 1099.000000\n2087 1199.000000\n2088 999.000000\n2089 999.000000\n2090 1199.000000\n2091 1299.000000\n2092 1099.000000\n2093 1199.000000\n2094 999.000000\n2095 1099.000000\n2096 1249.000000\n2097 1299.000000\n2098 1099.000000\n2099 1499.000000\n2100 1199.000000\n2101 1099.000000\n2102 1599.000000\n2103 1299.000000\n2104 999.000000\n2105 1099.000000\n2106 1099.000000\n2107 499.000000\n2108 999.000000\n2109 1299.000000\n2110 999.000000\n2111 1299.000000\n2112 1299.000000\n2113 999.000000\n2114 999.000000\n2115 1199.000000\n2116 999.000000\n2117 999.000000\n2118 1017.181818\n2119 1599.000000\n2120 1099.000000\n2121 1599.000000\n2122 699.000000\n2123 999.000000\n2124 1299.000000\n2125 1099.000000\n2126 1299.000000\n2127 1599.000000\n2128 999.000000\n2129 1099.000000\n2130 1599.000000\n2131 1299.000000\n2132 1599.000000\n2133 1099.000000\n2134 1099.000000\n2135 1699.000000\n2136 999.000000\n2137 1099.000000\n2138 999.000000\n2139 1099.000000\n2140 1299.000000\n2141 1299.000000\n2142 1399.000000\n2143 1199.000000\n2144 1199.000000\n2145 1999.000000\n2146 1099.000000\n2147 1699.000000\n2148 1299.000000\n2149 1099.000000\n2150 999.000000\n2151 1099.000000\n2152 1699.000000\n2153 1099.000000\n2154 999.000000\n2155 999.000000\n2156 999.000000\n2157 1099.000000\n2158 1299.000000\n2159 1099.000000\n2160 999.000000\n2161 1099.000000\n2162 999.000000\n2163 325.500000\n2164 999.000000\n2165 1099.000000\n2166 1599.000000\n2167 1299.000000\n2168 1299.000000\n2169 1399.000000\n2170 999.000000\n2171 1399.000000\n2172 1199.000000\n2173 1399.000000\n2174 1099.000000\n2175 999.000000\n2176 1599.000000\n2177 1599.000000\n2178 1699.000000\n2179 1299.000000\n2180 1299.000000\n2181 1299.000000\n2182 1099.000000\n2183 101.000000\n2184 1099.000000\n2185 1499.000000\n2186 1299.000000\n2187 1399.000000\n2188 1199.000000\n2189 1099.000000\n2190 1199.000000\n2191 999.000000\n2192 1299.000000\n2193 999.000000\n2194 1199.000000\n2195 1399.000000\n2196 999.000000\n2197 999.000000\n2198 999.000000\n2199 1299.000000\n2200 999.000000\n2201 1099.000000\n2202 1099.000000\n2203 1299.000000\n2204 1499.000000\n2205 1299.000000\n2206 1099.000000\n2207 1399.000000\n2208 1599.000000\n2209 999.000000\n2210 1299.000000\n2211 1199.000000\n2212 1099.000000\n2213 1199.000000\n2214 1.500000\n2215 1199.000000\n2216 999.000000\n2217 1299.000000\n2218 1199.000000\n2219 1099.000000\n2220 1299.000000\n2221 1149.000000\n2222 1099.000000\n2223 499.000000\n2224 1099.000000\n2225 1199.000000\n2226 1299.000000\n2227 1299.000000\n2228 1199.000000\n2229 1099.000000\n2230 1599.000000\n2231 1599.000000\n2232 1199.000000\n2233 1099.000000\n2234 1299.000000\n2235 999.000000\n2236 1299.000000\n2237 1499.000000\n2238 999.000000\n2239 1099.000000\n2240 1049.000000\n2241 1049.000000\n2242 1099.000000\n2243 999.000000\n2244 1999.000000\n2245 999.000000\n2246 1299.000000\n2247 1399.000000\n2248 999.000000\n2249 999.000000\n2250 1099.000000\n2251 999.000000\n2252 1099.000000\n2253 1399.000000\n2254 1199.000000\n2255 999.000000\n2256 999.000000\n2257 1299.000000\n2258 999.000000\n2259 1099.000000\n2260 1099.000000\n2261 999.000000\n2262 1699.000000\n2263 1099.000000\n2264 1099.000000\n2265 1099.000000\n2266 999.000000\n2267 1399.000000\n2268 1199.000000\n2269 1599.000000\n2270 999.000000\n2271 1299.000000\n2272 1199.000000\n2273 1099.000000\n2274 1799.000000\n2275 1099.000000\n2276 999.000000\n2277 1399.000000\n2278 999.000000\n2279 999.000000\n2280 999.000000\n2281 1199.000000\n2282 1199.000000\n2283 999.000000\n2284 1099.000000\n2285 1299.000000\n2286 999.000000\n2287 1599.000000\n2288 1299.000000\n2289 1099.000000\n2290 1199.000000\n2291 1099.000000\n2292 999.000000\n2293 999.000000\n2294 1299.000000\n2295 1099.000000\n2296 1199.000000\n2297 999.000000\n2298 999.000000\n2299 1399.000000\n2300 1099.000000\n2301 1399.000000\n2302 1199.000000\n2303 1199.000000\n2304 999.000000\n2305 999.000000\n2306 1099.000000\n2307 1099.000000\n2308 1199.000000\n2309 999.000000\n2310 1299.000000\n2311 1399.000000\n2312 1099.000000\n2313 999.000000\n2314 1099.000000\n2315 999.000000\n2316 1299.000000\n2317 1399.000000\n2318 1599.000000\n2319 1199.000000\n2320 1099.000000\n2321 1599.000000\n2322 1199.000000\n2323 1049.000000\n2324 1499.000000\n2325 999.000000\n2326 999.000000\n2327 999.000000\n2328 999.000000\n2329 999.000000\n2330 1099.000000\n2331 899.000000\n2332 1299.000000\n2333 999.000000\n2334 1699.000000\n2335 1099.000000\n2336 999.000000\n2337 1099.000000\n2338 1599.000000\n2339 999.000000\n2340 1099.000000\n2341 999.000000\n2342 1099.000000\n2343 1199.000000\n2344 1099.000000\n2345 999.000000\n2346 499.500000\n2347 999.000000\n2348 1099.000000\n2349 999.000000\n2350 1299.000000\n2351 1099.000000\n2352 1399.000000\n2353 1099.000000\n2354 1199.000000\n2355 1099.000000\n2356 499.500000\n2357 1099.000000\n2358 1299.000000\n2359 999.000000\n2360 1299.000000\n2361 199.500000\n2362 999.000000\n2363 1099.000000\n2364 1399.000000\n2365 1099.000000\n2366 1299.000000\n2367 1399.000000\n2368 1224.000000\n2369 1299.000000\n2370 1084.714286\n2371 1299.000000\n2372 1599.000000\n2373 1099.000000\n2374 999.000000\n2375 1199.000000\n2376 1199.000000\n2377 1299.000000\n2378 999.000000\n2379 999.000000\n2380 1499.000000\n2381 1199.000000\n2382 1099.000000\n2383 1099.000000\n2384 1599.000000\n2385 1099.000000\n2386 1798.000000\n2387 999.000000\n2388 499.500000\n2389 1099.000000\n2390 1099.000000\n2391 1299.000000\n2392 1249.000000\n2393 1049.000000\n2394 999.000000\n2395 999.000000\n2396 999.000000\n2397 1099.000000\n2398 699.000000\n2399 1199.000000\n2400 1199.000000\n2401 1499.000000\n2402 1299.000000\n2403 1499.000000\n2404 1499.000000\n2405 1199.000000\n2406 1299.000000\n2407 1099.000000\n2408 1299.000000\n2409 1299.000000\n2410 999.000000\n2411 1299.000000\n2412 1099.000000\n2413 999.000000\n2414 1199.000000\n2415 1199.000000\n2416 999.000000\n2417 1599.000000\n2418 999.000000\n2419 1299.000000\n2420 399.000000\n2421 1199.000000\n2422 999.000000\n2423 999.000000\n2424 1799.000000\n2425 1299.000000\n2426 999.000000\n2427 1249.000000\n2428 1699.000000\n2429 999.000000\n2430 999.000000\n2431 999.000000\n2432 999.000000\n2433 999.000000\n2434 1199.000000\n2435 999.000000\n2436 1299.000000\n2437 999.000000\n2438 1099.000000\n2439 1199.000000\n2440 1399.000000\n2441 1499.000000\n2442 1299.000000\n2443 1199.000000\n2444 999.000000\n2445 999.000000\n2446 1199.000000\n2447 1799.000000\n2448 1199.000000\n2449 999.000000\n2450 999.000000\n2451 1299.000000\n2452 1249.000000\n2453 1199.000000\n2454 1199.000000\n2455 1199.000000\n2456 899.000000\n2457 1199.000000\n2458 899.000000\n2459 1199.000000\n2460 999.000000\n2461 999.000000\n2462 1199.000000\n2463 999.000000\n2464 1165.666667\n2465 999.000000\n2466 1299.000000\n2467 899.000000\n2468 1299.000000\n2469 1049.000000\n2470 1099.000000\n2471 1199.000000\n2472 999.000000\n2473 1299.000000\n2474 999.000000\n2475 1049.000000\n2476 1249.000000\n2477 1599.000000\n2478 1599.000000\n2479 1099.000000\n2480 999.000000\n2481 999.000000\n2482 1099.000000\n2483 1099.000000\n2484 1199.000000\n2485 1199.000000\n2486 999.000000\n2487 1199.000000\n2488 1499.000000\n2489 1199.000000\n2490 1599.000000\n2491 1099.000000\n2492 999.000000\n2493 999.000000\n2494 1199.000000\n2495 1299.000000\n2496 1299.000000\n2497 1099.000000\n2498 1299.000000\n2499 1299.000000\n2500 1699.000000\n2501 1299.000000\n2502 999.000000\n2503 1199.000000\n2504 1399.000000\n2505 1199.000000\n2506 1099.000000\n2507 1099.000000\n2508 1299.000000\n2509 999.000000\n2510 999.000000\n2511 1299.000000\n2512 999.000000\n2513 999.000000\n2514 1199.000000\n2515 999.000000\n2516 1799.000000\n2517 999.000000\n2518 999.000000\n2519 1099.000000\n2520 1299.000000\n2521 1199.000000\n2522 1099.000000\n2523 1299.000000\n2524 999.000000\n2525 2099.000000\n2526 999.000000\n2527 999.000000\n2528 1399.000000\n2529 999.000000\n2530 1199.000000\n2531 999.000000\n2532 1299.000000\n2533 1299.000000\n2534 1299.000000\n2535 1099.000000\n2536 999.000000\n2537 1299.000000\n2538 1399.000000\n2539 499.000000\n2540 699.000000\n2541 1299.000000\n2542 999.000000\n2543 999.000000\n2544 1299.000000\n2545 1199.000000\n2546 1199.000000\n2547 1199.000000\n2548 1299.000000\n2549 1299.000000\n2550 1099.000000\n2551 999.000000\n2552 1499.000000\n2553 1299.000000\n2554 999.000000\n2555 1299.000000\n2556 1299.000000\n2557 1299.000000\n2558 1599.000000\n2559 1349.000000\n2560 1199.000000\n2561 1299.000000\n2562 999.000000\n2563 1649.000000\n2564 1099.000000\n2565 599.000000\n2566 1199.000000\n2567 999.000000\n2568 1099.000000\n2569 1099.000000\n2570 999.000000\n2571 1199.000000\n2572 999.000000\n2573 999.000000\n2574 51.000000\n2575 999.000000\n2576 999.000000","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"What is the average lifetime value of a customer as of 2024?","role":"user"},{"content":"SELECT ROUND(AVG(customer_lifetime_value), 2) AS avg_lifetime_value FROM (SELECT customer_id, SUM(net_sales_before_tax) AS customer_lifetime_value FROM order_values WHERE order_year <= 2024 GROUP BY customer_id) AS customer_lifetime_values;","role":"assistant"}]} {"question":"sales trend for last 6 months","ground_truth_query":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_gtu":"Success","execution_result_gtu":" order_date net_sales\n0 2024-02 5072.924089\n1 2024-03 247978.480489\n2 2024-04 501612.648951\n3 2024-05 461034.379542\n4 2024-06 373828.700250\n5 2024-07 434127.200322","llama_sqlcoder_3_few_promp":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_llama":"Success","execution_result_llama":" order_date net_sales\n0 2024-02 5072.924089\n1 2024-03 247978.480489\n2 2024-04 501612.648951\n3 2024-05 461034.379542\n4 2024-06 373828.700250\n5 2024-07 434127.200322","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"sales trend for last 6 months","role":"user"},{"content":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month;","role":"assistant"}]} {"question":"Identify the top 5 products with the highest return rates in the last quarter.","ground_truth_query":"WITH last_completed_quarter AS ( SELECT CASE WHEN order_quarter = 1 THEN order_year - 1 ELSE order_year END AS last_quarter_year, CASE WHEN order_quarter = 1 THEN 4 ELSE order_quarter - 1 END AS last_quarter FROM order_values GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC LIMIT 1 ), product_returns AS ( SELECT product_id, SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) AS total_returns, COUNT(*) AS total_orders FROM order_values o JOIN last_completed_quarter lq ON o.order_year = lq.last_quarter_year AND o.order_quarter = lq.last_quarter GROUP BY product_id ) SELECT p.product_id, ROUND((CAST(p.total_returns AS DOUBLE) \/ NULLIF(p.total_orders, 0)) * 100, 2) AS return_rate FROM product_returns p ORDER BY return_rate DESC LIMIT 5;","execution_status_gtu":"Success","execution_result_gtu":" product_id return_rate\n0 None 75.00\n1 7.288135647401E12 50.00\n2 8.055713136884E12 50.00\n3 8.4990711237E12 46.51\n4 7.988748615924E12 42.86","llama_sqlcoder_3_few_promp":"SELECT product_id, product_title, COUNT(order_refund_line_item_id) AS return_count, ROUND(COUNT(order_refund_line_item_id) * 100.0 \/ COUNT(order_line_item_id), 2) AS return_rate FROM order_values WHERE order_quarter = 4 AND order_year = YEAR(CURRENT_DATE) GROUP BY product_id, product_title ORDER BY return_count DESC LIMIT 5;","execution_status_llama":"Success","execution_result_llama":"Empty DataFrame\nColumns: [product_id, product_title, return_count, return_rate]\nIndex: []","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Identify the top 5 products with the highest return rates in the last quarter.","role":"user"},{"content":"WITH last_completed_quarter AS ( SELECT CASE WHEN order_quarter = 1 THEN order_year - 1 ELSE order_year END AS last_quarter_year, CASE WHEN order_quarter = 1 THEN 4 ELSE order_quarter - 1 END AS last_quarter FROM order_values GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC LIMIT 1 ), product_returns AS ( SELECT product_id, SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) AS total_returns, COUNT(*) AS total_orders FROM order_values o JOIN last_completed_quarter lq ON o.order_year = lq.last_quarter_year AND o.order_quarter = lq.last_quarter GROUP BY product_id ) SELECT p.product_id, ROUND((CAST(p.total_returns AS DOUBLE) \/ NULLIF(p.total_orders, 0)) * 100, 2) AS return_rate FROM product_returns p ORDER BY return_rate DESC LIMIT 5;","role":"assistant"}]} {"question":"Lowest selling SKUs on Amazon vs. Shopify","ground_truth_query":"SELECT sku_code, product_title, source, SUM(net_sales_before_tax) AS total_net_sales FROM order_values WHERE LOWER(source) IN ('amazon', 'shopify') AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) GROUP BY sku_code, product_title, source ORDER BY total_net_sales ASC;","execution_status_gtu":"Success","execution_result_gtu":" sku_code product_title source total_net_sales\n0 None Test Product shopify -174.000000\n1 None Wings X Fire Wireless Gaming in Ear Earbuds,TWS Headphones with RGB Lights case, 40ms Low Latency, Bluetooth 5.3, 40 Hours Playtime, ENC, 8mm Speaker Size (Black TWS) amazon -0.003906\n2 None Thunder shopify 244.444445\n3 None Wings Crosshair 100 Wired Optical Gaming Mouse\u00a0\u00a0(USB 3.0, Black), one size amazon 338.144089\n4 None Phantom 550 Orangutan shopify 700.000000\n5 None phantom-110 shopify 703.000000\n6 None Phantom 260 - Black shopify 719.000000\n7 None Upbeat 201 shopify 759.491520\n8 None Wings Upbeat 101 Bluetooth Speaker with TWS Bluetooth 5.1 Pairing, RGB Lights, Powerful 5W Output and 20 Hours of Playtime, Flexible Audio Input with Shoulder Strap amazon 891.846877\n9 None Phantom - Black shopify 899.000000\n10 None Phantom 205 shopify 899.000000\n11 None Wings Phantom Pro Earphones Gaming Earbuds with LED Battery Indicator, 50ms Low Latency, Bluetooth 5.3, 40 Hours Playtime, MEMs Mic, IPX4 Resist, 12mm Driver, 500mah case, Headphones, (Black TWS) amazon 931.366348\n12 None Wings Thunderbar 310 Mini Soundbar with Powerful 14 W Sound Output, Dual Passive radiators Bluetooth Wireless soundbar, Wireless soundbar with Bluetooth 5.1, Soundbars for TV, PC, Mobile amazon 1100.850000\n13 None Wings Phantom 550, Gaming TWS Earbuds, with 45 Hours Playtime, Bluetooth 5.3, Environmental Noise Cancellation, Touch Controls Headphones amazon 1100.850000\n14 None META shopify 1293.444445\n15 None Phantom Pro Orangutan shopify 1299.000000\n16 None Phantom GODLIKE shopify 1299.000000\n17 None Red shopify 1406.000000\n18 None Platinum - Blue shopify 1439.200000\n19 None Centerstage 200 shopify 1499.000000\n20 None Wings Phantom 380 Best Low Latency 30Hrs Earbuds, ANC Bluetooth Wireless Headphones, Ergonomic Case with LED Lights, 50 Hours Playtime, Quad ENC Mic, TWS Headset with Touch Controls. amazon 1524.582197\n21 None Phantom Orangutan shopify 1993.444445\n22 None Wings Crosshair 100 Gaming Mouse with Adjustable 3200 DPI | Ergonomic Gaming Design with Multicolour LED Lights | 6 Buttons Functionality | Gold Plated USB with Braided Cable amazon 2028.844089\n23 None META - Black shopify 2118.200000\n24 None Wings Phantom 200 Gaming TWS Earbuds with LED Battery Indicator, 40ms Low Latency, Bluetooth 5.2, 30 Hours Playtime, DNS Mic with Noise Reduction, IPX5, 13mm Driver Headphones (Orange) amazon 2369.479746\n25 None Vader 200 shopify 2498.000000\n26 None Flobuds 300 - Black shopify 2697.000000\n27 None Crosshair 205 shopify 2796.000000\n28 None Crosshair 200 shopify 2995.000000\n29 None Phantom 200 shopify 2998.000000\n30 None Wings Phantom 860 Wireless Earphones with 50 Hours of Battery Backup with Low Latency 40 ms, Gaming Designed case, LED Lights, Sync App Support, Bluetooth 5.3 TWS Gaming Airpods amazon 3047.429746\n31 None PRIME shopify 3145.000000\n32 None Wings Crosshair 205 Wired Optical Gaming Mouse\u00a0\u00a0(USB 3.0, Black), one Size amazon 3383.040000\n33 None Sling 100 shopify 3497.000000\n34 None Hypercharge shopify 3693.100000\n35 None Phantom Pro GODLIKE shopify 3897.000000\n36 None META - Gray shopify 3996.000000\n37 None Phantom 500 GODLIKE shopify 4397.000000\n38 None Wings Crosshair 205 Gaming Mouse with Adjustable 6400 DPI | Ergonomic Gaming Design with Multicolour LED Lights | 8 Buttons Functionality with Dedicated Software | Gold Plated USB with Braided Cable amazon 4651.680000\n39 None Phantom 210 shopify 4842.000000\n40 None Phantom 260 shopify 5041.444445\n41 None Wings Crosshair 100 Wired Optical Gaming Mouse\u00a0\u00a0(USB 3.0, Black), one Size amazon 5072.920580\n42 None Phantom 760 shopify 5290.444445\n43 None Crosshair 100 shopify 5439.000000\n44 None Phantom 700 shopify 6115.100000\n45 None Platinum shopify 6342.000000\n46 None Wings Centrestage 400 Soundbar with TWS Bluetooth 5.0 Pairing, Powerful 16W Output with 2500 mAh Battery and 5 Hours of Playback, Quad Mode. amazon 6351.699512\n47 None Bassdrops 101 shopify 6440.444445\n48 None Phantom 105 shopify 7140.444445\n49 None Prime shopify 7217.100000\n50 None Urbana shopify 7240.444445\n51 None Phantom - White shopify 7550.000000\n52 None Wings Vader 100, with 40mm Drivers, 3D Surround Sound, adjustible mic Wired Gaming On Ear Headset (Red, On The Ear) amazon 8125.442197\n53 None Wings Crosshair 100 Wired Optical Gaming Mouse\u00ef\u00bf\u00bd\u00ef\u00bf\u00bd(USB 3.0, Black), one Size amazon 8457.587701\n54 None Wings Crosshair 200 Wired Optical Gaming Mouse (USB 3.0, Black), one Size (WL-CROSSHAIR200-BLK) amazon 8629.712024\n55 None UpBeat 101 shopify 9717.444505\n56 None Phantom 250 shopify 9897.100000\n57 None Phantom 110 shopify 10083.000000\n58 None Meta shopify 10180.000000\n59 None X-Fire shopify 11187.444445\n60 None Center Stage 400 shopify 11242.960000\n61 None Phantom 800 shopify 11693.000000\n62 None Flobuds 300 - White shopify 12383.000000\n63 None Phantom 860 shopify 14990.000000\n64 None Power Bolt shopify 16535.400000\n65 None Phantom 500 shopify 20131.744445\n66 None Center Stage 120 shopify 22057.100030\n67 None Phantom 430 shopify 26532.200000\n68 None PowerPods shopify 27031.644445\n69 None Wings Phantom 320 Gaming in Ear Earbuds Earbuds with Bluetooth 5.3, Best Gaming Earphones with Gaming Mode 40ms Latency, Earpods Sync App Support, New Earbuds with Gaming Inspired Design amazon 32171.244404\n70 None Flobuds 335 shopify 34658.766525\n71 None Center Stage 210 shopify 42314.100000\n72 None Vader 350 shopify 55343.200000\n73 None Phantom 1000 shopify 58529.500030\n74 None Hypebuds 230 shopify 71141.300060\n75 None Phantom 315 shopify 74489.444445\n76 None Wings Vader 350 Gaming Headphone with 50 mm Drivers, Extra Soft Earmuffs, Ergonomic Gaming Headset Adjustable in-Game Mic Low Latency Gaming Mode and Bluetooth 5.2 amazon 88080.065723\n77 None Phantom 850 shopify 88670.300000\n78 None Phantom shopify 92910.000111\n79 None Flobuds 400 shopify 100353.120785\n80 None Phantom 550 shopify 100727.744465\n81 None Phantom Pro shopify 121247.944445\n82 None Flobuds 300 shopify 228849.871036\n83 None Hypebuds 225 shopify 509672.100141","llama_sqlcoder_3_few_promp":"SELECT ov.sku_id, SUM(ov.gross_sales_price_before_tax) AS total_sales, ROW_NUMBER() OVER (ORDER BY SUM(ov.gross_sales_price_before_tax) ASC) AS rank FROM order_values ov WHERE LOWER(ov.source) IN ('amazon','shopify') GROUP BY ov.sku_id ORDER BY rank ASC LIMIT 5;","execution_status_llama":"Success","execution_result_llama":" sku_id total_sales rank\n0 shopify_8499071123700_45009262477556 46.00000 1\n1 amazon_B08MFGCJK2 592.38000 2\n2 shopify_6624955400361_39505033035945 846.61017 3\n3 amazon_B0C6QXK2QP 1100.85000 4\n4 shopify_8394950050036_44683315183860 1299.00000 5","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Lowest selling SKUs on Amazon vs. Shopify","role":"user"},{"content":"SELECT sku_code, product_title, source, SUM(net_sales_before_tax) AS total_net_sales FROM order_values WHERE LOWER(source) IN ('amazon', 'shopify') AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) GROUP BY sku_code, product_title, source ORDER BY total_net_sales ASC;","role":"assistant"}]} {"question":"How many orders has my top customer placed?","ground_truth_query":"SELECT customer_id, COUNT(DISTINCT order_id) AS order_count FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY customer_id ORDER BY order_count DESC LIMIT 1;","execution_status_gtu":"Success","execution_result_gtu":" customer_id order_count\n0 None 158","llama_sqlcoder_3_few_promp":"SELECT COUNT(*) AS order_count FROM order_values WHERE customer_id = (SELECT customer_id FROM order_values ORDER BY total_returns_before_tax DESC LIMIT 1);","execution_status_llama":"Success","execution_result_llama":" order_count\n0 1","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"How many orders has my top customer placed?","role":"user"},{"content":"SELECT customer_id, COUNT(DISTINCT order_id) AS order_count FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY customer_id ORDER BY order_count DESC LIMIT 1;","role":"assistant"}]} {"question":"Which product categories have the highest growth potential based on current trends?","ground_truth_query":"WITH category_sales AS (SELECT product_category, SUM(net_sales_before_tax) AS total_net_sales FROM order_values WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY product_category), category_growth AS (SELECT product_category, total_net_sales, LAG(total_net_sales) OVER (ORDER BY total_net_sales DESC) AS previous_net_sales FROM category_sales) SELECT product_category, ROUND((total_net_sales - COALESCE(previous_net_sales, 0)) \/ NULLIF(COALESCE(previous_net_sales, 1), 0) * 100, 2) AS growth_percentage FROM category_growth ORDER BY growth_percentage DESC;","execution_status_gtu":"Success","execution_result_gtu":" product_category growth_percentage\n0 None 1.205838e+08\n1 Gaming Mouse -2.250000e+00\n2 Gaming Headphones -1.465000e+01\n3 NeckBand -2.151000e+01\n4 True Wireless -3.832000e+01\n5 Speaker -6.533000e+01\n6 True WireLess -6.652000e+01\n7 Neckband -8.014000e+01","llama_sqlcoder_3_few_promp":"SELECT o.product_category, SUM(o.net_sales_before_tax) AS total_sales, SUM(o.net_sales_before_tax) \/ NULLIF(SUM(o.net_sales_before_tax) - LAG(SUM(o.net_sales_before_tax), 1) OVER (ORDER BY o.product_category), 0) AS growth_rate FROM order_values o WHERE o.order_month = 4 AND o.order_year = 2024 GROUP BY o.product_category ORDER BY growth_rate DESC NULLS LAST LIMIT 5;","execution_status_llama":"Success","execution_result_llama":" product_category total_sales growth_rate\n0 NeckBand 15088.000000 1.465281\n1 Speaker 29661.748889 1.260071\n2 True WireLess 205194.111113 1.168982\n3 Gaming Headphones 22981.000000 -0.202586\n4 Gaming Mouse 4791.000000 -0.263386","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Which product categories have the highest growth potential based on current trends?","role":"user"},{"content":"WITH category_sales AS (SELECT product_category, SUM(net_sales_before_tax) AS total_net_sales FROM order_values WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY product_category), category_growth AS (SELECT product_category, total_net_sales, LAG(total_net_sales) OVER (ORDER BY total_net_sales DESC) AS previous_net_sales FROM category_sales) SELECT product_category, ROUND((total_net_sales - COALESCE(previous_net_sales, 0)) \/ NULLIF(COALESCE(previous_net_sales, 1), 0) * 100, 2) AS growth_percentage FROM category_growth ORDER BY growth_percentage DESC;","role":"assistant"}]} {"question":"Compare the return rates for orders placed on weekdays vs. weekends.","ground_truth_query":"WITH weekday_orders AS ( SELECT SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) AS total_returns, COUNT(*) AS total_orders FROM order_values WHERE order_day_of_week BETWEEN 1 AND 5 AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) ), weekend_orders AS ( SELECT SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) AS total_returns, COUNT(*) AS total_orders FROM order_values WHERE order_day_of_week IN (6, 7) AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) ) SELECT 'Weekday' AS order_type, ROUND((CAST(w.total_returns AS FLOAT) * 100 \/ w.total_orders), 2) AS return_rate FROM weekday_orders w UNION ALL SELECT 'Weekend' AS order_type, ROUND((CAST(we.total_returns AS FLOAT) * 100 \/ we.total_orders), 2) AS return_rate FROM weekend_orders we;","execution_status_gtu":"Success","execution_result_gtu":" order_type return_rate\n0 Weekday 9.90\n1 Weekend 10.08","llama_sqlcoder_3_few_promp":"SELECT CASE WHEN EXTRACT(dow FROM order_date_time) BETWEEN 1 AND 5 THEN 'Weekdays' ELSE 'Weekends' END AS day_of_week, COUNT(*) AS number_of_orders, SUM(COALESCE(total_returns_before_tax, 0)) \/ NULLIF(COUNT(*), 0) AS average_return_rate FROM order_values GROUP BY CASE WHEN EXTRACT(dow FROM order_date_time) BETWEEN 1 AND 5 THEN 'Weekdays' ELSE 'Weekends' END ORDER BY day_of_week;","execution_status_llama":"Success","execution_result_llama":" day_of_week number_of_orders average_return_rate\n0 Weekdays 22863 354.821217\n1 Weekends 11079 340.515994","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Compare the return rates for orders placed on weekdays vs. weekends.","role":"user"},{"content":"WITH weekday_orders AS ( SELECT SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) AS total_returns, COUNT(*) AS total_orders FROM order_values WHERE order_day_of_week BETWEEN 1 AND 5 AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) ), weekend_orders AS ( SELECT SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) AS total_returns, COUNT(*) AS total_orders FROM order_values WHERE order_day_of_week IN (6, 7) AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) ) SELECT 'Weekday' AS order_type, ROUND((CAST(w.total_returns AS FLOAT) * 100 \/ w.total_orders), 2) AS return_rate FROM weekday_orders w UNION ALL SELECT 'Weekend' AS order_type, ROUND((CAST(we.total_returns AS FLOAT) * 100 \/ we.total_orders), 2) AS return_rate FROM weekend_orders we;","role":"assistant"}]} {"question":"orders by state for April?","ground_truth_query":"SELECT LOWER(billing_address_state) AS state, COUNT(DISTINCT order_id) AS order_count FROM order_values WHERE order_month = 4 AND order_year = YEAR(CURRENT_DATE) AND billing_address_state IS NOT NULL GROUP BY LOWER(billing_address_state) ORDER BY order_count DESC;","execution_status_gtu":"Success","execution_result_gtu":" state order_count\n0 uttar pradesh 122\n1 maharashtra 86\n2 delhi 55\n3 west bengal 52\n4 haryana 37\n5 gujarat 37\n6 karnataka 34\n7 bihar 33\n8 punjab 31\n9 madhya pradesh 29\n10 odisha 28\n11 uttarakhand 26\n12 tamil nadu 25\n13 rajasthan 25\n14 telangana 22\n15 andhra pradesh 19\n16 chhattisgarh 16\n17 jharkhand 15\n18 assam 13\n19 kerala 13\n20 jammu and kashmir 11\n21 chandigarh 5\n22 himachal pradesh 4\n23 arunachal pradesh 4\n24 tripura 3\n25 goa 1\n26 dadra and nagar haveli and daman and diu 1\n27 nagaland 1\n28 jammu & kashmir 1\n29 sikkim 1\n30 mizoram 1","llama_sqlcoder_3_few_promp":"SELECT LOWER(billing_address_state) AS state, SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales FROM order_values WHERE order_month = 4 AND order_year = 2024 AND billing_address_state IS NOT NULL GROUP BY LOWER(billing_address_state) ORDER BY total_sales DESC NULLS LAST LIMIT 10;","execution_status_llama":"Success","execution_result_llama":" state total_sales\n0 maharashtra 69838.950170\n1 uttar pradesh 58411.346440\n2 delhi 33085.160000\n3 gujarat 30296.237300\n4 karnataka 30038.491520\n5 west bengal 29471.705746\n6 madhya pradesh 22526.000000\n7 punjab 22523.080000\n8 telangana 22329.237300\n9 rajasthan 17999.254210","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"orders by state for April?","role":"user"},{"content":"SELECT LOWER(billing_address_state) AS state, COUNT(DISTINCT order_id) AS order_count FROM order_values WHERE order_month = 4 AND order_year = YEAR(CURRENT_DATE) AND billing_address_state IS NOT NULL GROUP BY LOWER(billing_address_state) ORDER BY order_count DESC;","role":"assistant"}]} {"question":"What was the AOV for last month?","ground_truth_query":"SELECT ROUND(AVG(total_net_sales), 2) AS avg_order_value FROM (SELECT order_id, SUM(net_sales_before_tax) AS total_net_sales FROM order_values WHERE refund_status = 'false' AND cancellation_status = 'false' AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -1)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_id) AS order_totals;","execution_status_gtu":"Success","execution_result_gtu":" avg_order_value\n0 919.75","llama_sqlcoder_3_few_promp":"SELECT AVG(COALESCE(net_sales_before_tax, 0)) AS average_order_value FROM order_values WHERE order_month = MONTH(CURRENT_DATE) - 1 AND order_year = YEAR(CURRENT_DATE) - 1;","execution_status_llama":"Success","execution_result_llama":" average_order_value\n0 326.558073","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"What was the AOV for last month?","role":"user"},{"content":"SELECT ROUND(AVG(total_net_sales), 2) AS avg_order_value FROM (SELECT order_id, SUM(net_sales_before_tax) AS total_net_sales FROM order_values WHERE refund_status = 'false' AND cancellation_status = 'false' AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -1)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_id) AS order_totals;","role":"assistant"}]} {"question":"Net revenue by state for last month","ground_truth_query":"SELECT LOWER(billing_address_state) AS state, SUM(COALESCE(net_sales_before_tax, 0)) AS net_revenue FROM order_values WHERE order_year = YEAR(DATE_ADD(CURRENT_DATE(), -DAY(CURRENT_DATE()))) AND order_month = MONTH(DATE_ADD(CURRENT_DATE(), -DAY(CURRENT_DATE()))) AND billing_address_state IS NOT NULL GROUP BY LOWER(billing_address_state) ORDER BY net_revenue DESC;","execution_status_gtu":"Success","execution_result_gtu":" state net_revenue\n0 maharashtra 63193.000020\n1 uttar pradesh 46607.900061\n2 telangana 35768.900020\n3 delhi 29221.800000\n4 west bengal 25450.800000\n5 bihar 24285.500031\n6 gujarat 24109.900020\n7 punjab 23855.400020\n8 rajasthan 23513.900020\n9 tamil nadu 20239.700000\n10 andhra pradesh 19965.600040\n11 haryana 17166.700000\n12 madhya pradesh 15392.400020\n13 karnataka 14713.900051\n14 odisha 9673.200000\n15 assam 6985.300000\n16 jharkhand 6905.200000\n17 jammu and kashmir 6624.100000\n18 meghalaya 5845.000000\n19 kerala 5346.000000\n20 uttarakhand 4178.000000\n21 chhattisgarh 2498.000000\n22 goa 999.000000\n23 daman & diu 998.000000\n24 himachal pradesh 890.000020\n25 andaman and nicobar islands -300.000000","llama_sqlcoder_3_few_promp":"SELECT LOWER(billing_address_state) AS state, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE order_month = MONTH(CURRENT_DATE) - 1 AND order_year = YEAR(CURRENT_DATE) GROUP BY LOWER(billing_address_state) ORDER BY net_sales DESC NULLS LAST;","execution_status_llama":"Success","execution_result_llama":" state net_sales\n0 maharashtra 63193.000020\n1 uttar pradesh 46607.900061\n2 telangana 35768.900020\n3 delhi 29221.800000\n4 west bengal 25450.800000\n5 bihar 24285.500031\n6 gujarat 24109.900020\n7 punjab 23855.400020\n8 rajasthan 23513.900020\n9 tamil nadu 20239.700000\n10 andhra pradesh 19965.600040\n11 haryana 17166.700000\n12 madhya pradesh 15392.400020\n13 karnataka 14713.900051\n14 odisha 9673.200000\n15 assam 6985.300000\n16 jharkhand 6905.200000\n17 jammu and kashmir 6624.100000\n18 meghalaya 5845.000000\n19 kerala 5346.000000\n20 uttarakhand 4178.000000\n21 chhattisgarh 2498.000000\n22 goa 999.000000\n23 daman & diu 998.000000\n24 himachal pradesh 890.000020\n25 andaman and nicobar islands -300.000000","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Net revenue by state for last month","role":"user"},{"content":"SELECT LOWER(billing_address_state) AS state, SUM(COALESCE(net_sales_before_tax, 0)) AS net_revenue FROM order_values WHERE order_year = YEAR(DATE_ADD(CURRENT_DATE(), -DAY(CURRENT_DATE()))) AND order_month = MONTH(DATE_ADD(CURRENT_DATE(), -DAY(CURRENT_DATE()))) AND billing_address_state IS NOT NULL GROUP BY LOWER(billing_address_state) ORDER BY net_revenue DESC;","role":"assistant"}]} {"question":"Show the monthly trend of new customer acquisition for the last year.","ground_truth_query":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, COUNT(DISTINCT customer_id) AS new_customers FROM order_values WHERE order_date >= DATE_TRUNC('year', DATE_SUB(CURRENT_DATE, 365)) AND order_date < DATE_TRUNC('year', CURRENT_DATE) AND order_date = DATE(first_ordered_at) GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_gtu":"Success","execution_result_gtu":" order_date new_customers\n0 2023-01 1628\n1 2023-10 52\n2 2023-11 6\n3 2023-12 1\n4 2023-02 2068\n5 2023-03 1599\n6 2023-04 258\n7 2023-05 99\n8 2023-06 396\n9 2023-07 195\n10 2023-08 44\n11 2023-09 10","llama_sqlcoder_3_few_promp":"SELECT date_trunc('month', o.order_date_time) AS MONTH, COUNT(DISTINCT o.customer_id) AS new_customers FROM order_values o WHERE o.order_status = 'fulfilled' AND o.order_year = EXTRACT(YEAR FROM CURRENT_DATE) - 1 GROUP BY date_trunc('month', o.order_date_time) ORDER BY date_trunc('month', o.order_date_time);","execution_status_llama":"Success","execution_result_llama":" MONTH new_customers\n0 2023-01-01 1530\n1 2023-02-01 2055\n2 2023-03-01 1595\n3 2023-04-01 267\n4 2023-05-01 100\n5 2023-06-01 397\n6 2023-07-01 206\n7 2023-08-01 47\n8 2023-09-01 10\n9 2023-10-01 52\n10 2023-11-01 6\n11 2023-12-01 1","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Show the monthly trend of new customer acquisition for the last year.","role":"user"},{"content":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, COUNT(DISTINCT customer_id) AS new_customers FROM order_values WHERE order_date >= DATE_TRUNC('year', DATE_SUB(CURRENT_DATE, 365)) AND order_date < DATE_TRUNC('year', CURRENT_DATE) AND order_date = DATE(first_ordered_at) GROUP BY order_year, order_month ORDER BY order_year, order_month;","role":"assistant"}]} {"question":"How many customers used a discount code in April 2024?","ground_truth_query":"SELECT COUNT(DISTINCT customer_id) AS customers_with_discount_code FROM order_values WHERE order_month = 4 AND order_year = 2024 AND total_discount_after_tax > 0;","execution_status_gtu":"Success","execution_result_gtu":" customers_with_discount_code\n0 376","llama_sqlcoder_3_few_promp":"SELECT COUNT(DISTINCT customer_id) AS customer_count FROM order_values WHERE order_month = 4 AND order_year = 2024 AND total_discount_before_tax > 0;","execution_status_llama":"Success","execution_result_llama":" customer_count\n0 376","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"How many customers used a discount code in April 2024?","role":"user"},{"content":"SELECT COUNT(DISTINCT customer_id) AS customers_with_discount_code FROM order_values WHERE order_month = 4 AND order_year = 2024 AND total_discount_after_tax > 0;","role":"assistant"}]} {"question":"What is the average order frequency per customer in the last 6 months?","ground_truth_query":"WITH customer_orders AS (SELECT customer_id, COUNT(DISTINCT order_id) AS order_count FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) GROUP BY customer_id) SELECT ROUND(AVG(order_count), 2) AS avg_order_frequency FROM customer_orders;","execution_status_gtu":"Success","execution_result_gtu":" avg_order_frequency\n0 1.24","llama_sqlcoder_3_few_promp":"SELECT customer_id, COUNT(order_id) AS order_count FROM order_values WHERE order_date >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '6 months') AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY customer_id ORDER BY order_count DESC NULLS LAST;","execution_status_llama":"Success","execution_result_llama":null,"messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"What is the average order frequency per customer in the last 6 months?","role":"user"},{"content":"WITH customer_orders AS (SELECT customer_id, COUNT(DISTINCT order_id) AS order_count FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) GROUP BY customer_id) SELECT ROUND(AVG(order_count), 2) AS avg_order_frequency FROM customer_orders;","role":"assistant"}]} {"question":"What is the quarterly trend of orders for the last 4 quarters?","ground_truth_query":"SELECT CONCAT(order_year, '-Q', order_quarter) AS year_quarter, COUNT(DISTINCT order_id) AS total_orders FROM order_values WHERE (order_year, order_quarter) IN (SELECT order_year, order_quarter FROM order_values GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC LIMIT 4) GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC;","execution_status_gtu":"Success","execution_result_gtu":" year_quarter total_orders\n0 2024-Q3 791\n1 2024-Q2 1971\n2 2024-Q1 441\n3 2023-Q4 112","llama_sqlcoder_3_few_promp":"SELECT CONCAT(order_year, '-Q', order_quarter) AS year_quarter, COUNT(order_line_item_id) AS total_orders FROM order_values WHERE order_year = YEAR(CURRENT_DATE) - 1 AND order_quarter IN (1, 2, 3, 4) GROUP BY year_quarter ORDER BY year_quarter;","execution_status_llama":"Success","execution_result_llama":" year_quarter total_orders\n0 2023-Q1 6785\n1 2023-Q2 1323\n2 2023-Q3 378\n3 2023-Q4 112","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"What is the quarterly trend of orders for the last 4 quarters?","role":"user"},{"content":"SELECT CONCAT(order_year, '-Q', order_quarter) AS year_quarter, COUNT(DISTINCT order_id) AS total_orders FROM order_values WHERE (order_year, order_quarter) IN (SELECT order_year, order_quarter FROM order_values GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC LIMIT 4) GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC;","role":"assistant"}]} {"question":"Trend of average order value AOV for first time customers for the last 6 months","ground_truth_query":"WITH first_orders AS (SELECT customer_id, MIN(order_date) AS first_order_date FROM order_values GROUP BY customer_id), first_time_orders AS (SELECT o.order_id, o.order_date, SUM(o.net_sales_before_tax) AS total_net_sales_before_tax FROM order_values o JOIN first_orders f ON o.customer_id = f.customer_id AND o.order_date = f.first_order_date WHERE refund_status = 'false' AND cancellation_status = 'false' GROUP BY o.order_id, o.order_date) SELECT CONCAT(YEAR(order_date), '-', LPAD(MONTH(order_date), 2, '0')) AS order_month, ROUND(AVG(total_net_sales_before_tax), 2) AS avg_order_value FROM first_time_orders WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY YEAR(order_date), MONTH(order_date) ORDER BY YEAR(order_date), MONTH(order_date);","execution_status_gtu":"Success","execution_result_gtu":" order_month avg_order_value\n0 2024-02 390.22\n1 2024-03 867.14\n2 2024-04 718.75\n3 2024-05 732.37\n4 2024-06 789.39\n5 2024-07 901.81","llama_sqlcoder_3_few_promp":"SELECT DATE_TRUNC('month', order_date_time) AS MONTH, AVG(net_sales_before_tax) AS average_order_value FROM order_values WHERE first_ordered_at >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '6 months') AND first_ordered_at < DATE_TRUNC('month', CURRENT_DATE) AND order_status = 'fulfilled' AND customer_id NOT IN (SELECT customer_id FROM order_values WHERE first_ordered_at < DATE_TRUNC('month', CURRENT_DATE - INTERVAL '6 months')) GROUP BY MONTH ORDER BY MONTH;","execution_status_llama":"Success","execution_result_llama":" MONTH average_order_value\n0 2024-02-01 338.194939\n1 2024-03-01 759.890692\n2 2024-04-01 699.430634\n3 2024-05-01 708.851964\n4 2024-06-01 769.344176\n5 2024-07-01 880.931788\n6 2024-08-01 947.017857","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Trend of average order value AOV for first time customers for the last 6 months","role":"user"},{"content":"WITH first_orders AS (SELECT customer_id, MIN(order_date) AS first_order_date FROM order_values GROUP BY customer_id), first_time_orders AS (SELECT o.order_id, o.order_date, SUM(o.net_sales_before_tax) AS total_net_sales_before_tax FROM order_values o JOIN first_orders f ON o.customer_id = f.customer_id AND o.order_date = f.first_order_date WHERE refund_status = 'false' AND cancellation_status = 'false' GROUP BY o.order_id, o.order_date) SELECT CONCAT(YEAR(order_date), '-', LPAD(MONTH(order_date), 2, '0')) AS order_month, ROUND(AVG(total_net_sales_before_tax), 2) AS avg_order_value FROM first_time_orders WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY YEAR(order_date), MONTH(order_date) ORDER BY YEAR(order_date), MONTH(order_date);","role":"assistant"}]} {"question":"average Order Value AOV trend for shopify and amazon in the last 3 months","ground_truth_query":"WITH order_totals AS (SELECT order_id, source, SUM(net_sales_before_tax) AS total_net_sales_before_tax, order_year, order_month FROM order_values WHERE refund_status = 'false' AND cancellation_status = 'false' AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -3)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_id, source, order_year, order_month) SELECT source, CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, ROUND(AVG(total_net_sales_before_tax), 2) AS avg_net_sales_aov FROM order_totals WHERE source IN ('amazon', 'shopify') GROUP BY source, order_year, order_month ORDER BY source, order_year, order_month;","execution_status_gtu":"Success","execution_result_gtu":" source order_date avg_net_sales_aov\n0 amazon 2024-05 1270.34\n1 shopify 2024-05 727.80\n2 shopify 2024-06 801.15\n3 shopify 2024-07 919.75","llama_sqlcoder_3_few_promp":"SELECT LOWER(sku_id) AS vendor, AVG(COALESCE(gross_sales_price_before_tax, 0)) AS average_gross_sales_price FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -3)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY LOWER(sku_id) ORDER BY average_gross_sales_price DESC NULLS LAST;","execution_status_llama":"Success","execution_result_llama":" vendor average_gross_sales_price\n0 shopify_6624935903401_39504934797481 1999.000000\n1 shopify_7580801106164_42483248464116 1799.000000\n2 shopify_8395920376052_44689179148532 1699.000000\n3 shopify_8395920376052_44689179508980 1699.000000\n4 shopify_7939005743348_43533952090356 1681.900000\n5 shopify_8032335757556_43735529914612 1599.000000\n6 shopify_8033034567924_43745206730996 1499.000000\n7 shopify_8010739122420_43695802581236 1499.000000\n8 shopify_7840902873332_43269814255860 1499.000000\n9 shopify_7995642642676_43653845319924 1499.000000\n10 shopify_7551234113780_42401469464820 1499.000000\n11 shopify_8399385821428_44704832684276 1499.000000\n12 shopify_8395528929524_44686639235316 1487.040000\n13 shopify_7938983395572_43533925548276 1486.500000\n14 shopify_7988793901300_43631382790388 1399.000000\n15 shopify_7988748615924_43631325544692 1399.000000\n16 shopify_8034015248628_43748307796212 1395.666667\n17 shopify_8394950050036_44683315151092 1350.200000\n18 shopify_8505350586612_45022986993908 1316.320000\n19 shopify_7840902873332_43269814223092 1304.000000\n20 shopify_8468011811060_44931928031476 1299.000000\n21 shopify_8395534467316_44686685765876 1299.000000\n22 shopify_7288135647401_41579331879081 1299.000000\n23 shopify_8055713136884_43819207557364 1299.000000\n24 shopify_7493164892404_42204994502900 1299.000000\n25 shopify_7853101744372_43301283791092 1299.000000\n26 shopify_8399435661556_44875332124916 1299.000000\n27 shopify_8395534467316_44686685798644 1299.000000\n28 shopify_7853101744372_43301279760628 1299.000000\n29 shopify_7600463053044_42546831524084 1299.000000\n30 shopify_8395534467316_44686684717300 1299.000000\n31 shopify_8394950050036_44683315183860 1299.000000\n32 shopify_6624938033321_39504943972521 1212.220588\n33 shopify_8504654364916_45020311945460 1210.777996\n34 shopify_7786470670580_43112417722612 1199.000000\n35 shopify_7786470670580_43112417689844 1199.000000\n36 shopify_8040065695988_43776876085492 1199.000000\n37 shopify_6624938033321_44686603911412 1149.195122\n38 shopify_7207167492265_44733150888180 1099.000000\n39 shopify_7207167492265_44733150920948 1099.000000\n40 shopify_8394950050036_44683315216628 1059.000000\n41 shopify_7952689791220_43570982453492 1010.111111\n42 shopify_8399200846068_44704447987956 999.000000\n43 shopify_8395054973172_44683899928820 999.000000\n44 shopify_7901938319604_43435490541812 999.000000\n45 shopify_8395054973172_44683900682484 999.000000\n46 shopify_8399200846068_44704448020724 999.000000\n47 shopify_8047426371828_43800745509108 999.000000\n48 shopify_8465375297780_44922068762868 999.000000\n49 shopify_8047426371828_43800756420852 999.000000\n50 shopify_7901938319604_43435485888756 999.000000\n51 shopify_8399227158772_44704490062068 997.924731\n52 shopify_8399227158772_44704490094836 993.924370\n53 shopify_7952689791220_43570982519028 899.000000\n54 amazon_b0brhzkc9c 846.893333\n55 shopify_7633657037044_42655284527348 499.000000\n56 shopify_8499071123700_45009262477556 1.076923\n57 amazon_b0bsty8b8j 0.000000","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"average Order Value AOV trend for shopify and amazon in the last 3 months","role":"user"},{"content":"WITH order_totals AS (SELECT order_id, source, SUM(net_sales_before_tax) AS total_net_sales_before_tax, order_year, order_month FROM order_values WHERE refund_status = 'false' AND cancellation_status = 'false' AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -3)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_id, source, order_year, order_month) SELECT source, CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, ROUND(AVG(total_net_sales_before_tax), 2) AS avg_net_sales_aov FROM order_totals WHERE source IN ('amazon', 'shopify') GROUP BY source, order_year, order_month ORDER BY source, order_year, order_month;","role":"assistant"}]} {"question":"What are the top performing categories for Q1 2024?","ground_truth_query":"SELECT LOWER(product_category) AS category, SUM(COALESCE(net_sales_before_tax, 0)) AS total_net_sales FROM order_values WHERE order_year = 2024 AND order_quarter = 1 GROUP BY LOWER(product_category) ORDER BY total_net_sales DESC;","execution_status_gtu":"Success","execution_result_gtu":" category total_net_sales\n0 None 114653.955194\n1 true wireless 112427.000000\n2 gaming headphones 21487.000000\n3 gaming mouse 4493.000000\n4 speaker 4265.491520\n5 neckband 4097.000000","llama_sqlcoder_3_few_promp":"SELECT product_category, SUM(gross_profit) AS total_gross_profit FROM order_values WHERE order_year = 2024 AND order_quarter = 1 GROUP BY product_category ORDER BY total_gross_profit DESC LIMIT 5;","execution_status_llama":"Success","execution_result_llama":" product_category total_gross_profit\n0 None 114653.955194\n1 True WireLess 92076.000000\n2 Gaming Headphones 21487.000000\n3 True Wireless 20351.000000\n4 Gaming Mouse 4493.000000","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"What are the top performing categories for Q1 2024?","role":"user"},{"content":"SELECT LOWER(product_category) AS category, SUM(COALESCE(net_sales_before_tax, 0)) AS total_net_sales FROM order_values WHERE order_year = 2024 AND order_quarter = 1 GROUP BY LOWER(product_category) ORDER BY total_net_sales DESC;","role":"assistant"}]} {"question":"Compare the return rates for each product category in the last year.","ground_truth_query":"SELECT product_category, ROUND(SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) \/ COUNT(*) * 100.0) AS return_rate FROM order_values WHERE order_year = YEAR(DATE_SUB(CURRENT_DATE, 365)) GROUP BY product_category;","execution_status_gtu":"Success","execution_result_gtu":" product_category return_rate\n0 True WireLess 14.0\n1 NeckBand 10.0\n2 Speaker 12.0\n3 None 19.0\n4 Gaming Mouse 5.0\n5 Neckband 10.0\n6 Gaming Headphones 12.0\n7 Gaming Keyboard 14.0\n8 True Wireless 10.0","llama_sqlcoder_3_few_promp":"SELECT o.product_category, COUNT(DISTINCT CASE WHEN o.order_status = 'cancelled' THEN o.order_line_item_id END)::FLOAT \/ NULLIF(COUNT(DISTINCT o.order_line_item_id), 0) AS return_rate FROM order_values o WHERE o.order_year = YEAR(CURRENT_DATE - INTERVAL '1 year') GROUP BY o.product_category ORDER BY return_rate DESC NULLS LAST;","execution_status_llama":"Success","execution_result_llama":" product_category return_rate\n0 True WireLess 0.0\n1 NeckBand 0.0\n2 None 0.0\n3 Speaker 0.0\n4 Gaming Mouse 0.0\n5 Neckband 0.0\n6 Gaming Headphones 0.0\n7 Gaming Keyboard 0.0\n8 True Wireless 0.0","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Compare the return rates for each product category in the last year.","role":"user"},{"content":"SELECT product_category, ROUND(SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) \/ COUNT(*) * 100.0) AS return_rate FROM order_values WHERE order_year = YEAR(DATE_SUB(CURRENT_DATE, 365)) GROUP BY product_category;","role":"assistant"}]} {"question":"weekly breakdown of gross sales for the current year","ground_truth_query":"SELECT CONCAT(order_year, '-W', LPAD(order_week, 2, '0')) AS year_week,SUM(gross_sales_price_before_tax) AS total_gross_sales FROM order_values WHERE order_year = YEAR(CURRENT_DATE) GROUP BY order_year, order_week ORDER BY order_year, order_week;","execution_status_gtu":"Success","execution_result_gtu":" year_week total_gross_sales\n0 2024-W11 62111.30034\n1 2024-W12 148072.80374\n2 2024-W13 148825.68255\n3 2024-W14 181740.78289\n4 2024-W15 187737.00000\n5 2024-W16 229100.34000\n6 2024-W17 167247.00000\n7 2024-W18 253431.04000\n8 2024-W19 100108.00000\n9 2024-W20 200322.00000\n10 2024-W21 152722.40000\n11 2024-W22 165461.00000\n12 2024-W23 127690.00000\n13 2024-W24 104909.00000\n14 2024-W25 143074.00000\n15 2024-W26 180542.00000\n16 2024-W27 170950.00000\n17 2024-W28 150373.00000\n18 2024-W29 134483.00000\n19 2024-W03 4483.05000\n20 2024-W30 109160.00000\n21 2024-W31 105062.00000\n22 2024-W32 109203.00000\n23 2024-W33 89812.00000\n24 2024-W34 40308.00000\n25 2024-W04 4736.45000\n26 2024-W05 3889.84000\n27 2024-W06 1352.56000\n28 2024-W07 1352.56000\n29 2024-W08 0.00000\n30 2024-W09 676.28000","llama_sqlcoder_3_few_promp":"SELECT date_trunc('week', o.order_date_time) AS WEEK, SUM(COALESCE(o.gross_sales_price_before_tax, 0)) AS gross_sales FROM order_values o WHERE date_part('year', o.order_date_time) = date_part('year', CURRENT_DATE) GROUP BY date_trunc('week', o.order_date_time) ORDER BY date_trunc('week', o.order_date_time);","execution_status_llama":"Success","execution_result_llama":" WEEK gross_sales\n0 2024-01-15 4483.05000\n1 2024-01-22 4736.45000\n2 2024-01-29 3889.84000\n3 2024-02-05 1352.56000\n4 2024-02-12 1352.56000\n5 2024-02-19 0.00000\n6 2024-02-26 676.28000\n7 2024-03-11 62111.30034\n8 2024-03-18 148072.80374\n9 2024-03-25 148825.68255\n10 2024-04-01 181740.78289\n11 2024-04-08 187737.00000\n12 2024-04-15 229100.34000\n13 2024-04-22 167247.00000\n14 2024-04-29 253431.04000\n15 2024-05-06 100108.00000\n16 2024-05-13 200322.00000\n17 2024-05-20 152722.40000\n18 2024-05-27 165461.00000\n19 2024-06-03 127690.00000\n20 2024-06-10 104909.00000\n21 2024-06-17 143074.00000\n22 2024-06-24 180542.00000\n23 2024-07-01 170950.00000\n24 2024-07-08 150373.00000\n25 2024-07-15 134483.00000\n26 2024-07-22 109160.00000\n27 2024-07-29 105062.00000\n28 2024-08-05 109203.00000\n29 2024-08-12 89812.00000\n30 2024-08-19 40308.00000","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"weekly breakdown of gross sales for the current year","role":"user"},{"content":"SELECT CONCAT(order_year, '-W', LPAD(order_week, 2, '0')) AS year_week,SUM(gross_sales_price_before_tax) AS total_gross_sales FROM order_values WHERE order_year = YEAR(CURRENT_DATE) GROUP BY order_year, order_week ORDER BY order_year, order_week;","role":"assistant"}]} {"question":"States with the highest returning customer rate","ground_truth_query":"WITH customer_orders AS (SELECT customer_id, COUNT(DISTINCT order_id) AS order_count FROM order_values WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY customer_id), returning_customers AS (SELECT customer_id FROM customer_orders WHERE order_count > 1) SELECT LOWER(billing_address_state) AS state, COUNT(DISTINCT customer_id) AS returning_customer_count, ROUND((COUNT(DISTINCT customer_id) * 100 \/ (SELECT COUNT(DISTINCT customer_id) FROM order_values WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND billing_address_state IS NOT NULL)), 2) AS returning_customer_rate FROM order_values WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND customer_id IN (SELECT customer_id FROM returning_customers) AND billing_address_state IS NOT NULL GROUP BY LOWER(billing_address_state) ORDER BY returning_customer_rate DESC;","execution_status_gtu":"Success","execution_result_gtu":" state returning_customer_count returning_customer_rate\n0 uttar pradesh 49 1.96\n1 maharashtra 32 1.28\n2 delhi 27 1.08\n3 west bengal 24 0.96\n4 punjab 19 0.76\n5 haryana 17 0.68\n6 bihar 17 0.68\n7 madhya pradesh 15 0.60\n8 rajasthan 15 0.60\n9 telangana 14 0.56\n10 gujarat 12 0.48\n11 odisha 11 0.44\n12 andhra pradesh 11 0.44\n13 tamil nadu 10 0.40\n14 karnataka 6 0.24\n15 jharkhand 6 0.24\n16 jammu and kashmir 5 0.20\n17 kerala 5 0.20\n18 uttarakhand 5 0.20\n19 assam 3 0.12\n20 meghalaya 2 0.08\n21 chhattisgarh 2 0.08\n22 andaman and nicobar islands 2 0.08\n23 daman & diu 1 0.04\n24 himachal pradesh 1 0.04\n25 tripura 1 0.04","llama_sqlcoder_3_few_promp":"SELECT LOWER(billing_address_state) AS state, COUNT(DISTINCT customer_id) \/ NULLIF(COUNT(DISTINCT order_id), 0) AS returning_customer_rate FROM order_values GROUP BY LOWER(billing_address_state) ORDER BY returning_customer_rate DESC LIMIT 5;","execution_status_llama":"Success","execution_result_llama":" state returning_customer_rate\n0 daman and diu 1.0\n1 daman & diu 1.0\n2 dadra and nagar haveli and daman and diu 1.0\n3 wb 1.0\n4 ka 1.0","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"States with the highest returning customer rate","role":"user"},{"content":"WITH customer_orders AS (SELECT customer_id, COUNT(DISTINCT order_id) AS order_count FROM order_values WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY customer_id), returning_customers AS (SELECT customer_id FROM customer_orders WHERE order_count > 1) SELECT LOWER(billing_address_state) AS state, COUNT(DISTINCT customer_id) AS returning_customer_count, ROUND((COUNT(DISTINCT customer_id) * 100 \/ (SELECT COUNT(DISTINCT customer_id) FROM order_values WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND billing_address_state IS NOT NULL)), 2) AS returning_customer_rate FROM order_values WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND customer_id IN (SELECT customer_id FROM returning_customers) AND billing_address_state IS NOT NULL GROUP BY LOWER(billing_address_state) ORDER BY returning_customer_rate DESC;","role":"assistant"}]} {"question":"Show me the trend of sales by source for the last 6 months","ground_truth_query":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, source, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month, source ORDER BY order_year, order_month, source;","execution_status_gtu":"Success","execution_result_gtu":" order_date source net_sales\n0 2024-02 amazon 5072.924089\n1 2024-03 amazon 88064.209158\n2 2024-03 shopify 159914.271331\n3 2024-04 amazon 13042.343896\n4 2024-04 shopify 488570.305055\n5 2024-05 amazon 2540.679512\n6 2024-05 shopify 458493.700030\n7 2024-06 shopify 373828.700250\n8 2024-07 shopify 434127.200322","llama_sqlcoder_3_few_promp":"SELECT o.source, DATE_TRUNC('month', o.order_date) AS MONTH, SUM(COALESCE(o.net_sales_before_tax, 0)) AS total_sales FROM order_values o WHERE o.order_date >= DATE_TRUNC('month', CURRENT_DATE) - INTERVAL '6 months' AND o.order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY o.source, MONTH ORDER BY o.source, MONTH;","execution_status_llama":"Success","execution_result_llama":" source MONTH total_sales\n0 amazon 2024-02-01 5072.924089\n1 amazon 2024-03-01 88064.209158\n2 amazon 2024-04-01 13042.343896\n3 amazon 2024-05-01 2540.679512\n4 shopify 2024-03-01 159914.271331\n5 shopify 2024-04-01 488570.305055\n6 shopify 2024-05-01 458493.700030\n7 shopify 2024-06-01 373828.700250\n8 shopify 2024-07-01 434127.200322","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Show me the trend of sales by source for the last 6 months","role":"user"},{"content":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, source, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month, source ORDER BY order_year, order_month, source;","role":"assistant"}]} {"question":"Show the trend of discount code usage over the past year.","ground_truth_query":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, COUNT(DISTINCT order_id) AS discount_code_usage FROM order_values WHERE total_discount_after_tax > 0 AND order_date >= DATE_TRUNC('year', CURRENT_DATE) - INTERVAL 1 YEAR GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_gtu":"Success","execution_result_gtu":" order_date discount_code_usage\n0 2023-01 62\n1 2023-02 61\n2 2023-03 69\n3 2024-03 98\n4 2024-04 384\n5 2024-05 398\n6 2024-06 345\n7 2024-07 307\n8 2024-08 145","llama_sqlcoder_3_few_promp":"SELECT date_trunc('month', o.order_date_time) AS MONTH, COUNT(DISTINCT CASE WHEN o.total_discount_before_tax > 0 THEN o.order_id ELSE NULL END) AS num_orders_with_discount FROM order_values o WHERE date_trunc('month', o.order_date_time) >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 year') GROUP BY MONTH ORDER BY MONTH;","execution_status_llama":"Success","execution_result_llama":" MONTH num_orders_with_discount\n0 2023-08-01 0\n1 2023-09-01 0\n2 2023-10-01 0\n3 2023-11-01 0\n4 2023-12-01 0\n5 2024-01-01 0\n6 2024-02-01 0\n7 2024-03-01 98\n8 2024-04-01 384\n9 2024-05-01 398\n10 2024-06-01 345\n11 2024-07-01 307\n12 2024-08-01 145","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Show the trend of discount code usage over the past year.","role":"user"},{"content":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, COUNT(DISTINCT order_id) AS discount_code_usage FROM order_values WHERE total_discount_after_tax > 0 AND order_date >= DATE_TRUNC('year', CURRENT_DATE) - INTERVAL 1 YEAR GROUP BY order_year, order_month ORDER BY order_year, order_month;","role":"assistant"}]} {"question":"Which are the states with the lowest return rate in terms of revenue?","ground_truth_query":"SELECT LOWER(billing_address_state) AS state, SUM(COALESCE(total_returns_before_tax, 0)) \/ NULLIF(SUM(COALESCE(net_sales_before_tax, 0)), 0) AS return_rate FROM order_values WHERE billing_address_state IS NOT NULL AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY LOWER(billing_address_state) ORDER BY return_rate ASC;","execution_status_gtu":"Success","execution_result_gtu":" state return_rate\n0 andaman and nicobar islands -10.990000\n1 daman and diu 0.000000\n2 dadra and nagar haveli and daman and diu 0.000000\n3 nagaland 0.000000\n4 chandigarh 0.000000\n5 dadra and nagar haveli 0.000000\n6 tripura 0.000000\n7 jammu & kashmir 0.000000\n8 sikkim 0.000000\n9 mizoram 0.000000\n10 manipur 0.000000\n11 arunachal pradesh 0.000000\n12 goa 0.000000\n13 daman & diu 0.000000\n14 puducherry 0.000000\n15 assam 0.050944\n16 telangana 0.052080\n17 gujarat 0.055406\n18 andhra pradesh 0.059246\n19 kerala 0.067619\n20 uttarakhand 0.087011\n21 punjab 0.087154\n22 maharashtra 0.104691\n23 karnataka 0.108595\n24 jharkhand 0.115944\n25 west bengal 0.119960\n26 odisha 0.126468\n27 haryana 0.138577\n28 delhi 0.140039\n29 madhya pradesh 0.146371\n30 tamil nadu 0.146595\n31 meghalaya 0.154631\n32 bihar 0.183297\n33 uttar pradesh 0.220907\n34 rajasthan 0.267691\n35 himachal pradesh 0.375019\n36 jammu and kashmir 0.473563\n37 chhattisgarh 0.827098","llama_sqlcoder_3_few_promp":"SELECT o.billing_address_state, SUM(o.total_returns_before_tax) \/ NULLIF(COUNT(o.total_returns_before_tax), 0) AS return_rate FROM order_values o GROUP BY o.billing_address_state ORDER BY return_rate ASC LIMIT 5;","execution_status_llama":"Success","execution_result_llama":" billing_address_state return_rate\n0 ONTARIO 0.0\n1 MH 0.0\n2 NEW DELHI 0.0\n3 DADRA AND NAGAR HAVELI AND DAMAN AND DIU 0.0\n4 WB 0.0","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Which are the states with the lowest return rate in terms of revenue?","role":"user"},{"content":"SELECT LOWER(billing_address_state) AS state, SUM(COALESCE(total_returns_before_tax, 0)) \/ NULLIF(SUM(COALESCE(net_sales_before_tax, 0)), 0) AS return_rate FROM order_values WHERE billing_address_state IS NOT NULL AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY LOWER(billing_address_state) ORDER BY return_rate ASC;","role":"assistant"}]} {"question":"Monthly trend of average order value AOV","ground_truth_query":"WITH order_totals AS (SELECT order_id, order_year, order_month, SUM(net_sales_before_tax) AS total_net_sales_before_tax FROM order_values WHERE refund_status = 'false' AND cancellation_status = 'false' AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_id, order_year, order_month) SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, ROUND(AVG(total_net_sales_before_tax), 2) AS avg_net_sales_aov FROM order_totals GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_gtu":"Success","execution_result_gtu":" order_date avg_net_sales_aov\n0 2023-10 999.62\n1 2023-11 338.30\n2 2023-08 471.07\n3 2023-09 1001.97\n4 2024-01 398.67\n5 2024-02 362.35\n6 2024-03 887.67\n7 2024-04 720.86\n8 2024-05 729.66\n9 2024-06 801.15\n10 2024-07 919.75","llama_sqlcoder_3_few_promp":"SELECT date_trunc('month', order_date) AS MONTH, AVG(COALESCE(gross_sales_price_before_tax, 0)) AS AOV FROM order_values GROUP BY MONTH ORDER BY MONTH;","execution_status_llama":"Success","execution_result_llama":" MONTH AOV\n0 2021-05-01 2091.155963\n1 2021-06-01 1997.628822\n2 2021-07-01 2013.755330\n3 2021-08-01 1630.385285\n4 2021-09-01 3887.363218\n5 2021-10-01 1759.823819\n6 2021-11-01 2100.978024\n7 2021-12-01 2717.721411\n8 2022-01-01 2494.882928\n9 2022-02-01 1815.118655\n10 2022-03-01 1553.860943\n11 2022-04-01 1244.560837\n12 2022-05-01 1505.704470\n13 2022-06-01 1433.589694\n14 2022-07-01 1362.078800\n15 2022-08-01 1404.846494\n16 2022-09-01 899.605881\n17 2022-10-01 1346.503631\n18 2022-11-01 1196.463070\n19 2022-12-01 967.004427\n20 2023-01-01 1050.309364\n21 2023-02-01 960.291199\n22 2023-03-01 772.322161\n23 2023-04-01 489.108709\n24 2023-05-01 438.130612\n25 2023-06-01 533.956672\n26 2023-07-01 491.002230\n27 2023-08-01 401.297727\n28 2023-09-01 539.723125\n29 2023-10-01 575.805895\n30 2023-11-01 211.440000\n31 2023-12-01 304.916000\n32 2024-01-01 346.780000\n33 2024-02-01 284.792632\n34 2024-03-01 915.231722\n35 2024-04-01 1086.776384\n36 2024-05-01 1077.604508\n37 2024-06-01 1156.416016\n38 2024-07-01 1160.020873\n39 2024-08-01 1116.179775","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Monthly trend of average order value AOV","role":"user"},{"content":"WITH order_totals AS (SELECT order_id, order_year, order_month, SUM(net_sales_before_tax) AS total_net_sales_before_tax FROM order_values WHERE refund_status = 'false' AND cancellation_status = 'false' AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_id, order_year, order_month) SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, ROUND(AVG(total_net_sales_before_tax), 2) AS avg_net_sales_aov FROM order_totals GROUP BY order_year, order_month ORDER BY order_year, order_month;","role":"assistant"}]} {"question":"What is the correlation between product price and return rate?","ground_truth_query":"WITH product_returns AS ( SELECT product_id, SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) AS total_returns, COUNT(*) AS total_orders FROM order_values WHERE order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) GROUP BY product_id ) SELECT p.product_price, ROUND(COALESCE(pr.total_returns, 0) * 100 \/ NULLIF(pr.total_orders, 0), 2) AS return_rate FROM order_values p LEFT JOIN product_returns pr ON p.product_id = pr.product_id WHERE p.product_price IS NOT NULL AND p.order_date < DATE_TRUNC('month', CURRENT_DATE) AND p.order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12));","execution_status_gtu":"Success","execution_result_gtu":null,"llama_sqlcoder_3_few_promp":"SELECT o.product_price, COUNT(o.order_refund_line_item_id) \/ NULLIF(COUNT(o.order_line_item_id), 0) AS return_rate FROM order_values o GROUP BY o.product_price ORDER BY o.product_price NULLS LAST;","execution_status_llama":"Success","execution_result_llama":" product_price return_rate\n0 0.0 0.055263\n1 0.85 0.000000\n2 1.0 0.465116\n3 1016.1 0.574257\n4 1016.1017 0.358209\n5 1049.0 0.125000\n6 1058.47 0.358491\n7 1058.48 0.500000\n8 1099.0 0.109955\n9 1100.84 0.451613\n10 1100.8474 0.395630\n11 1100.85 0.397436\n12 1119.2 0.000000\n13 1149.0 0.138614\n14 1185.59 0.338710\n15 1185.5933 0.113636\n16 1185.6 0.181818\n17 1199.0 0.094878\n18 1270.339 0.182405\n19 1270.34 0.365385\n20 1299.0 0.128015\n21 1349.0 0.000000\n22 1355.08 0.312977\n23 1355.0847 0.109726\n24 1399.0 0.163842\n25 1439.2 0.000000\n26 1439.83 0.250000\n27 1439.8304 0.153846\n28 1439.84 0.181818\n29 1449.0 0.000000\n30 1499.0 0.134378\n31 1524.5763 0.157831\n32 1524.58 0.454545\n33 1525.42 1.000000\n34 1528.0 0.000000\n35 1529.0 0.000000\n36 1599.0 0.114286\n37 1694.06 1.000000\n38 1694.0677 0.252927\n39 1694.07 0.666667\n40 1699.0 0.133333\n41 1799.0 0.261905\n42 1863.5593 0.058824\n43 1905.9323 0.111111\n44 1948.305 0.244444\n45 1999.0 0.155963\n46 2033.0508 0.416667\n47 2117.7966 0.363904\n48 2199.0 0.000000\n49 2249.0 0.000000\n50 2372.034 0.141026\n51 2499.0 0.085106\n52 253.38 0.080000\n53 253.39 0.096330\n54 2541.5254 0.536145\n55 2711.0168 0.000000\n56 2799.0 0.333333\n57 2965.2542 0.277778\n58 299.0 0.071429\n59 2999.0 0.044776\n60 3199.0 0.000000\n61 338.14 0.129310\n62 3499.0 0.250000\n63 399.0 0.040404\n64 3999.0 0.041379\n65 422.88 0.174419\n66 422.88135 0.133333\n67 4499.0 0.142857\n68 499.0 0.038462\n69 4999.0 0.024311\n70 507.62 0.320000\n71 507.6271 0.096774\n72 507.63 0.200873\n73 5499.0 0.037037\n74 592.37 0.263682\n75 592.37286 0.291513\n76 592.38 0.333333\n77 599.0 0.185185\n78 677.11865 0.222222\n79 677.12 0.289474\n80 699.0 0.088889\n81 703.0 0.500000\n82 719.0 0.000000\n83 761.86 0.209412\n84 761.8644 0.245509\n85 799.0 0.079125\n86 846.61 0.383803\n87 846.61005 0.500000\n88 846.61017 0.187088\n89 846.62 0.463768\n90 848.0 0.000000\n91 849.0 0.000000\n92 879.0 0.000000\n93 889.83 0.090909\n94 889.84 0.000000\n95 898.0 0.000000\n96 899.0 0.113379\n97 931.35596 0.025000\n98 931.36 0.514851\n99 9499.0 0.043478\n100 973.7288 0.000000\n101 998.0 0.000000\n102 999.0 0.097568","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"What is the correlation between product price and return rate?","role":"user"},{"content":"WITH product_returns AS ( SELECT product_id, SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) AS total_returns, COUNT(*) AS total_orders FROM order_values WHERE order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) GROUP BY product_id ) SELECT p.product_price, ROUND(COALESCE(pr.total_returns, 0) * 100 \/ NULLIF(pr.total_orders, 0), 2) AS return_rate FROM order_values p LEFT JOIN product_returns pr ON p.product_id = pr.product_id WHERE p.product_price IS NOT NULL AND p.order_date < DATE_TRUNC('month', CURRENT_DATE) AND p.order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12));","role":"assistant"}]} {"question":"Trend of return rate in the last 6 months","ground_truth_query":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, ROUND(SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) \/ COUNT(*) * 100.0, 2) AS return_rate FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_gtu":"Success","execution_result_gtu":" order_date return_rate\n0 2024-02 5.26\n1 2024-03 11.45\n2 2024-04 8.86\n3 2024-05 9.13\n4 2024-06 8.40\n5 2024-07 9.87","llama_sqlcoder_3_few_promp":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, COUNT(DISTINCT CASE WHEN total_returns_before_tax > 0 THEN order_line_item_id END) \/ NULLIF(COUNT(DISTINCT order_line_item_id), 0) AS return_rate FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_llama":"Success","execution_result_llama":" order_date return_rate\n0 2024-02 0.052632\n1 2024-03 0.114504\n2 2024-04 0.088575\n3 2024-05 0.091298\n4 2024-06 0.083984\n5 2024-07 0.098672","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Trend of return rate in the last 6 months","role":"user"},{"content":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, ROUND(SUM(CASE WHEN total_returns_before_tax > 0 THEN 1 ELSE 0 END) \/ COUNT(*) * 100.0, 2) AS return_rate FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month;","role":"assistant"}]} {"question":"What are my sales for the last quarter?","ground_truth_query":"WITH last_completed_quarter AS (SELECT CASE WHEN order_quarter = 1 THEN order_year - 1 ELSE order_year END AS last_quarter_year, CASE WHEN order_quarter = 1 THEN 4 ELSE order_quarter - 1 END AS last_quarter FROM order_values GROUP BY order_year,order_quarter ORDER BY order_year DESC, order_quarter DESC LIMIT 1) SELECT SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales_last_quarter FROM order_values o JOIN last_completed_quarter lq ON o.order_year = lq.last_quarter_year AND o.order_quarter = lq.last_quarter;","execution_status_gtu":"Success","execution_result_gtu":" total_sales_last_quarter\n0 1.336476e+06","llama_sqlcoder_3_few_promp":"SELECT SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales FROM order_values WHERE order_quarter = 4 AND order_year = 2024;","execution_status_llama":"Success","execution_result_llama":" total_sales\n0 NaN","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"What are my sales for the last quarter?","role":"user"},{"content":"WITH last_completed_quarter AS (SELECT CASE WHEN order_quarter = 1 THEN order_year - 1 ELSE order_year END AS last_quarter_year, CASE WHEN order_quarter = 1 THEN 4 ELSE order_quarter - 1 END AS last_quarter FROM order_values GROUP BY order_year,order_quarter ORDER BY order_year DESC, order_quarter DESC LIMIT 1) SELECT SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales_last_quarter FROM order_values o JOIN last_completed_quarter lq ON o.order_year = lq.last_quarter_year AND o.order_quarter = lq.last_quarter;","role":"assistant"}]} {"question":"How many of my customers have purchased more than once within the last 12 months?","ground_truth_query":"SELECT COUNT(DISTINCT customer_id) AS customers_with_multiple_purchases FROM (SELECT customer_id, COUNT(DISTINCT order_id) AS number_of_orders FROM order_values WHERE order_date BETWEEN DATE_SUB(CURRENT_DATE, 365) AND CURRENT_DATE GROUP BY customer_id HAVING COUNT(DISTINCT order_id) > 1) AS subquery;","execution_status_gtu":"Success","execution_result_gtu":" customers_with_multiple_purchases\n0 293","llama_sqlcoder_3_few_promp":"SELECT COUNT(DISTINCT customer_id) AS customer_count FROM order_values WHERE order_date >= DATE_TRUNC('month', CURRENT_DATE) - INTERVAL '12 months';","execution_status_llama":"Success","execution_result_llama":" customer_count\n0 2693","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"How many of my customers have purchased more than once within the last 12 months?","role":"user"},{"content":"SELECT COUNT(DISTINCT customer_id) AS customers_with_multiple_purchases FROM (SELECT customer_id, COUNT(DISTINCT order_id) AS number_of_orders FROM order_values WHERE order_date BETWEEN DATE_SUB(CURRENT_DATE, 365) AND CURRENT_DATE GROUP BY customer_id HAVING COUNT(DISTINCT order_id) > 1) AS subquery;","role":"assistant"}]} {"question":"Trend of gross vs. net sales for the last 12 months","ground_truth_query":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, SUM(COALESCE(gross_sales_price_before_tax, 0)) AS gross_sales, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_gtu":"Success","execution_result_gtu":" order_date gross_sales net_sales\n0 2023-10 54701.56000 35986.287216\n1 2023-11 2537.28000 1691.516490\n2 2023-12 1524.58000 0.002197\n3 2023-08 26485.65000 17474.938016\n4 2023-09 8635.57000 6011.838617\n5 2024-01 10403.40000 8372.042136\n6 2024-02 5411.06000 5072.924089\n7 2024-03 359686.06663 247978.480489\n8 2024-04 846598.80289 501612.648951\n9 2024-05 755400.76000 461034.379542\n10 2024-06 592085.00000 373828.700250\n11 2024-07 611331.00000 434127.200322","llama_sqlcoder_3_few_promp":"SELECT date_trunc('month', o.order_date) AS MONTH, SUM(o.gross_sales_price_before_tax) AS gross_sales, SUM(o.net_sales_before_tax) AS net_sales FROM order_values o WHERE date_part('year', o.order_date) = EXTRACT(YEAR FROM CURRENT_DATE) - 1 AND date_part('day', o.order_date) <= EXTRACT(DAY FROM CURRENT_DATE) GROUP BY MONTH ORDER BY MONTH;","execution_status_llama":"Success","execution_result_llama":" MONTH gross_sales net_sales\n0 2023-01-01 1.957088e+06 1.634185e+06\n1 2023-02-01 2.507320e+06 2.138935e+06\n2 2023-03-01 1.741193e+06 1.383821e+06\n3 2023-04-01 2.841722e+05 1.494466e+05\n4 2023-05-01 5.907046e+04 4.425858e+04\n5 2023-06-01 3.177042e+05 1.845753e+05\n6 2023-07-01 1.423756e+05 9.463067e+04\n7 2023-08-01 2.606277e+04 1.705206e+04\n8 2023-09-01 8.635570e+03 6.011839e+03\n9 2023-10-01 5.470156e+04 3.598629e+04\n10 2023-11-01 2.537280e+03 1.691516e+03\n11 2023-12-01 1.524580e+03 2.197266e-03","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Trend of gross vs. net sales for the last 12 months","role":"user"},{"content":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, SUM(COALESCE(gross_sales_price_before_tax, 0)) AS gross_sales, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month;","role":"assistant"}]} {"question":"What is the average revenue per customer in April 2024?","ground_truth_query":"SELECT ROUND(AVG(customer_revenue), 2) AS avg_revenue_per_customer FROM (SELECT customer_id, SUM(net_sales_before_tax) AS customer_revenue FROM order_values WHERE order_year = 2024 AND order_month = 4 GROUP BY customer_id) AS customer_revenues;","execution_status_gtu":"Success","execution_result_gtu":" avg_revenue_per_customer\n0 736.58","llama_sqlcoder_3_few_promp":"SELECT o.customer_id, AVG(o.net_sales_before_tax) AS average_revenue_per_customer FROM order_values o WHERE LOWER(o.billing_address_city) IS NOT NULL AND EXTRACT(MONTH FROM o.order_date) = 4 AND EXTRACT(YEAR FROM o.order_date) = 2024 GROUP BY o.customer_id ORDER BY average_revenue_per_customer DESC NULLS LAST;","execution_status_llama":"Success","execution_result_llama":" customer_id average_revenue_per_customer\n0 xrwwqv9bxmjhnph@marketplace.amazon.in 1355.080000\n1 nhb9jrbphjsw1fh@marketplace.amazon.in 1355.080000\n2 psl403dc3pp0f92@marketplace.amazon.in 1355.080000\n3 sydclc7j69qm82y@marketplace.amazon.in 1355.080000\n4 5nxf8p4jntry4rv@marketplace.amazon.in 1355.080000\n5 d8nwm4q6rgyt9f3@marketplace.amazon.in 1355.080000\n6 f2rf04bgl0r38bg@marketplace.amazon.in 1270.340000\n7 5714gdfvn0sjgk8@marketplace.amazon.in 1270.340000\n8 jc9b7y4dq6krmt9@marketplace.amazon.in 1270.340000\n9 22kzvxfhgfzh2lv@marketplace.amazon.in 1100.850000\n10 knrjmpv2zd4p5lp@marketplace.amazon.in -0.006104","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"What is the average revenue per customer in April 2024?","role":"user"},{"content":"SELECT ROUND(AVG(customer_revenue), 2) AS avg_revenue_per_customer FROM (SELECT customer_id, SUM(net_sales_before_tax) AS customer_revenue FROM order_values WHERE order_year = 2024 AND order_month = 4 GROUP BY customer_id) AS customer_revenues;","role":"assistant"}]} {"question":"Which was the day with the highest number of orders in the last month?","ground_truth_query":"SELECT order_date, COUNT(DISTINCT order_id) AS order_count FROM order_values WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -1)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_date ORDER BY order_count DESC LIMIT 1;","execution_status_gtu":"Success","execution_result_gtu":" order_date order_count\n0 2024-07-01 32","llama_sqlcoder_3_few_promp":"SELECT o.order_day_of_week, COUNT(o.order_id) AS order_count FROM order_values o WHERE o.order_date >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month') AND o.order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY o.order_day_of_week ORDER BY order_count DESC LIMIT 1;","execution_status_llama":"Success","execution_result_llama":" order_day_of_week order_count\n0 3 96","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Which was the day with the highest number of orders in the last month?","role":"user"},{"content":"SELECT order_date, COUNT(DISTINCT order_id) AS order_count FROM order_values WHERE order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -1)) AND order_date < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_date ORDER BY order_count DESC LIMIT 1;","role":"assistant"}]} {"question":"What percentage of total sales did repeat customers contribute in the last quarter?","ground_truth_query":"WITH last_completed_quarter AS (SELECT CASE WHEN order_quarter = 1 THEN order_year - 1 ELSE order_year END AS last_quarter_year, CASE WHEN order_quarter = 1 THEN 4 ELSE order_quarter - 1 END AS last_quarter FROM order_values GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC LIMIT 1), total_sales AS (SELECT SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales FROM order_values o JOIN last_completed_quarter lq ON o.order_year = lq.last_quarter_year AND o.order_quarter = lq.last_quarter), repeat_customer_sales AS (SELECT SUM(COALESCE(net_sales_before_tax, 0)) AS repeat_sales FROM order_values o JOIN last_completed_quarter lq ON o.order_year = lq.last_quarter_year AND o.order_quarter = lq.last_quarter WHERE o.customer_id IN (SELECT customer_id FROM order_values GROUP BY customer_id HAVING COUNT(DISTINCT order_id) > 1)) SELECT ROUND((CAST(repeat_sales AS DOUBLE) \/ total_sales) * 100, 2) AS repeat_customer_sales_percentage FROM total_sales, repeat_customer_sales;","execution_status_gtu":"Success","execution_result_gtu":" repeat_customer_sales_percentage\n0 28.82","llama_sqlcoder_3_few_promp":"SELECT SUM(CASE WHEN o.order_id IN (SELECT order_id FROM order_values WHERE customer_id IN (SELECT customer_id FROM order_values WHERE order_quarter = 4 AND order_year = 2024)) THEN o.net_sales_before_tax ELSE 0 END) AS repeat_customers_sales, SUM(o.net_sales_before_tax) AS total_sales FROM order_values o WHERE o.order_quarter = 4 AND o.order_year = 2024;","execution_status_llama":"Success","execution_result_llama":" repeat_customers_sales total_sales\n0 NaN NaN","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"What percentage of total sales did repeat customers contribute in the last quarter?","role":"user"},{"content":"WITH last_completed_quarter AS (SELECT CASE WHEN order_quarter = 1 THEN order_year - 1 ELSE order_year END AS last_quarter_year, CASE WHEN order_quarter = 1 THEN 4 ELSE order_quarter - 1 END AS last_quarter FROM order_values GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC LIMIT 1), total_sales AS (SELECT SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales FROM order_values o JOIN last_completed_quarter lq ON o.order_year = lq.last_quarter_year AND o.order_quarter = lq.last_quarter), repeat_customer_sales AS (SELECT SUM(COALESCE(net_sales_before_tax, 0)) AS repeat_sales FROM order_values o JOIN last_completed_quarter lq ON o.order_year = lq.last_quarter_year AND o.order_quarter = lq.last_quarter WHERE o.customer_id IN (SELECT customer_id FROM order_values GROUP BY customer_id HAVING COUNT(DISTINCT order_id) > 1)) SELECT ROUND((CAST(repeat_sales AS DOUBLE) \/ total_sales) * 100, 2) AS repeat_customer_sales_percentage FROM total_sales, repeat_customer_sales;","role":"assistant"}]} {"question":"Bestselling SKUs for new customers vs. returning customers","ground_truth_query":"WITH first_orders AS ( SELECT customer_id, MIN(CAST(first_ordered_at AS DATE)) AS first_order_date FROM order_values GROUP BY customer_id ), customer_type AS ( SELECT o.customer_id, CASE WHEN f.first_order_date = o.order_date THEN 'new' ELSE 'returning' END AS customer_type, o.sku_code, o.product_title, SUM(o.net_sales_before_tax) AS total_sales FROM order_values o JOIN first_orders f ON o.customer_id = f.customer_id WHERE o.order_date < DATE_TRUNC('month', CURRENT_DATE) AND o.order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) GROUP BY o.customer_id, CASE WHEN f.first_order_date = o.order_date THEN 'new' ELSE 'returning' END, o.sku_code, o.product_title ) SELECT * FROM (SELECT customer_type, sku_code, product_title, SUM(total_sales) AS total_sales FROM customer_type WHERE customer_type='new' GROUP BY customer_type, sku_code, product_title ORDER BY customer_type, total_sales DESC LIMIT 5) UNION ALL SELECT * FROM (SELECT customer_type, sku_code, product_title, SUM(total_sales) AS total_sales FROM customer_type WHERE customer_type='returning' GROUP BY customer_type, sku_code, product_title ORDER BY customer_type, total_sales DESC LIMIT 5);","execution_status_gtu":"Success","execution_result_gtu":" customer_type sku_code product_title total_sales\n0 new None Hypebuds 225 416408.100141\n1 new None Flobuds 300 203680.060866\n2 new None Phantom Pro 111463.944445\n3 new None Phantom 550 90684.744465\n4 new None Flobuds 400 87070.120785\n5 returning None Hypebuds 225 93264.000000\n6 returning None Flobuds 300 25169.810170\n7 returning None Hypebuds 230 13390.000000\n8 returning None Flobuds 400 13283.000000\n9 returning None Flobuds 300 - White 12383.000000","llama_sqlcoder_3_few_promp":"SELECT o.order_id, o.sku_id, SUM(o.net_sales_before_tax) AS total_sales, COUNT(*) AS total_orders, CASE WHEN o.customer_id IN (SELECT DISTINCT customer_id FROM order_values WHERE first_ordered_at <= '2024-04-01') THEN 'Returning' ELSE 'New' END AS customer_type FROM order_values o GROUP BY o.order_id, o.sku_id, customer_type ORDER BY total_sales DESC NULLS LAST LIMIT 10;","execution_status_llama":"Success","execution_result_llama":" order_id sku_id total_sales total_orders customer_type\n0 shopify_4956263481588 shopify_7649836630260_42708090454260 34990.000 1 Returning\n1 shopify_5106334925044 shopify_7815197032692_43193431392500 19485.000 1 Returning\n2 shopify_5077511110900 shopify_7815355302132_43193987432692 10392.000 1 Returning\n3 shopify_4956266004724 shopify_7209757442217_41293628899497 7995.000 1 Returning\n4 shopify_5064954347764 shopify_7529683550452_42328072585460 6990.000 1 Returning\n5 shopify_5064954347764 shopify_7529683550452_42328072618228 6990.000 1 Returning\n6 shopify_4157279043753 shopify_6624938033321_39504943972521 5082.203 1 Returning\n7 shopify_5077511110900 shopify_7493164892404_42204994502900 4596.000 1 Returning\n8 shopify_5086978375924 shopify_7580801106164_42483248464116 4396.000 1 Returning\n9 shopify_4708580163828 shopify_7562411016436_42424128700660 4319.491 1 Returning","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Bestselling SKUs for new customers vs. returning customers","role":"user"},{"content":"WITH first_orders AS ( SELECT customer_id, MIN(CAST(first_ordered_at AS DATE)) AS first_order_date FROM order_values GROUP BY customer_id ), customer_type AS ( SELECT o.customer_id, CASE WHEN f.first_order_date = o.order_date THEN 'new' ELSE 'returning' END AS customer_type, o.sku_code, o.product_title, SUM(o.net_sales_before_tax) AS total_sales FROM order_values o JOIN first_orders f ON o.customer_id = f.customer_id WHERE o.order_date < DATE_TRUNC('month', CURRENT_DATE) AND o.order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) GROUP BY o.customer_id, CASE WHEN f.first_order_date = o.order_date THEN 'new' ELSE 'returning' END, o.sku_code, o.product_title ) SELECT * FROM (SELECT customer_type, sku_code, product_title, SUM(total_sales) AS total_sales FROM customer_type WHERE customer_type='new' GROUP BY customer_type, sku_code, product_title ORDER BY customer_type, total_sales DESC LIMIT 5) UNION ALL SELECT * FROM (SELECT customer_type, sku_code, product_title, SUM(total_sales) AS total_sales FROM customer_type WHERE customer_type='returning' GROUP BY customer_type, sku_code, product_title ORDER BY customer_type, total_sales DESC LIMIT 5);","role":"assistant"}]} {"question":"Show the monthly trend of sales by product category.","ground_truth_query":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, product_category, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) GROUP BY order_year, order_month, product_category ORDER BY order_year, order_month, product_category;","execution_status_gtu":"Success","execution_result_gtu":" order_date product_category net_sales\n0 2023-10 None 35986.287216\n1 2023-11 None 1691.516490\n2 2023-12 None 0.002197\n3 2023-08 None 17474.938016\n4 2023-09 None 6011.838617\n5 2024-01 None 8372.042136\n6 2024-02 None 5072.924089\n7 2024-03 None 101208.988969\n8 2024-03 Gaming Headphones 21487.000000\n9 2024-03 Gaming Mouse 4493.000000\n10 2024-03 NeckBand 4097.000000\n11 2024-03 Speaker 4265.491520\n12 2024-03 True WireLess 92076.000000\n13 2024-03 True Wireless 20351.000000\n14 2024-04 None 136419.011170\n15 2024-04 Gaming Headphones 22981.000000\n16 2024-04 Gaming Mouse 4791.000000\n17 2024-04 NeckBand 15088.000000\n18 2024-04 Neckband 6122.000000\n19 2024-04 Speaker 29661.748889\n20 2024-04 True WireLess 205194.111113\n21 2024-04 True Wireless 81355.777779\n22 2024-05 None 298214.279512\n23 2024-05 Gaming Headphones 7835.100000\n24 2024-05 Gaming Mouse 1946.000000\n25 2024-05 NeckBand 16852.100030\n26 2024-05 Neckband 4068.000000\n27 2024-05 Speaker 19741.000000\n28 2024-05 True WireLess 85052.800000\n29 2024-05 True Wireless 27325.100000\n30 2024-06 None 288145.100140\n31 2024-06 Gaming Headphones 2099.000000\n32 2024-06 NeckBand 15058.100000\n33 2024-06 Neckband 1299.000000\n34 2024-06 Speaker 6466.200090\n35 2024-06 True WireLess 8397.300020\n36 2024-06 True Wireless 52364.000000\n37 2024-07 None 307240.900212\n38 2024-07 Gaming Headphones 3439.100000\n39 2024-07 Gaming Mouse 0.000000\n40 2024-07 NeckBand 16672.300000\n41 2024-07 Speaker 26201.100000\n42 2024-07 True WireLess 12981.300000\n43 2024-07 True Wireless 67592.500111","llama_sqlcoder_3_few_promp":"SELECT product_category, EXTRACT(MONTH FROM order_date_time) AS MONTH, SUM(net_sales_before_tax) AS total_sales FROM order_values GROUP BY product_category, MONTH ORDER BY product_category, MONTH;","execution_status_llama":"Success","execution_result_llama":" product_category MONTH total_sales\n0 None 1 6.859374e+05\n1 None 2 5.100592e+05\n2 None 3 7.695974e+05\n3 None 4 2.922370e+05\n4 None 5 3.678976e+05\n5 None 6 7.401576e+05\n6 None 7 5.193927e+05\n7 None 8 2.885988e+05\n8 None 9 2.800002e+05\n9 None 10 6.599558e+05\n10 None 11 1.616742e+05\n11 None 12 7.355840e+05\n12 Gaming Headphones 1 4.078720e+04\n13 Gaming Headphones 2 4.296130e+04\n14 Gaming Headphones 3 4.477310e+04\n15 Gaming Headphones 4 2.298100e+04\n16 Gaming Headphones 5 7.835100e+03\n17 Gaming Headphones 6 2.099000e+03\n18 Gaming Headphones 7 3.865176e+03\n19 Gaming Headphones 8 1.101186e+04\n20 Gaming Headphones 9 2.910322e+03\n21 Gaming Headphones 10 4.062559e+03\n22 Gaming Headphones 11 5.078100e+03\n23 Gaming Headphones 12 4.694000e+03\n24 Gaming Keyboard 1 2.897000e+03\n25 Gaming Keyboard 2 1.099000e+03\n26 Gaming Keyboard 3 3.197000e+03\n27 Gaming Keyboard 6 1.862712e+03\n28 Gaming Keyboard 7 1.660933e+02\n29 Gaming Keyboard 8 1.971865e+03\n30 Gaming Keyboard 9 7.628983e+02\n31 Gaming Keyboard 12 2.198000e+03\n32 Gaming Mouse 1 2.309810e+04\n33 Gaming Mouse 2 1.326400e+04\n34 Gaming Mouse 3 1.127600e+04\n35 Gaming Mouse 4 4.791000e+03\n36 Gaming Mouse 5 1.946000e+03\n37 Gaming Mouse 6 4.047763e+03\n38 Gaming Mouse 7 7.519932e+03\n39 Gaming Mouse 8 7.843390e+03\n40 Gaming Mouse 9 1.815525e+03\n41 Gaming Mouse 10 3.693000e+03\n42 Gaming Mouse 11 3.694000e+03\n43 Gaming Mouse 12 5.288000e+03\n44 NeckBand 1 1.425698e+05\n45 NeckBand 2 1.033898e+06\n46 NeckBand 3 6.114083e+05\n47 NeckBand 4 3.630908e+05\n48 NeckBand 5 6.375861e+04\n49 NeckBand 6 7.834105e+04\n50 NeckBand 7 6.809840e+04\n51 NeckBand 8 6.344236e+04\n52 NeckBand 9 3.924641e+04\n53 NeckBand 10 7.705974e+03\n54 NeckBand 11 2.044056e+04\n55 NeckBand 12 7.153854e+04\n56 Neckband 1 2.604652e+04\n57 Neckband 2 6.975425e+04\n58 Neckband 3 4.124783e+04\n59 Neckband 4 2.098502e+04\n60 Neckband 5 2.724388e+04\n61 Neckband 6 1.175643e+04\n62 Neckband 7 1.087042e+02\n63 Neckband 8 4.455017e+03\n64 Neckband 9 1.614475e+03\n65 Neckband 10 8.389139e+04\n66 Neckband 12 1.660864e+03\n67 Speaker 1 3.233279e+04\n68 Speaker 2 3.660489e+04\n69 Speaker 3 2.999944e+04\n70 Speaker 4 3.626683e+04\n71 Speaker 5 2.243797e+04\n72 Speaker 6 7.852963e+03\n73 Speaker 7 2.689707e+04\n74 Speaker 8 2.516563e+04\n75 Speaker 9 2.201695e+03\n76 Speaker 10 -2.899156e+02\n77 Speaker 11 1.811731e+04\n78 Speaker 12 7.686883e+04\n79 True WireLess 1 1.494379e+06\n80 True WireLess 2 1.010547e+06\n81 True WireLess 3 7.884078e+05\n82 True WireLess 4 3.588701e+05\n83 True WireLess 5 1.477619e+05\n84 True WireLess 6 1.053472e+05\n85 True WireLess 7 4.291610e+05\n86 True WireLess 8 1.407198e+06\n87 True WireLess 9 5.113959e+05\n88 True WireLess 10 8.924566e+05\n89 True WireLess 11 2.865846e+05\n90 True WireLess 12 6.938895e+05\n91 True Wireless 1 1.171054e+06\n92 True Wireless 2 2.063434e+06\n93 True Wireless 3 8.829846e+05\n94 True Wireless 4 4.257644e+05\n95 True Wireless 5 1.240339e+06\n96 True Wireless 6 1.011855e+06\n97 True Wireless 7 5.554614e+05\n98 True Wireless 8 3.372477e+05\n99 True Wireless 9 1.577380e+06\n100 True Wireless 10 5.853576e+05\n101 True Wireless 11 4.334485e+05\n102 True Wireless 12 7.239043e+05","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Show the monthly trend of sales by product category.","role":"user"},{"content":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, product_category, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) GROUP BY order_year, order_month, product_category ORDER BY order_year, order_month, product_category;","role":"assistant"}]} {"question":"Show me trend of sales for the last 6 months","ground_truth_query":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_gtu":"Success","execution_result_gtu":" order_date net_sales\n0 2024-02 5072.924089\n1 2024-03 247978.480489\n2 2024-04 501612.648951\n3 2024-05 461034.379542\n4 2024-06 373828.700250\n5 2024-07 434127.200322","llama_sqlcoder_3_few_promp":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_llama":"Success","execution_result_llama":" order_date net_sales\n0 2024-02 5072.924089\n1 2024-03 247978.480489\n2 2024-04 501612.648951\n3 2024-05 461034.379542\n4 2024-06 373828.700250\n5 2024-07 434127.200322","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Show me trend of sales for the last 6 months","role":"user"},{"content":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month;","role":"assistant"}]} {"question":"MoM revenue growth rate for the last 6 months","ground_truth_query":"WITH monthly_revenue AS (SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month), revenue_growth AS (SELECT order_date, net_sales, LAG(net_sales) OVER (ORDER BY order_date) AS previous_month_sales FROM monthly_revenue) SELECT order_date, ROUND((net_sales - previous_month_sales) \/ NULLIF(previous_month_sales, 0) * 100, 2) AS mom_growth_rate FROM revenue_growth;","execution_status_gtu":"Success","execution_result_gtu":" order_date mom_growth_rate\n0 2024-02 NaN\n1 2024-03 4788.28\n2 2024-04 102.28\n3 2024-05 -8.09\n4 2024-06 -18.92\n5 2024-07 16.13","llama_sqlcoder_3_few_promp":"SELECT (SUM(CASE WHEN DATE_TRUNC('month', TO_TIMESTAMP(o.order_date_time)) <= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '6 months') THEN o.net_sales_before_tax ELSE 0 END) - SUM(CASE WHEN DATE_TRUNC('month', TO_TIMESTAMP(o.order_date_time)) > DATE_TRUNC('month', CURRENT_DATE - INTERVAL '6 months') THEN o.net_sales_before_tax ELSE 0 END)) \/ NULLIF(SUM(CASE WHEN DATE_TRUNC('month', TO_TIMESTAMP(o.order_date_time)) > DATE_TRUNC('month', CURRENT_DATE - INTERVAL '6 months') THEN o.net_sales_before_tax ELSE 0 END), 0) AS revenue_growth_rate FROM order_values o;","execution_status_llama":"Success","execution_result_llama":" revenue_growth_rate\n0 10.666218","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"MoM revenue growth rate for the last 6 months","role":"user"},{"content":"WITH monthly_revenue AS (SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month), revenue_growth AS (SELECT order_date, net_sales, LAG(net_sales) OVER (ORDER BY order_date) AS previous_month_sales FROM monthly_revenue) SELECT order_date, ROUND((net_sales - previous_month_sales) \/ NULLIF(previous_month_sales, 0) * 100, 2) AS mom_growth_rate FROM revenue_growth;","role":"assistant"}]} {"question":"net revenue for the last 180 days","ground_truth_query":"SELECT SUM(net_sales_before_tax) AS total_sales_last_180_days FROM order_values WHERE order_date >= DATE_ADD(CURRENT_DATE, -180);","execution_status_gtu":"Success","execution_result_gtu":" total_sales_last_180_days\n0 2.258234e+06","llama_sqlcoder_3_few_promp":"SELECT SUM(COALESCE(net_sales_before_tax, 0)) AS net_revenue FROM order_values WHERE order_date >= DATE_TRUNC('day', CURRENT_DATE - INTERVAL '180 days') AND order_date < DATE_TRUNC('day', CURRENT_DATE) AND net_sales_before_tax IS NOT NULL;","execution_status_llama":"Success","execution_result_llama":" net_revenue\n0 2.258234e+06","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"net revenue for the last 180 days","role":"user"},{"content":"SELECT SUM(net_sales_before_tax) AS total_sales_last_180_days FROM order_values WHERE order_date >= DATE_ADD(CURRENT_DATE, -180);","role":"assistant"}]} {"question":"Top 10 bestselling SKUs on Shopify this year","ground_truth_query":"SELECT sku_code, product_title, SUM(net_sales_before_tax) AS total_net_sales_before_tax FROM order_values WHERE source = 'shopify' AND order_year = YEAR(CURRENT_DATE) GROUP BY sku_code, product_title ORDER BY total_net_sales_before_tax DESC LIMIT 10;","execution_status_gtu":"Success","execution_result_gtu":" sku_code product_title total_net_sales_before_tax\n0 None Hypebuds 225 599286.480252\n1 None Flobuds 300 268631.111107\n2 None Phantom Pro 121247.944445\n3 None Flobuds 400 118033.040785\n4 None Phantom 550 100727.744465\n5 None Phantom 92910.000111\n6 None Phantom 850 88670.300000\n7 None Hypebuds 230 88197.900060\n8 None Phantom 315 74489.444445\n9 None Phantom 1000 66013.700030","llama_sqlcoder_3_few_promp":"SELECT o.sku_id, o.product_title, SUM(o.net_sales_before_tax) AS total_sales FROM order_values o WHERE o.order_year = 2024 GROUP BY o.sku_id, o.product_title ORDER BY total_sales DESC LIMIT 10;","execution_status_llama":"Success","execution_result_llama":" sku_id product_title total_sales\n0 shopify_8504654364916_45020311945460 Hypebuds 225 599286.480252\n1 shopify_8399227158772_44704490062068 Flobuds 300 174341.470946\n2 shopify_7207167492265_44733150888180 Phantom Pro 117405.944445\n3 shopify_8399227158772_44704490094836 Flobuds 300 94289.640161\n4 shopify_8505350586612_45022986993908 Hypebuds 230 88197.900060\n5 shopify_7995642642676_43653845319924 Phantom 850 87171.300000\n6 shopify_7901938319604_43435485888756 Phantom 550 75459.444445\n7 shopify_7600463053044_42546831524084 Phantom 1000 66013.700030\n8 shopify_8399200846068_44704447987956 Flobuds 400 63257.820765\n9 shopify_6624938033321_39504943972521 Phantom 59728.300071","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Top 10 bestselling SKUs on Shopify this year","role":"user"},{"content":"SELECT sku_code, product_title, SUM(net_sales_before_tax) AS total_net_sales_before_tax FROM order_values WHERE source = 'shopify' AND order_year = YEAR(CURRENT_DATE) GROUP BY sku_code, product_title ORDER BY total_net_sales_before_tax DESC LIMIT 10;","role":"assistant"}]} {"question":"trend of AOV for shopify in the last 3 months","ground_truth_query":"WITH order_totals AS (SELECT order_id, SUM(net_sales_before_tax) AS total_net_sales_before_tax, order_year, order_month FROM order_values WHERE refund_status = 'false' AND cancellation_status = 'false' AND source = 'shopify' AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -3)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_id, order_year, order_month) SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, ROUND(AVG(total_net_sales_before_tax), 2) AS avg_net_sales_aov FROM order_totals GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_gtu":"Success","execution_result_gtu":" order_date avg_net_sales_aov\n0 2024-05 727.80\n1 2024-06 801.15\n2 2024-07 919.75","llama_sqlcoder_3_few_promp":"SELECT AVG(COALESCE(gross_sales_price_before_tax, 0)) AS avg_gross_sales_price_before_tax FROM order_values WHERE order_date >= DATE_TRUNC('month', CURRENT_DATE) - INTERVAL '3 months' AND order_date < DATE_TRUNC('month', CURRENT_DATE) AND LOWER(source) ='shopify';","execution_status_llama":"Success","execution_result_llama":" avg_gross_sales_price_before_tax\n0 1127.371841","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"trend of AOV for shopify in the last 3 months","role":"user"},{"content":"WITH order_totals AS (SELECT order_id, SUM(net_sales_before_tax) AS total_net_sales_before_tax, order_year, order_month FROM order_values WHERE refund_status = 'false' AND cancellation_status = 'false' AND source = 'shopify' AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -3)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_id, order_year, order_month) SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, ROUND(AVG(total_net_sales_before_tax), 2) AS avg_net_sales_aov FROM order_totals GROUP BY order_year, order_month ORDER BY order_year, order_month;","role":"assistant"}]} {"question":"Trend of average order value AOV for the last 6 months","ground_truth_query":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, ROUND(AVG(total_net_sales), 2) AS avg_order_value FROM ( SELECT order_id, order_year, order_month, SUM(net_sales_before_tax) AS total_net_sales FROM order_values WHERE refund_status = 'false' AND cancellation_status = 'false' AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_id, order_year, order_month) AS order_totals GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_gtu":"Success","execution_result_gtu":" order_date avg_order_value\n0 2024-02 362.35\n1 2024-03 887.67\n2 2024-04 720.86\n3 2024-05 729.66\n4 2024-06 801.15\n5 2024-07 919.75","llama_sqlcoder_3_few_promp":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, AVG(COALESCE(net_sales_before_tax, 0)) AS avg_order_value FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_year, order_month ORDER BY order_year, order_month;","execution_status_llama":"Success","execution_result_llama":" order_date avg_order_value\n0 2024-02 266.996005\n1 2024-03 630.988500\n2 2024-04 643.918676\n3 2024-05 657.680998\n4 2024-06 730.134180\n5 2024-07 823.770779","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Trend of average order value AOV for the last 6 months","role":"user"},{"content":"SELECT CONCAT(order_year, '-', LPAD(order_month, 2, '0')) AS order_date, ROUND(AVG(total_net_sales), 2) AS avg_order_value FROM ( SELECT order_id, order_year, order_month, SUM(net_sales_before_tax) AS total_net_sales FROM order_values WHERE refund_status = 'false' AND cancellation_status = 'false' AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_id, order_year, order_month) AS order_totals GROUP BY order_year, order_month ORDER BY order_year, order_month;","role":"assistant"}]} {"question":"What is the average number of items per order for new customers vs. returning customers?","ground_truth_query":"WITH order_counts AS ( SELECT o.customer_id, o.order_id, order_date, SUM(o.ordered_quantity) AS total_items FROM order_values o WHERE order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) GROUP BY o.customer_id, o.order_id, order_date ), first_orders AS ( SELECT customer_id, MIN(CAST(first_ordered_at AS DATE)) AS first_order_date FROM order_values WHERE order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) GROUP BY customer_id ) SELECT CASE WHEN fo.first_order_date = oc.order_date THEN 'new' ELSE 'returning' END AS customer_type, ROUND(AVG(oc.total_items), 2) AS avg_items_per_order FROM order_counts oc JOIN first_orders fo ON oc.customer_id = fo.customer_id GROUP BY customer_type;","execution_status_gtu":"Success","execution_result_gtu":" customer_type avg_items_per_order\n0 new 1.01\n1 returning 1.02","llama_sqlcoder_3_few_promp":"SELECT CASE WHEN first_ordered_at IS NULL THEN 'new' ELSE'returning' END AS customer_type, AVG(ordered_quantity) AS average_items_per_order FROM order_values WHERE first_ordered_at <= '2024-04-01' AND first_ordered_at >= '2022-05-01' GROUP BY customer_type;","execution_status_llama":"Success","execution_result_llama":" customer_type average_items_per_order\n0 returning 1.023673","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"What is the average number of items per order for new customers vs. returning customers?","role":"user"},{"content":"WITH order_counts AS ( SELECT o.customer_id, o.order_id, order_date, SUM(o.ordered_quantity) AS total_items FROM order_values o WHERE order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) GROUP BY o.customer_id, o.order_id, order_date ), first_orders AS ( SELECT customer_id, MIN(CAST(first_ordered_at AS DATE)) AS first_order_date FROM order_values WHERE order_date < DATE_TRUNC('month', CURRENT_DATE) AND order_date >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -12)) GROUP BY customer_id ) SELECT CASE WHEN fo.first_order_date = oc.order_date THEN 'new' ELSE 'returning' END AS customer_type, ROUND(AVG(oc.total_items), 2) AS avg_items_per_order FROM order_counts oc JOIN first_orders fo ON oc.customer_id = fo.customer_id GROUP BY customer_type;","role":"assistant"}]} {"question":"What is the average discount applied per order in the last 6 months?","ground_truth_query":"SELECT ROUND(AVG(total_discount_after_tax), 2) AS avg_discount_per_order FROM (SELECT order_id, SUM(COALESCE(total_discount_after_tax, 0)) AS total_discount_after_tax FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_id) AS order_discounts;","execution_status_gtu":"Success","execution_result_gtu":" avg_discount_per_order\n0 299.31","llama_sqlcoder_3_few_promp":"SELECT AVG(total_discount_before_tax) AS average_discount FROM order_values WHERE order_date >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '6 months') AND order_date < DATE_TRUNC('month', CURRENT_DATE);","execution_status_llama":"Success","execution_result_llama":" average_discount\n0 295.035515","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"What is the average discount applied per order in the last 6 months?","role":"user"},{"content":"SELECT ROUND(AVG(total_discount_after_tax), 2) AS avg_discount_per_order FROM (SELECT order_id, SUM(COALESCE(total_discount_after_tax, 0)) AS total_discount_after_tax FROM order_values WHERE TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') >= DATE_TRUNC('month', ADD_MONTHS(CURRENT_DATE, -6)) AND TO_DATE(CONCAT(order_year, '-', LPAD(order_month, 2, '0')), 'yyyy-MM') < DATE_TRUNC('month', CURRENT_DATE) GROUP BY order_id) AS order_discounts;","role":"assistant"}]} {"question":"Show me a quarterly trend of sales for the last 4 quarters","ground_truth_query":"SELECT CONCAT(order_year, '-Q', order_quarter) AS year_quarter, SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales FROM order_values WHERE (order_year, order_quarter) IN (SELECT order_year, order_quarter FROM order_values GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC LIMIT 4) GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC;","execution_status_gtu":"Success","execution_result_gtu":" year_quarter total_sales\n0 2024-Q3 6.741181e+05\n1 2024-Q2 1.336476e+06\n2 2024-Q1 2.614234e+05\n3 2023-Q4 3.767781e+04","llama_sqlcoder_3_few_promp":"SELECT CONCAT(order_year, '-Q', order_quarter) AS year_quarter, SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales FROM order_values WHERE order_year = YEAR(DATE_TRUNC('quarter', CURRENT_DATE)) - 1 GROUP BY order_year, order_quarter ORDER BY order_year, order_quarter;","execution_status_llama":"Success","execution_result_llama":" year_quarter total_sales\n0 2023-Q1 5.207684e+06\n1 2023-Q2 3.822601e+05\n2 2023-Q3 1.201480e+05\n3 2023-Q4 3.767781e+04","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Show me a quarterly trend of sales for the last 4 quarters","role":"user"},{"content":"SELECT CONCAT(order_year, '-Q', order_quarter) AS year_quarter, SUM(COALESCE(net_sales_before_tax, 0)) AS total_sales FROM order_values WHERE (order_year, order_quarter) IN (SELECT order_year, order_quarter FROM order_values GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC LIMIT 4) GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC;","role":"assistant"}]} {"question":"Weekly trend of revenue in the last quarter","ground_truth_query":"WITH last_completed_quarter AS (SELECT CASE WHEN order_quarter = 1 THEN order_year - 1 ELSE order_year END AS last_quarter_year, CASE WHEN order_quarter = 1 THEN 4 ELSE order_quarter - 1 END AS last_quarter FROM order_values GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC LIMIT 1) SELECT CONCAT(o.order_year, '-W', LPAD(o.order_week, 2, '0')) AS year_week, SUM(COALESCE(o.net_sales_before_tax, 0)) AS total_net_sales FROM order_values o JOIN last_completed_quarter lq ON o.order_year = lq.last_quarter_year AND o.order_quarter = lq.last_quarter GROUP BY o.order_year, o.order_week ORDER BY o.order_year, o.order_week;","execution_status_gtu":"Success","execution_result_gtu":" year_week total_net_sales\n0 2024-W14 97896.628946\n1 2024-W15 111824.000000\n2 2024-W16 149249.340005\n3 2024-W17 89644.000000\n4 2024-W18 179621.359512\n5 2024-W19 44910.000000\n6 2024-W20 107731.100000\n7 2024-W21 94899.400000\n8 2024-W22 115425.800030\n9 2024-W23 81838.300060\n10 2024-W24 73974.900040\n11 2024-W25 83658.600080\n12 2024-W26 105802.300070","llama_sqlcoder_3_few_promp":"SELECT CONCAT(order_year, '-', LPAD(order_week, 2, '0')) AS order_week, SUM(COALESCE(net_sales_before_tax, 0)) AS net_sales FROM order_values WHERE order_quarter = 4 AND order_year = 2024 GROUP BY order_year, order_week ORDER BY order_year, order_week;","execution_status_llama":"Success","execution_result_llama":"Empty DataFrame\nColumns: [order_week, net_sales]\nIndex: []","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"Weekly trend of revenue in the last quarter","role":"user"},{"content":"WITH last_completed_quarter AS (SELECT CASE WHEN order_quarter = 1 THEN order_year - 1 ELSE order_year END AS last_quarter_year, CASE WHEN order_quarter = 1 THEN 4 ELSE order_quarter - 1 END AS last_quarter FROM order_values GROUP BY order_year, order_quarter ORDER BY order_year DESC, order_quarter DESC LIMIT 1) SELECT CONCAT(o.order_year, '-W', LPAD(o.order_week, 2, '0')) AS year_week, SUM(COALESCE(o.net_sales_before_tax, 0)) AS total_net_sales FROM order_values o JOIN last_completed_quarter lq ON o.order_year = lq.last_quarter_year AND o.order_quarter = lq.last_quarter GROUP BY o.order_year, o.order_week ORDER BY o.order_year, o.order_week;","role":"assistant"}]} {"question":"How many new customers did I get in April 2024?","ground_truth_query":"SELECT COUNT(DISTINCT customer_id) AS new_customers FROM order_values WHERE order_month = 4 AND order_year = 2024 AND first_ordered_at IS NOT NULL AND DATE_TRUNC('month', first_ordered_at) = '2024-04-01';","execution_status_gtu":"Success","execution_result_gtu":" new_customers\n0 652","llama_sqlcoder_3_few_promp":"SELECT COUNT(DISTINCT customer_id) AS new_customers FROM order_values WHERE LOWER(billing_address_city) ='surat' AND order_month = 4 AND order_year = 2024 AND customer_id NOT IN (SELECT customer_id FROM order_values WHERE LOWER(billing_address_city) ='surat' AND order_month < 4 AND order_year = 2024);","execution_status_llama":"Success","execution_result_llama":" new_customers\n0 0","messages":[{"content":"\nYou are a SQL expert in Mysql. As a SQL expert, your job is to answer data related questions from the business team accurately by writing SQL queries. Refer to the provided database schema for tables and columns. Do not correct spelling mistakes in the schema.\n\nPlease generate only read\/SELECT queries for data safety. If a question cannot be answered using a SELECT operation, it should not be addressed.\nRefer the sample queries to see how date filters and calculations are done. Pay high attention on sample queries that seem most relevant to user question.\n\nFormat your responses as JSON, including the SQL query and the following associated fields. Use this format:\n\ngenerated_query:[{\"sql_query\": \"Your SQL Query Here\", \"logic\": \"Explain briefly the logic you used\", \"response\": \"A friendly and conversational response to give more context to the user.\", \"chart\": {\"type\": \"The type of chart\", \"x_axis\": [\"Array of variables in the x-axis of the chart\"], \"y_axis\": [\"Array of variables in the y-axis of the chart\"]} }]\n\n## Database Schema:\n{\n \"order_values\": \"This table contains comprehensive order information including pricing, tax, discounts, returns, shipping, and product details. Each row represents a unique line item within an order and includes timestamps, statuses, and financials associated with the order.\",\n}\nCOLUMNS = {\n \"order_values\": {\n \"order_line_item_id\": {\n \"description\": \"Unique identifier for each line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"source\": {\n \"description\": \"Source of the order (e.g., platform or channel)\",\n \"values_sample\": [\"shopify\"],\n },\n \"order_id\": {\n \"description\": \"Unique identifier for each order\",\n \"values_sample\": [\"shopify_5667598663969\"],\n },\n \"ordered_quantity\": {\n \"description\": \"Quantity of each item ordered\",\n \"values_sample\": [1],\n },\n \"gross_sales_price_after_tax\": {\n \"description\": \"Gross sales price after tax is applied\",\n \"values_sample\": [150.00],\n },\n \"tax_percent\": {\n \"description\": \"Tax percentage applied to the order\",\n \"values_sample\": [18.0],\n },\n \"total_price_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [20.00],\n },\n \"gross_sales_price_before_tax\": {\n \"description\": \"Gross sales price before tax is applied\",\n \"values_sample\": [127.12],\n },\n \"total_discount_after_tax\": {\n \"description\": \"Total discount amount after tax is applied\",\n \"values_sample\": [10.00],\n },\n \"total_discount_tax\": {\n \"description\": \"Total tax amount on the discount applied\",\n \"values_sample\": [1.80],\n },\n \"total_discount_before_tax\": {\n \"description\": \"Total discount amount before tax is applied\",\n \"values_sample\": [8.20],\n },\n \"total_cancellation_returns_before_tax\": {\n \"description\": \"Total cancellation returns amount before tax\",\n \"values_sample\": [20.00],\n },\n \"total_rto_returns_before_tax\": {\n \"description\": \"Total RTO (Return to Origin) returns amount before tax\",\n \"values_sample\": [15.00],\n },\n \"total_returns_refund_before_tax\": {\n \"description\": \"Total refund amount before tax due to returns\",\n \"values_sample\": [30.00],\n },\n \"total_returns_before_tax\": {\n \"description\": \"Total returns amount before tax, including all types of returns\",\n \"values_sample\": [25.00],\n },\n \"total_return_tax\": {\n \"description\": \"Total tax amount on returns\",\n \"values_sample\": [4.50],\n },\n \"net_sales_before_tax\": {\n \"description\": \"Net sales amount before tax is applied\",\n \"values_sample\": [100.00],\n },\n \"item_shipping_charge\": {\n \"description\": \"Shipping charge for the item\",\n \"values_sample\": [5.00],\n },\n \"item_duties\": {\n \"description\": \"Duties charged for the item\",\n \"values_sample\": [3.00],\n },\n \"item_additional_fees\": {\n \"description\": \"Additional fees associated with the item\",\n \"values_sample\": [2.00],\n },\n \"total_tax\": {\n \"description\": \"Total tax amount applied to the order\",\n \"values_sample\": [18.00],\n },\n \"total_sales_after_tax\": {\n \"description\": \"Total sales amount after tax is applied\",\n \"values_sample\": [120.00],\n },\n \"gross_merchandise_value\": {\n \"description\": \"Gross merchandise value of the item\",\n \"values_sample\": [150.00],\n },\n \"sku_id\": {\n \"description\": \"Unique identifier for each SKU (Stock Keeping Unit)\",\n \"values_sample\": [\"shopify_8848983261473_47478863036705\"],\n },\n \"sku_code\": {\n \"description\": \"Code assigned to each SKU\",\n \"values_sample\": [\"BSL-D-SIP-0001\"],\n },\n \"product_category\": {\n \"description\": \"Category of the product\",\n \"values_sample\": [\"Insulated Sipper\"],\n },\n \"product_id\": {\n \"description\": \"Unique identifier for each product\",\n \"values_sample\": [\"shopify_8848983261473\"],\n },\n \"product_title\": {\n \"description\": \"Title of the product\",\n \"values_sample\": [\"Kids Sipper (430 ml)\"],\n },\n \"product_price\": {\n \"description\": \"Price of the product\",\n \"values_sample\": [999],\n },\n \"customer_id\": {\n \"description\": \"Unique identifier for each customer\",\n \"values_sample\": [\"shopify_7694075199777\"],\n },\n \"first_ordered_at\": {\n \"description\": \"Timestamp of the customer's first order\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_refund_line_item_id\": {\n \"description\": \"Unique identifier for each refunded line item in an order\",\n \"values_sample\": [\"shopify_5667598663969_14461737632033\"],\n },\n \"order_date_time_utc\": {\n \"description\": \"Order date and time in UTC\",\n \"values_sample\": [\"2024-02-14 16:00:13.000000\"],\n },\n \"order_date_time\": {\n \"description\": \"Local date and time of the order\",\n \"values_sample\": [\"2024-02-14 11:00:13.000000\"],\n },\n \"order_date\": {\n \"description\": \"Date of the order\",\n \"values_sample\": [\"2024-02-14\"],\n },\n \"order_year\": {\n \"description\": \"Year of the order\",\n \"values_sample\": [2024],\n },\n \"order_quarter\": {\n \"description\": \"Quarter of the year when the order was placed\",\n \"values_sample\": [1],\n },\n \"order_month\": {\n \"description\": \"Month of the order\",\n \"values_sample\": [2],\n },\n \"order_day_of_month\": {\n \"description\": \"Day of the month of the order\",\n \"values_sample\": [14],\n },\n \"order_week\": {\n \"description\": \"Week of the year when the order was placed\",\n \"values_sample\": [7],\n },\n \"order_day_of_week\": {\n \"description\": \"Day of the week of the order\",\n \"values_sample\": [4], # Assuming Sunday is 0\n },\n \"order_hour\": {\n \"description\": \"Hour of the day when the order was placed\",\n \"values_sample\": [16],\n },\n \"order_minute\": {\n \"description\": \"Minute of the hour when the order was placed\",\n \"values_sample\": [0],\n },\n \"order_time\": {\n \"description\": \"Time of the order\",\n \"values_sample\": [\"16:00\"],\n },\n \"refund_status\": {\n \"description\": \"Refund status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"rto_status\": {\n \"description\": \"Return to Origin (RTO) status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"cancellation_status\": {\n \"description\": \"Cancellation status of the order\",\n \"values_sample\": [\"false\"],\n },\n \"order_status\": {\n \"description\": \"Current status of the order\",\n \"values_sample\": [\"completed\"],\n },\n \"payment_status\": {\n \"description\": \"Payment status of the order\",\n \"values_sample\": [\"paid\"],\n },\n \"return_reason\": {\n \"description\": \"Reason for return, if applicable\",\n \"values_sample\": [\"damaged item\"],\n },\n \"billing_address_city\": {\n \"description\": \"City of the billing address\",\n \"values_sample\": [\"Surat\"],\n },\n \"billing_address_state\": {\n \"description\": \"State of the billing address\",\n \"values_sample\": [\"Gujarat\"],\n },\n \"billing_address_country\": {\n \"description\": \"Country of the billing address\",\n \"values_sample\": [\"India\"],\n },\n \"gift_wrap_expense\": {\n \"description\": \"Expense incurred for gift wrapping\",\n \"values_sample\": [5.00],\n },\n \"packaging_expense\": {\n \"description\": \"Expense incurred for packaging\",\n \"values_sample\": [3.00],\n },\n \"handling_expense\": {\n \"description\": \"Expense incurred for handling\",\n \"values_sample\": [2.00],\n },\n \"shipping_expense\": {\n \"description\": \"Expense incurred for shipping\",\n \"values_sample\": [10.00],\n },\n \"marketplace_expense\": {\n \"description\": \"Marketplace fees associated with the order\",\n \"values_sample\": [8.00],\n },\n \"payment_gateway_expense\": {\n \"description\": \"Fees charged by the payment gateway\",\n \"values_sample\": [4.00],\n },\n \"other_adjustments\": {\n \"description\": \"Other adjustments related to the order\",\n \"values_sample\": [2.50],\n },\n \"estimated_expense\": {\n \"description\": \"Estimated total expense for the order\",\n \"values_sample\": [20.00],\n },\n \"sku_cost\": {\n \"description\": \"Cost of the SKU\",\n \"values_sample\": [75.00],\n },\n \"gross_profit\": {\n \"description\": \"Gross profit for the order\",\n \"values_sample\": [50.00],\n },\n \"cm1_expense\": {\n \"description\": \"CM1 (Contribution Margin 1) expense\",\n \"values_sample\": [10.00],\n },\n \"profit_cm1\": {\n \"description\": \"CM1 profit for the order\",\n \"values_sample\": [40.00],\n },\n \"_synced_at\": {\n \"description\": \"Timestamp when the data was last synced\",\n \"values_sample\": [\"2024-02-14 16:30:00.000000\"],\n },\n },\n}\n\n## Guidelines that are necessary to follow for making correct SQL queries:\n1. Whenever working with any text fields, always cast both column and value to lowercase before performing any operations on them.\n2. Chart Type, X-axis and Y-axis will be \"null\" when the question asks for a single value instead of a trend or split.\n3. Ensure numeric typecasting for numerators in division operations.\n4. Use lowercase for string matching to maintain consistency. Note: Do type casting to varchar only if needed (mainly in case of Mssql DB type).\n5. Apply the same operation in both GROUP BY and SELECT clauses when referencing the same field.\n6. Create aliases for fields in SELECT on which operations are applied.\n7. Always prefix field names with table or alias names in joins.\n8. Treat numeric fields as measures and text, enums, and time fields as dimensions in aggregation queries.\n9. Please do not refer the database name in column or table names.\n10. Prevent zero division errors by validating the denominator in division operations.\n11. Exclude null values in aggregations of numeric fields.\n12. Use LOWER in GROUP BY only if the same column in SELECT is also in LOWER.\n13. Please consider the granularity level of the table and do appropriate aggregations.\ne.g.: If order_data table has Order ID - SKU ID columns, and question is asked at order level, group rows by Order ID. Write queries accordingly.\n14. In case time period is not mentioned, use last 12 calendar months data only for calculations, unless lifetime value like questions are asked.\n15. Consider order by ABS value wherever seems logical.\n16. Round the calculations to 2 decimal points at appropriate places, like AVG and Percentages.\n17. Please type-cast the date columns appropriately before making any date based comparisons (only if needed). E.g. for IBM I DB2 ``` to_date(cast(date_column as char(8)),'YYYYMMDD') < current date' ```\n\n## Additional guidelines specific for IBM I DB2:\n18. In case of IBM I DB2 queries do not end with semi-colon ';'\n19. In case of IBM I DB2 syntax to get top x rows is 'FETCH TOP x ROWS ONLY'.\n20. Column names in IBM I DB2 are in upper case and should match in chart dict.\n\n## Response:\n","role":"system"},{"content":"How many new customers did I get in April 2024?","role":"user"},{"content":"SELECT COUNT(DISTINCT customer_id) AS new_customers FROM order_values WHERE order_month = 4 AND order_year = 2024 AND first_ordered_at IS NOT NULL AND DATE_TRUNC('month', first_ordered_at) = '2024-04-01';","role":"assistant"}]}