problem stringlengths 550 699 | message_content stringlengths 314 2.35k | message_thinking stringclasses 1
value | gtruth_answer stringlengths 314 2.35k |
|---|---|---|---|
Database schema:
```sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR, email VARCHAR, created_at TIMESTAMP, country VARCHAR);
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR, category VARCHAR, price DECIMAL, stock INT);
CREATE TABLE orders (id INT PRIMARY KEY, user_id INT, created_at TIMESTAMP, total DEC... | ```sql
SELECT u.*
FROM users u
WHERE u.country = 'USA'
AND u.email NOT LIKE '%@spam.com';
```
**Explanation:**
This query addresses the request to "List all {entity} that {condition} but not {other_condition}".
1. **`SELECT u.* FROM users u`**: This selects all columns (`*`) from the `users` table, aliased as `u`... | ```sql
SELECT u.*
FROM users u
WHERE u.country = 'USA'
AND u.email NOT LIKE '%@spam.com';
```
**Explanation:**
This query addresses the request to "List all {entity} that {condition} but not {other_condition}".
1. **`SELECT u.* FROM users u`**: This selects all columns (`*`) from the `users` table, aliased as `u`... | |
Database schema:
```sql
CREATE TABLE patients (id INT PRIMARY KEY, name VARCHAR, dob DATE, gender VARCHAR, insurance_id VARCHAR);
CREATE TABLE doctors (id INT PRIMARY KEY, name VARCHAR, specialty VARCHAR, license_num VARCHAR);
CREATE TABLE appointments (id INT PRIMARY KEY, patient_id INT, doctor_id INT, date TIMESTAMP,... | ```sql
WITH MonthlyPatientActivity AS (
-- Calculate the number of appointments per month for each patient
SELECT
STRFTIME('%Y-%m', date) AS activity_month,
p.id AS patient_id,
COUNT(a.id) AS appointment_count
FROM appointments a
JOIN patients p ON a.patient_id = p.id
GROUP B... | ```sql
WITH MonthlyPatientActivity AS (
-- Calculate the number of appointments per month for each patient
SELECT
STRFTIME('%Y-%m', date) AS activity_month,
p.id AS patient_id,
COUNT(a.id) AS appointment_count
FROM appointments a
JOIN patients p ON a.patient_id = p.id
GROUP B... | |
Database schema:
```sql
CREATE TABLE patients (id INT PRIMARY KEY, name VARCHAR, dob DATE, gender VARCHAR, insurance_id VARCHAR);
CREATE TABLE doctors (id INT PRIMARY KEY, name VARCHAR, specialty VARCHAR, license_num VARCHAR);
CREATE TABLE appointments (id INT PRIMARY KEY, patient_id INT, doctor_id INT, date TIMESTAMP,... | ```sql
SELECT
d.specialty,
AVG(p.days) AS average_prescription_days
FROM
prescriptions p
JOIN
doctors d ON p.doctor_id = d.id
GROUP BY
d.specialty;
```
**Explanation:**
The request asks to calculate the average of a metric for an entity per a dimension. Based on the provided schema and the generic... | ```sql
SELECT
d.specialty,
AVG(p.days) AS average_prescription_days
FROM
prescriptions p
JOIN
doctors d ON p.doctor_id = d.id
GROUP BY
d.specialty;
```
**Explanation:**
The request asks to calculate the average of a metric for an entity per a dimension. Based on the provided schema and the generic... | |
Database schema:
```sql
CREATE TABLE accounts (id INT PRIMARY KEY, name VARCHAR, plan VARCHAR, mrr DECIMAL, created_at TIMESTAMP);
CREATE TABLE users (id INT PRIMARY KEY, account_id INT, email VARCHAR, role VARCHAR, last_login TIMESTAMP);
CREATE TABLE events (id INT PRIMARY KEY, user_id INT, event_type VARCHAR, created... | ```sql
SELECT
a.*
FROM accounts AS a
LEFT JOIN users AS u
ON a.id = u.account_id
LEFT JOIN events AS e
ON u.id = e.user_id
WHERE
e.id IS NULL;
```
**Explanation:**
This query aims to find `accounts` that have never been associated with any recorded `events`.
1. **`FROM accounts AS a`**: We start with the `a... | ```sql
SELECT
a.*
FROM accounts AS a
LEFT JOIN users AS u
ON a.id = u.account_id
LEFT JOIN events AS e
ON u.id = e.user_id
WHERE
e.id IS NULL;
```
**Explanation:**
This query aims to find `accounts` that have never been associated with any recorded `events`.
1. **`FROM accounts AS a`**: We start with the `a... | |
Database schema:
```sql
CREATE TABLE accounts (id INT PRIMARY KEY, name VARCHAR, plan VARCHAR, mrr DECIMAL, created_at TIMESTAMP);
CREATE TABLE users (id INT PRIMARY KEY, account_id INT, email VARCHAR, role VARCHAR, last_login TIMESTAMP);
CREATE TABLE events (id INT PRIMARY KEY, user_id INT, event_type VARCHAR, created... | ```sql
WITH monthly_metrics AS (
SELECT
DATE_TRUNC('month', e.created_at) AS month_start,
COUNT(e.id) AS event_count
FROM events e
GROUP BY 1
)
SELECT
month_start,
event_count,
LAG(event_count, 1, 0) OVER (ORDER BY month_start) AS previous_month_count,
event_count - LAG(event... | ```sql
WITH monthly_metrics AS (
SELECT
DATE_TRUNC('month', e.created_at) AS month_start,
COUNT(e.id) AS event_count
FROM events e
GROUP BY 1
)
SELECT
month_start,
event_count,
LAG(event_count, 1, 0) OVER (ORDER BY month_start) AS previous_month_count,
event_count - LAG(event... | |
Database schema:
```sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR, email VARCHAR, created_at TIMESTAMP, country VARCHAR);
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR, category VARCHAR, price DECIMAL, stock INT);
CREATE TABLE orders (id INT PRIMARY KEY, user_id INT, created_at TIMESTAMP, total DEC... | Please provide the specific entity and condition you are interested in.
For example, you could ask:
* "Find all users who live in 'USA'."
* "Find all products with a price greater than 50.00."
* "Find all orders with the status 'Shipped'."
Once you provide the request, I will generate the appropriate SQL query. | Please provide the specific entity and condition you are interested in.
For example, you could ask:
* "Find all users who live in 'USA'."
* "Find all products with a price greater than 50.00."
* "Find all orders with the status 'Shipped'."
Once you provide the request, I will generate the appropriate SQL query. | |
Database schema:
```sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR, email VARCHAR, created_at TIMESTAMP, country VARCHAR);
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR, category VARCHAR, price DECIMAL, stock INT);
CREATE TABLE orders (id INT PRIMARY KEY, user_id INT, created_at TIMESTAMP, total DEC... | ```sql
SELECT
name,
COUNT(*) AS duplicate_count
FROM
users
GROUP BY
name
HAVING
COUNT(*) > 1;
```
**Explanation:**
This query is designed to find duplicate user names in the `users` table.
1. **`SELECT name, COUNT(*) AS duplicate_count`**: Selects the `name` of the user and counts how many times... | ```sql
SELECT
name,
COUNT(*) AS duplicate_count
FROM
users
GROUP BY
name
HAVING
COUNT(*) > 1;
```
**Explanation:**
This query is designed to find duplicate user names in the `users` table.
1. **`SELECT name, COUNT(*) AS duplicate_count`**: Selects the `name` of the user and counts how many times... | |
Database schema:
```sql
CREATE TABLE patients (id INT PRIMARY KEY, name VARCHAR, dob DATE, gender VARCHAR, insurance_id VARCHAR);
CREATE TABLE doctors (id INT PRIMARY KEY, name VARCHAR, specialty VARCHAR, license_num VARCHAR);
CREATE TABLE appointments (id INT PRIMARY KEY, patient_id INT, doctor_id INT, date TIMESTAMP,... | ```sql
SELECT
patient_id,
COUNT(patient_id) AS duplicate_count
FROM
diagnoses
GROUP BY
patient_id
HAVING
COUNT(patient_id) > 1;
```
**Explanation:**
This query is designed to find duplicate entries based on the `patient_id` in the `diagnoses` table.
1. **`SELECT patient_id, COUNT(patient_id) AS ... | ```sql
SELECT
patient_id,
COUNT(patient_id) AS duplicate_count
FROM
diagnoses
GROUP BY
patient_id
HAVING
COUNT(patient_id) > 1;
```
**Explanation:**
This query is designed to find duplicate entries based on the `patient_id` in the `diagnoses` table.
1. **`SELECT patient_id, COUNT(patient_id) AS ... | |
Database schema:
```sql
CREATE TABLE patients (id INT PRIMARY KEY, name VARCHAR, dob DATE, gender VARCHAR, insurance_id VARCHAR);
CREATE TABLE doctors (id INT PRIMARY KEY, name VARCHAR, specialty VARCHAR, license_num VARCHAR);
CREATE TABLE appointments (id INT PRIMARY KEY, patient_id INT, doctor_id INT, date TIMESTAMP,... | Please provide the specific entity and condition you are interested in.
For example, you could ask:
* "Find all patients who have an appointment scheduled for tomorrow."
* "Find all doctors who specialize in 'Cardiology'."
* "Find all patients who have a diagnosis recorded."
Once you provide the request, I will write... | Please provide the specific entity and condition you are interested in.
For example, you could ask:
* "Find all patients who have an appointment scheduled for tomorrow."
* "Find all doctors who specialize in 'Cardiology'."
* "Find all patients who have a diagnosis recorded."
Once you provide the request, I will write... | |
Database schema:
```sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR, email VARCHAR, created_at TIMESTAMP, country VARCHAR);
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR, category VARCHAR, price DECIMAL, stock INT);
CREATE TABLE orders (id INT PRIMARY KEY, user_id INT, created_at TIMESTAMP, total DEC... | ```sql
SELECT
p.category,
COUNT(o.id) AS order_count
FROM
orders o
JOIN
order_items oi ON o.id = oi.order_id
JOIN
products p ON oi.product_id = p.id
GROUP BY
p.category;
```
**Explanation:**
The request asks to "Count the total number of {entity} grouped by {dimension}". Since the specific ent... | ```sql
SELECT
p.category,
COUNT(o.id) AS order_count
FROM
orders o
JOIN
order_items oi ON o.id = oi.order_id
JOIN
products p ON oi.product_id = p.id
GROUP BY
p.category;
```
**Explanation:**
The request asks to "Count the total number of {entity} grouped by {dimension}". Since the specific ent... | |
Database schema:
```sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR, email VARCHAR, created_at TIMESTAMP, country VARCHAR);
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR, category VARCHAR, price DECIMAL, stock INT);
CREATE TABLE orders (id INT PRIMARY KEY, user_id INT, created_at TIMESTAMP, total DEC... | ```sql
WITH ProductSales AS (
SELECT
p.name AS product_name,
SUM(oi.quantity) AS total_quantity_sold
FROM products p
JOIN order_items oi ON p.id = oi.product_id
GROUP BY p.id, p.name
),
PercentileSales AS (
SELECT
total_quantity_sold,
PERCENTILE_CONT(0.9) WITHIN GROUP... | ```sql
WITH ProductSales AS (
SELECT
p.name AS product_name,
SUM(oi.quantity) AS total_quantity_sold
FROM products p
JOIN order_items oi ON p.id = oi.product_id
GROUP BY p.id, p.name
),
PercentileSales AS (
SELECT
total_quantity_sold,
PERCENTILE_CONT(0.9) WITHIN GROUP... | |
Database schema:
```sql
CREATE TABLE accounts (id INT PRIMARY KEY, name VARCHAR, plan VARCHAR, mrr DECIMAL, created_at TIMESTAMP);
CREATE TABLE users (id INT PRIMARY KEY, account_id INT, email VARCHAR, role VARCHAR, last_login TIMESTAMP);
CREATE TABLE events (id INT PRIMARY KEY, user_id INT, event_type VARCHAR, created... | ```sql
SELECT
a.plan AS dimension,
AVG(s.arr) AS average_arr
FROM
accounts a
JOIN
subscriptions s ON a.id = s.account_id
GROUP BY
a.plan
ORDER BY
average_arr DESC;
```
**Explanation:**
The request asks to "Calculate the average {metric} for {entity} per {dimension}". Based on the provided sche... | ```sql
SELECT
a.plan AS dimension,
AVG(s.arr) AS average_arr
FROM
accounts a
JOIN
subscriptions s ON a.id = s.account_id
GROUP BY
a.plan
ORDER BY
average_arr DESC;
```
**Explanation:**
The request asks to "Calculate the average {metric} for {entity} per {dimension}". Based on the provided sche... | |
Database schema:
```sql
CREATE TABLE accounts (id INT PRIMARY KEY, name VARCHAR, plan VARCHAR, mrr DECIMAL, created_at TIMESTAMP);
CREATE TABLE users (id INT PRIMARY KEY, account_id INT, email VARCHAR, role VARCHAR, last_login TIMESTAMP);
CREATE TABLE events (id INT PRIMARY KEY, user_id INT, event_type VARCHAR, created... | ```sql
WITH UserMRR AS (
-- Calculate the total MRR for each user
SELECT
u.id AS user_id,
SUM(a.mrr) AS total_mrr
FROM users u
JOIN accounts a ON u.account_id = a.id
GROUP BY u.id
),
PercentileMRR AS (
-- Calculate the 90th percentile of the total MRR
SELECT
PERCENTIL... | ```sql
WITH UserMRR AS (
-- Calculate the total MRR for each user
SELECT
u.id AS user_id,
SUM(a.mrr) AS total_mrr
FROM users u
JOIN accounts a ON u.account_id = a.id
GROUP BY u.id
),
PercentileMRR AS (
-- Calculate the 90th percentile of the total MRR
SELECT
PERCENTIL... | |
Database schema:
```sql
CREATE TABLE accounts (id INT PRIMARY KEY, name VARCHAR, plan VARCHAR, mrr DECIMAL, created_at TIMESTAMP);
CREATE TABLE users (id INT PRIMARY KEY, account_id INT, email VARCHAR, role VARCHAR, last_login TIMESTAMP);
CREATE TABLE events (id INT PRIMARY KEY, user_id INT, event_type VARCHAR, created... | ```sql
SELECT
t1.plan,
COUNT(t1.id) AS count
FROM
subscriptions AS t1
GROUP BY
t1.plan;
```
**Explanation:**
The request asks to "Count the total number of {entity} grouped by {dimension}". Since the prompt uses placeholders (`{entity}` and `{dimension}`) without specifying which tables or columns to ... | ```sql
SELECT
t1.plan,
COUNT(t1.id) AS count
FROM
subscriptions AS t1
GROUP BY
t1.plan;
```
**Explanation:**
The request asks to "Count the total number of {entity} grouped by {dimension}". Since the prompt uses placeholders (`{entity}` and `{dimension}`) without specifying which tables or columns to ... | |
Database schema:
```sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR, email VARCHAR, created_at TIMESTAMP, country VARCHAR);
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR, category VARCHAR, price DECIMAL, stock INT);
CREATE TABLE orders (id INT PRIMARY KEY, user_id INT, created_at TIMESTAMP, total DEC... | ```sql
SELECT
p.category,
AVG(p.price) AS average_product_price
FROM
products p
GROUP BY
p.category;
```
**Explanation:**
The request asks to "Calculate the average {metric} for {entity} per {dimension}". Based on the provided schema and the generic template, I have interpreted this as calculating the... | ```sql
SELECT
p.category,
AVG(p.price) AS average_product_price
FROM
products p
GROUP BY
p.category;
```
**Explanation:**
The request asks to "Calculate the average {metric} for {entity} per {dimension}". Based on the provided schema and the generic template, I have interpreted this as calculating the... | |
Database schema:
```sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR, email VARCHAR, created_at TIMESTAMP, country VARCHAR);
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR, category VARCHAR, price DECIMAL, stock INT);
CREATE TABLE orders (id INT PRIMARY KEY, user_id INT, created_at TIMESTAMP, total DEC... | ```sql
SELECT
p.name AS product_name,
SUM(oi.quantity) AS total_quantity_sold
FROM
products p
JOIN
order_items oi ON p.id = oi.product_id
JOIN
orders o ON oi.order_id = o.id
WHERE
o.created_at >= DATETIME('now', '-1 month') -- Example for "last 1 month"
GROUP BY
p.name
ORDER BY
total_qua... | ```sql
SELECT
p.name AS product_name,
SUM(oi.quantity) AS total_quantity_sold
FROM
products p
JOIN
order_items oi ON p.id = oi.product_id
JOIN
orders o ON oi.order_id = o.id
WHERE
o.created_at >= DATETIME('now', '-1 month') -- Example for "last 1 month"
GROUP BY
p.name
ORDER BY
total_qua... | |
Database schema:
```sql
CREATE TABLE patients (id INT PRIMARY KEY, name VARCHAR, dob DATE, gender VARCHAR, insurance_id VARCHAR);
CREATE TABLE doctors (id INT PRIMARY KEY, name VARCHAR, specialty VARCHAR, license_num VARCHAR);
CREATE TABLE appointments (id INT PRIMARY KEY, patient_id INT, doctor_id INT, date TIMESTAMP,... | ```sql
SELECT
T1.dimension,
COUNT(T2.id) AS count
FROM
your_table_name AS T1
JOIN
your_other_table_name AS T2 ON T1.common_column = T2.common_column
GROUP BY
T1.dimension;
```
**Explanation:**
Since the request is a generic template ("Count the total number of {entity} grouped by {dimension}"), I ... | ```sql
SELECT
T1.dimension,
COUNT(T2.id) AS count
FROM
your_table_name AS T1
JOIN
your_other_table_name AS T2 ON T1.common_column = T2.common_column
GROUP BY
T1.dimension;
```
**Explanation:**
Since the request is a generic template ("Count the total number of {entity} grouped by {dimension}"), I ... | |
Database schema:
```sql
CREATE TABLE patients (id INT PRIMARY KEY, name VARCHAR, dob DATE, gender VARCHAR, insurance_id VARCHAR);
CREATE TABLE doctors (id INT PRIMARY KEY, name VARCHAR, specialty VARCHAR, license_num VARCHAR);
CREATE TABLE appointments (id INT PRIMARY KEY, patient_id INT, doctor_id INT, date TIMESTAMP,... | ```sql
SELECT
p.name
FROM patients AS p
WHERE
p.insurance_id IS NOT NULL -- Example condition 1: Has an insurance ID
AND p.gender != 'Male' -- Example condition 2: Is not male
AND p.insurance_id != 'INS001'; -- Example condition 3: Does not have a specific insurance ID
```
**Explanation:**
Since the natura... | ```sql
SELECT
p.name
FROM patients AS p
WHERE
p.insurance_id IS NOT NULL -- Example condition 1: Has an insurance ID
AND p.gender != 'Male' -- Example condition 2: Is not male
AND p.insurance_id != 'INS001'; -- Example condition 3: Does not have a specific insurance ID
```
**Explanation:**
Since the natura... | |
Database schema:
```sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR, email VARCHAR, created_at TIMESTAMP, country VARCHAR);
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR, category VARCHAR, price DECIMAL, stock INT);
CREATE TABLE orders (id INT PRIMARY KEY, user_id INT, created_at TIMESTAMP, total DEC... | ```sql
SELECT u.*
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE o.id IS NULL;
```
**Explanation:**
This query aims to find all users who have never placed an order.
1. **`SELECT u.* FROM users u`**: Selects all columns from the `users` table, aliased as `u`.
2. **`LEFT JOIN orders o ON u.id = o.user_id... | ```sql
SELECT u.*
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE o.id IS NULL;
```
**Explanation:**
This query aims to find all users who have never placed an order.
1. **`SELECT u.* FROM users u`**: Selects all columns from the `users` table, aliased as `u`.
2. **`LEFT JOIN orders o ON u.id = o.user_id... | |
Database schema:
```sql
CREATE TABLE patients (id INT PRIMARY KEY, name VARCHAR, dob DATE, gender VARCHAR, insurance_id VARCHAR);
CREATE TABLE doctors (id INT PRIMARY KEY, name VARCHAR, specialty VARCHAR, license_num VARCHAR);
CREATE TABLE appointments (id INT PRIMARY KEY, patient_id INT, doctor_id INT, date TIMESTAMP,... | ```sql
-- Find patients that have never had a diagnosis
SELECT p.*
FROM patients p
LEFT JOIN diagnoses d ON p.id = d.patient_id
WHERE d.patient_id IS NULL;
```
**Explanation:**
1. **`SELECT p.* FROM patients p`**: This selects all columns from the `patients` table, aliased as `p`.
2. **`LEFT JOIN diagnoses d ON p.i... | ```sql
-- Find patients that have never had a diagnosis
SELECT p.*
FROM patients p
LEFT JOIN diagnoses d ON p.id = d.patient_id
WHERE d.patient_id IS NULL;
```
**Explanation:**
1. **`SELECT p.* FROM patients p`**: This selects all columns from the `patients` table, aliased as `p`.
2. **`LEFT JOIN diagnoses d ON p.i... | |
Database schema:
```sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR, email VARCHAR, created_at TIMESTAMP, country VARCHAR);
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR, category VARCHAR, price DECIMAL, stock INT);
CREATE TABLE orders (id INT PRIMARY KEY, user_id INT, created_at TIMESTAMP, total DEC... | ```sql
WITH MonthlySales AS (
SELECT
STRFTIME('%Y-%m', o.created_at) AS sales_month,
SUM(oi.quantity * oi.unit_price) AS monthly_sales
FROM orders o
JOIN order_items oi ON o.id = oi.order_id
GROUP BY 1
)
SELECT
sales_month,
monthly_sales,
LAG(monthly_sales, 1, 0) OVER (ORDER ... | ```sql
WITH MonthlySales AS (
SELECT
STRFTIME('%Y-%m', o.created_at) AS sales_month,
SUM(oi.quantity * oi.unit_price) AS monthly_sales
FROM orders o
JOIN order_items oi ON o.id = oi.order_id
GROUP BY 1
)
SELECT
sales_month,
monthly_sales,
LAG(monthly_sales, 1, 0) OVER (ORDER ... | |
Database schema:
```sql
CREATE TABLE patients (id INT PRIMARY KEY, name VARCHAR, dob DATE, gender VARCHAR, insurance_id VARCHAR);
CREATE TABLE doctors (id INT PRIMARY KEY, name VARCHAR, specialty VARCHAR, license_num VARCHAR);
CREATE TABLE appointments (id INT PRIMARY KEY, patient_id INT, doctor_id INT, date TIMESTAMP,... | ```sql
SELECT
p.name AS patient_name,
COUNT(a.id) AS appointment_count
FROM
patients p
JOIN
appointments a ON p.id = a.patient_id
WHERE
a.date >= datetime('now', '-30 days') -- Example for "last 30 days"
GROUP BY
p.name
ORDER BY
appointment_count DESC
LIMIT 10;
```
**Explanation:**
Since t... | ```sql
SELECT
p.name AS patient_name,
COUNT(a.id) AS appointment_count
FROM
patients p
JOIN
appointments a ON p.id = a.patient_id
WHERE
a.date >= datetime('now', '-30 days') -- Example for "last 30 days"
GROUP BY
p.name
ORDER BY
appointment_count DESC
LIMIT 10;
```
**Explanation:**
Since t... | |
Database schema:
```sql
CREATE TABLE accounts (id INT PRIMARY KEY, name VARCHAR, plan VARCHAR, mrr DECIMAL, created_at TIMESTAMP);
CREATE TABLE users (id INT PRIMARY KEY, account_id INT, email VARCHAR, role VARCHAR, last_login TIMESTAMP);
CREATE TABLE events (id INT PRIMARY KEY, user_id INT, event_type VARCHAR, created... | ```sql
SELECT
t1.name,
COUNT(t1.id) AS duplicate_count
FROM
accounts t1
GROUP BY
t1.name
HAVING
COUNT(t1.id) > 1;
```
**Explanation:**
This query is designed to find duplicate entries in the `accounts` table based on the `name` field.
1. **`SELECT t1.name, COUNT(t1.id) AS duplicate_count`**: Sel... | ```sql
SELECT
t1.name,
COUNT(t1.id) AS duplicate_count
FROM
accounts t1
GROUP BY
t1.name
HAVING
COUNT(t1.id) > 1;
```
**Explanation:**
This query is designed to find duplicate entries in the `accounts` table based on the `name` field.
1. **`SELECT t1.name, COUNT(t1.id) AS duplicate_count`**: Sel... | |
Database schema:
```sql
CREATE TABLE patients (id INT PRIMARY KEY, name VARCHAR, dob DATE, gender VARCHAR, insurance_id VARCHAR);
CREATE TABLE doctors (id INT PRIMARY KEY, name VARCHAR, specialty VARCHAR, license_num VARCHAR);
CREATE TABLE appointments (id INT PRIMARY KEY, patient_id INT, doctor_id INT, date TIMESTAMP,... | ```sql
SELECT
d.name AS doctor_name,
COUNT(a.id) AS appointment_count
FROM
doctors d
JOIN
appointments a ON d.id = a.doctor_id
GROUP BY
d.id, d.name
ORDER BY
appointment_count DESC;
```
**Explanation:**
The request asks to "Get the {ranking} {entity} for each {dimension}". Based on the provide... | ```sql
SELECT
d.name AS doctor_name,
COUNT(a.id) AS appointment_count
FROM
doctors d
JOIN
appointments a ON d.id = a.doctor_id
GROUP BY
d.id, d.name
ORDER BY
appointment_count DESC;
```
**Explanation:**
The request asks to "Get the {ranking} {entity} for each {dimension}". Based on the provide... | |
Database schema:
```sql
CREATE TABLE accounts (id INT PRIMARY KEY, name VARCHAR, plan VARCHAR, mrr DECIMAL, created_at TIMESTAMP);
CREATE TABLE users (id INT PRIMARY KEY, account_id INT, email VARCHAR, role VARCHAR, last_login TIMESTAMP);
CREATE TABLE events (id INT PRIMARY KEY, user_id INT, event_type VARCHAR, created... | ```sql
WITH recent_activity AS (
SELECT
a.name AS account_name,
SUM(s.arr) AS total_arr
FROM accounts a
JOIN subscriptions s ON a.id = s.account_id
-- Assuming "last {period}" implies activity within the last 30 days for this example
WHERE s.end_date >= CURRENT_DATE - INTERVAL '30 da... | ```sql
WITH recent_activity AS (
SELECT
a.name AS account_name,
SUM(s.arr) AS total_arr
FROM accounts a
JOIN subscriptions s ON a.id = s.account_id
-- Assuming "last {period}" implies activity within the last 30 days for this example
WHERE s.end_date >= CURRENT_DATE - INTERVAL '30 da... | |
Database schema:
```sql
CREATE TABLE patients (id INT PRIMARY KEY, name VARCHAR, dob DATE, gender VARCHAR, insurance_id VARCHAR);
CREATE TABLE doctors (id INT PRIMARY KEY, name VARCHAR, specialty VARCHAR, license_num VARCHAR);
CREATE TABLE appointments (id INT PRIMARY KEY, patient_id INT, doctor_id INT, date TIMESTAMP,... | ```sql
WITH PatientMetrics AS (
SELECT
p.name AS entity,
COUNT(a.id) AS appointment_count
FROM patients p
JOIN appointments a ON p.id = a.patient_id
GROUP BY p.id, p.name
),
PercentileCalculation AS (
SELECT
entity,
appointment_count,
PERCENTILE_CONT(0.9) WITH... | ```sql
WITH PatientMetrics AS (
SELECT
p.name AS entity,
COUNT(a.id) AS appointment_count
FROM patients p
JOIN appointments a ON p.id = a.patient_id
GROUP BY p.id, p.name
),
PercentileCalculation AS (
SELECT
entity,
appointment_count,
PERCENTILE_CONT(0.9) WITH... | |
Database schema:
```sql
CREATE TABLE accounts (id INT PRIMARY KEY, name VARCHAR, plan VARCHAR, mrr DECIMAL, created_at TIMESTAMP);
CREATE TABLE users (id INT PRIMARY KEY, account_id INT, email VARCHAR, role VARCHAR, last_login TIMESTAMP);
CREATE TABLE events (id INT PRIMARY KEY, user_id INT, event_type VARCHAR, created... | ```sql
WITH UserAccountMetrics AS (
-- Calculate the total MRR for each account
SELECT
a.id AS account_id,
a.name AS account_name,
a.plan AS account_plan,
SUM(a.mrr) AS total_mrr
FROM
accounts a
GROUP BY
a.id, a.name, a.plan
)
SELECT
u.email,
u.rol... | ```sql
WITH UserAccountMetrics AS (
-- Calculate the total MRR for each account
SELECT
a.id AS account_id,
a.name AS account_name,
a.plan AS account_plan,
SUM(a.mrr) AS total_mrr
FROM
accounts a
GROUP BY
a.id, a.name, a.plan
)
SELECT
u.email,
u.rol... | |
Database schema:
```sql
CREATE TABLE accounts (id INT PRIMARY KEY, name VARCHAR, plan VARCHAR, mrr DECIMAL, created_at TIMESTAMP);
CREATE TABLE users (id INT PRIMARY KEY, account_id INT, email VARCHAR, role VARCHAR, last_login TIMESTAMP);
CREATE TABLE events (id INT PRIMARY KEY, user_id INT, event_type VARCHAR, created... | Please provide the specific entity and condition you are interested in.
For example, you could ask:
* "Find all users who have the role 'admin'."
* "Find all accounts with an MRR greater than 1000."
* "Find all subscriptions that are currently active."
Once you provide the request, I will write the appropriate SQL qu... | Please provide the specific entity and condition you are interested in.
For example, you could ask:
* "Find all users who have the role 'admin'."
* "Find all accounts with an MRR greater than 1000."
* "Find all subscriptions that are currently active."
Once you provide the request, I will write the appropriate SQL qu... |
DuoNeural SQL in SQL-SFT-V1 format
Source: DuoNeural/Gemma4-E2B-SFT-SQL, revision a634a858fa73e842092a936559627a5206d57779. The source dataset card declares the Gemma license. See the source dataset card and Gemma terms and model-specific licenses.
This conversion maps the user and assistant turns to four SFT fields. It keeps one row per normalized prompt, preferring the higher source quality score. Ties retain the first row. Train and eval use a seeded 95/5 split of those prompts.
- Source rows: 7560
- Train rows: 28
- Eval rows: 2
- Repeated prompts removed: 7530
The targets are synthetic and have not been executed against a database. gtruth_answer mirrors message_content for loader compatibility. message_thinking is populated only when an explicit think block is present. The data is English text-to-SQL. The pajak filenames match the existing loader.
- Downloads last month
- 11