A capable large language model for natural language to SQL generation.
- Public
- 21.4K runs
-
L40S
- GitHub
Prediction
nateraw/defog-sqlcoder-7b-2:ced935b577fb52644d933f77e2ff8902744e4c58a2f50023b3a1db80b7a75806IDenm65blbgntnxuhsewbxdy2qoqStatusSucceededSourceWebHardwareA40 (Large)Total durationCreatedInput
- top_k
- 50
- top_p
- 0.9
- question
- Do we get more sales from customers in New York compared to customers in San Francisco? Give me the total sales for each city, and the difference between the two.
- temperature
- 0
- max_new_tokens
- 512
- table_metadata
- CREATE TABLE products ( product_id INTEGER PRIMARY KEY, -- Unique ID for each product name VARCHAR(50), -- Name of the product price DECIMAL(10,2), -- Price of each unit of the product quantity INTEGER -- Current quantity in stock ); CREATE TABLE customers ( customer_id INTEGER PRIMARY KEY, -- Unique ID for each customer name VARCHAR(50), -- Name of the customer address VARCHAR(100) -- Mailing address of the customer ); CREATE TABLE salespeople ( salesperson_id INTEGER PRIMARY KEY, -- Unique ID for each salesperson name VARCHAR(50), -- Name of the salesperson region VARCHAR(50) -- Geographic sales region ); CREATE TABLE sales ( sale_id INTEGER PRIMARY KEY, -- Unique ID for each sale product_id INTEGER, -- ID of product sold customer_id INTEGER, -- ID of customer who made purchase salesperson_id INTEGER, -- ID of salesperson who made the sale sale_date DATE, -- Date the sale occurred quantity INTEGER -- Quantity of product sold ); CREATE TABLE product_suppliers ( supplier_id INTEGER PRIMARY KEY, -- Unique ID for each supplier product_id INTEGER, -- Product ID supplied supply_price DECIMAL(10,2) -- Unit price charged by supplier ); -- sales.product_id can be joined with products.product_id -- sales.customer_id can be joined with customers.customer_id -- sales.salesperson_id can be joined with salespeople.salesperson_id -- product_suppliers.product_id can be joined with products.product_id
- prompt_template
- ### Task Generate a SQL query to answer [QUESTION]{question}[/QUESTION] ### Instructions - If you cannot answer the question with the available database schema, return 'I do not know' ### Database Schema The query will run on a database with the following schema: {table_metadata} ### Answer Given the database schema, here is the SQL query that answers [QUESTION]{question}[/QUESTION] [SQL]
- presence_penalty
- 0
- frequency_penalty
- 0
Output
SELECT c.city, SUM(s.quantity) AS total_sales, SUM(CASE WHEN c.city = 'New York' THEN s.quantity ELSE 0 END) - SUM(CASE WHEN c.city = 'San Francisco' THEN s.quantity ELSE 0 END) AS difference_in_sales FROM sales s JOIN customers c ON s.customer_id = c.customer_id GROUP BY c.city ORDER BY total_sales DESC NULLS LAST;Generated in
Want to make some of these yourself?
Run this model