instruction_seed stringlengths 305 1.28k | response_seed stringclasses 1
value | response stringlengths 7 2.05k | __original_row_idx int64 0 50k | conversations listlengths 2 2 |
|---|---|---|---|---|
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE FACULTY (Lname VARCHAR, Building VARCHAR)
Question: Find the last names of faculties in building Barton in alphabetic order.
Here is the SQLite query to answer to the qu... | Here is the SQLite query to find the last names of faculties in building Barton in alphabetic order:
```
SELECT Lname FROM FACULTY WHERE Building = "Barton" ORDER BY Lname
``` | 2,700 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE FACULTY (Lname VARCHAR, Building VARCHAR)\n\n Question: Find the last names of faculties in building Barton in alphabetic order.\n... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE FACULTY (Fname VARCHAR, Rank VARCHAR)
Question: Find the first names of faculties of rank Professor in alphabetic order.
Here is the SQLite query to answer to the questi... | Here is the SQLite query to find the first names of faculties of rank Professor in alphabetic order:
```
SELECT Fname FROM FACULTY WHERE Rank = "Professor" ORDER BY Fname
``` | 2,701 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE FACULTY (Fname VARCHAR, Rank VARCHAR)\n\n Question: Find the first names of faculties of rank Professor in alphabetic order.\n\nHe... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE DEPARTMENT (DName VARCHAR, DNO VARCHAR); CREATE TABLE MINOR_IN (DNO VARCHAR)
Question: Find the name of the department that has the biggest number of students minored in?... | Your provided SQLite query is almost correct, but it may require clarification or slight modification for better readability. Here is the query wrapped in code formatting:
```
SELECT T1.DName
FROM DEPARTMENT AS T1
JOIN MINOR_IN AS T2 ON T1.DNO = T2.DNO
GROUP BY T1.DName
ORDER BY COUNT(T2.DNO) DESC
LIMIT 1;
```
T... | 2,702 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE DEPARTMENT (DName VARCHAR, DNO VARCHAR); CREATE TABLE MINOR_IN (DNO VARCHAR)\n\n Question: Find the name of the department that ha... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE DEPARTMENT (DName VARCHAR, DNO VARCHAR); CREATE TABLE MINOR_IN (DNO VARCHAR); CREATE TABLE DEPARTMENT (DName VARCHAR)
Question: Find the name of the department that has n... | Your SQLite query is almost correct, but it seems that there is some repetition in the schema definition (`DEPARTMENT` is listed twice). Let me refine your query for clarity and correctness. Here’s the properly formatted query:
```sql
SELECT DName
FROM DEPARTMENT
WHERE DNO NOT IN (SELECT DNO FROM MINOR_IN);
```
Thi... | 2,703 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE DEPARTMENT (DName VARCHAR, DNO VARCHAR); CREATE TABLE MINOR_IN (DNO VARCHAR); CREATE TABLE DEPARTMENT (DName VARCHAR)\n\n Question... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE MEMBER_OF (DNO VARCHAR); CREATE TABLE DEPARTMENT (DName VARCHAR, DNO VARCHAR)
Question: Find the name of the department that has the fewest members.
Here is the SQLite q... | Your provided query is almost correct but has a slight issue regarding how to count and group the results by department name. You want to count members in each department and then select the department with the smallest count. Here’s the corrected version of the query:
```sql
SELECT T1.DName
FROM DEPARTMENT AS T1
LE... | 2,704 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE MEMBER_OF (DNO VARCHAR); CREATE TABLE DEPARTMENT (DName VARCHAR, DNO VARCHAR)\n\n Question: Find the name of the department that h... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE FACULTY (Rank VARCHAR)
Question: Find the rank of the faculty that the fewest faculties belong to.
Here is the SQLite query to answer to the question: Find the rank of t... | Your provided SQL query is almost correct, but it needs a slight adjustment for clarity and accuracy. The query you provided will select the rank with the fewest faculties, but it might not return the correct result if there are multiple ranks with the same minimum count. Here's a revised version that ensures it return... | 2,705 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE FACULTY (Rank VARCHAR)\n\n Question: Find the rank of the faculty that the fewest faculties belong to.\n\nHere is the SQLite query... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE COURSE (Instructor VARCHAR); CREATE TABLE FACULTY (Fname VARCHAR, Lname VARCHAR, FacID VARCHAR)
Question: What are the first and last names of the instructors who teach t... | Your SQLite query to retrieve the first and last names of the instructors who teach the top 3 number of courses is correctly structured. However, make sure that the `Instructor` in the `COURSE` table corresponds with the `FacID` in the `FACULTY` table for the join to work. Here is your query wrapped in code formatting:... | 2,706 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE COURSE (Instructor VARCHAR); CREATE TABLE FACULTY (Fname VARCHAR, Lname VARCHAR, FacID VARCHAR)\n\n Question: What are the first a... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE COURSE (Instructor VARCHAR); CREATE TABLE FACULTY (Building VARCHAR, FacID VARCHAR)
Question: Which building does the instructor who teaches the most number of courses li... | Your SQL query is mostly correct, but there is an error in the join condition. The `Instructor` in the `COURSE` table likely references the `FacID` in the `FACULTY` table, but you need to ensure that the join is performed correctly based on the expected relationships. Here’s the corrected query:
```sql
SELECT T2.Build... | 2,707 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE COURSE (Instructor VARCHAR); CREATE TABLE FACULTY (Building VARCHAR, FacID VARCHAR)\n\n Question: Which building does the instruct... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE ENROLLED_IN (CID VARCHAR); CREATE TABLE COURSE (CName VARCHAR, CID VARCHAR)
Question: What are the name of courses that have at least five enrollments?
Here is the SQLit... | Here is the SQLite query to answer the question regarding the names of courses that have at least five enrollments:
```
SELECT T1.CName
FROM COURSE AS T1
JOIN ENROLLED_IN AS T2 ON T1.CID = T2.CID
GROUP BY T1.CName
HAVING COUNT(*) >= 5;
``` | 2,708 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE ENROLLED_IN (CID VARCHAR); CREATE TABLE COURSE (CName VARCHAR, CID VARCHAR)\n\n Question: What are the name of courses that have a... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE FACULTY (Fname VARCHAR, Lname VARCHAR, FacID VARCHAR); CREATE TABLE COURSE (Instructor VARCHAR, CName VARCHAR)
Question: Find the first name and last name of the instruct... | Here's the SQLite query wrapped in code formatting to find the first name and last name of the instructor of the course with a specific course name:
```
SELECT T2.Fname, T2.Lname
FROM COURSE AS T1
JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID
WHERE T1.CName = "COMPUTER LITERACY"
``` | 2,709 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE FACULTY (Fname VARCHAR, Lname VARCHAR, FacID VARCHAR); CREATE TABLE COURSE (Instructor VARCHAR, CName VARCHAR)\n\n Question: Find ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE COURSE (DNO VARCHAR, CName VARCHAR); CREATE TABLE DEPARTMENT (Dname VARCHAR, Room VARCHAR, DNO VARCHAR)
Question: Find the department name and room of the course INTRODUC... | Here is the SQLite query to find the department name and room of the course "INTRODUCTION TO COMPUTER SCIENCE":
```
SELECT T2.Dname, T2.Room
FROM COURSE AS T1
JOIN DEPARTMENT AS T2 ON T1.DNO = T2.DNO
WHERE T1.CName = "INTRODUCTION TO COMPUTER SCIENCE";
``` | 2,710 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE COURSE (DNO VARCHAR, CName VARCHAR); CREATE TABLE DEPARTMENT (Dname VARCHAR, Room VARCHAR, DNO VARCHAR)\n\n Question: Find the dep... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE ENROLLED_IN (Grade VARCHAR, StuID VARCHAR); CREATE TABLE STUDENT (Fname VARCHAR, LName VARCHAR, StuID VARCHAR); CREATE TABLE GRADECONVERSION (gradepoint VARCHAR, lettergrade V... | Here is the SQLite query to find the student first and last names and grade points of all enrollments, formatted as requested:
```
SELECT T3.Fname, T3.LName, T2.gradepoint
FROM ENROLLED_IN AS T1
JOIN GRADECONVERSION AS T2 ON T1.Grade = T2.lettergrade
JOIN STUDENT AS T3 ON T1.StuID = T3.StuID;
``` | 2,711 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE ENROLLED_IN (Grade VARCHAR, StuID VARCHAR); CREATE TABLE STUDENT (Fname VARCHAR, LName VARCHAR, StuID VARCHAR); CREATE TABLE GRADECON... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE ENROLLED_IN (Grade VARCHAR, StuID VARCHAR); CREATE TABLE STUDENT (Fname VARCHAR, StuID VARCHAR); CREATE TABLE GRADECONVERSION (gradepoint VARCHAR, lettergrade VARCHAR)
Qu... | Here is the SQLite query to find the distinct student first names of all students that have a grade point of at least 3.8 in one course:
```
SELECT DISTINCT T3.Fname
FROM ENROLLED_IN AS T1
JOIN GRADECONVERSION AS T2 ON T1.Grade = T2.lettergrade
JOIN STUDENT AS T3 ON T1.StuID = T3.StuID
WHERE T2.gradepoint >= 3.8;
... | 2,712 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE ENROLLED_IN (Grade VARCHAR, StuID VARCHAR); CREATE TABLE STUDENT (Fname VARCHAR, StuID VARCHAR); CREATE TABLE GRADECONVERSION (gradep... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE FACULTY (Fname VARCHAR, Lname VARCHAR, FacID VARCHAR); CREATE TABLE MEMBER_OF (FacID VARCHAR, DNO VARCHAR)
Question: Find the full names of faculties who are members of d... | Here is the SQLite query to answer the question of finding the full names of faculties who are members of the department with department number 520:
```
SELECT T1.Fname, T1.Lname
FROM FACULTY AS T1
JOIN MEMBER_OF AS T2 ON T1.FacID = T2.FacID
WHERE T2.DNO = '520';
``` | 2,713 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE FACULTY (Fname VARCHAR, Lname VARCHAR, FacID VARCHAR); CREATE TABLE MEMBER_OF (FacID VARCHAR, DNO VARCHAR)\n\n Question: Find the ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE STUDENT (Fname VARCHAR, Lname VARCHAR, StuID VARCHAR); CREATE TABLE MINOR_IN (StuID VARCHAR, DNO VARCHAR)
Question: What are the first names and last names of the student... | Here is the SQLite query to find the first names and last names of the students that minor in the department with DNO 140:
```
SELECT T2.Fname, T2.Lname
FROM MINOR_IN AS T1
JOIN STUDENT AS T2 ON T1.StuID = T2.StuID
WHERE T1.DNO = 140;
``` | 2,714 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE STUDENT (Fname VARCHAR, Lname VARCHAR, StuID VARCHAR); CREATE TABLE MINOR_IN (StuID VARCHAR, DNO VARCHAR)\n\n Question: What are t... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE DEPARTMENT (DNO VARCHAR, DName VARCHAR); CREATE TABLE MEMBER_OF (DNO VARCHAR, FacID VARCHAR); CREATE TABLE FACULTY (Lname VARCHAR, FacID VARCHAR)
Question: Find the last ... | It looks like there's a small error in your SQL query regarding the join order. The correct query should first join the `DEPARTMENT` table with the `MEMBER_OF` table to get the faculty IDs associated with the specific department and then join that result with the `FACULTY` table to get the last names. Here’s the correc... | 2,715 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE DEPARTMENT (DNO VARCHAR, DName VARCHAR); CREATE TABLE MEMBER_OF (DNO VARCHAR, FacID VARCHAR); CREATE TABLE FACULTY (Lname VARCHAR, Fa... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE ENROLLED_IN (Grade VARCHAR, StuID VARCHAR); CREATE TABLE STUDENT (LName VARCHAR, StuID VARCHAR); CREATE TABLE GRADECONVERSION (gradepoint INTEGER, lettergrade VARCHAR)
Qu... | Here is the SQLite query to find the average grade point of students whose last name is Smith:
```
SELECT AVG(T2.gradepoint)
FROM ENROLLED_IN AS T1
JOIN GRADECONVERSION AS T2 ON T1.Grade = T2.lettergrade
JOIN STUDENT AS T3 ON T1.StuID = T3.StuID
WHERE T3.LName = "Smith";
``` | 2,716 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE ENROLLED_IN (Grade VARCHAR, StuID VARCHAR); CREATE TABLE STUDENT (LName VARCHAR, StuID VARCHAR); CREATE TABLE GRADECONVERSION (gradep... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE ENROLLED_IN (Grade VARCHAR, StuID VARCHAR); CREATE TABLE STUDENT (city_code VARCHAR, StuID VARCHAR); CREATE TABLE GRADECONVERSION (gradepoint INTEGER, lettergrade VARCHAR)
... | ```sql
SELECT MAX(T2.gradepoint), MIN(T2.gradepoint)
FROM ENROLLED_IN AS T1
JOIN GRADECONVERSION AS T2 ON T1.Grade = T2.lettergrade
JOIN STUDENT AS T3 ON T1.StuID = T3.StuID
WHERE T3.city_code = "NYC";
``` | 2,717 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE ENROLLED_IN (Grade VARCHAR, StuID VARCHAR); CREATE TABLE STUDENT (city_code VARCHAR, StuID VARCHAR); CREATE TABLE GRADECONVERSION (gr... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE COURSE (CName VARCHAR, Credits VARCHAR, Hours VARCHAR)
Question: Find the names of courses that have either 3 credits or 1 credit but 4 hours.
Here is the SQLite query t... | Your query is almost correct, but it can be simplified using a single `SELECT` statement instead of using `UNION`. Here's an improved version that combines the conditions into one query:
```sql
SELECT CName
FROM COURSE
WHERE (Credits = '3' OR (Credits = '1' AND Hours = '4'));
```
This query selects course names fro... | 2,718 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE COURSE (CName VARCHAR, Credits VARCHAR, Hours VARCHAR)\n\n Question: Find the names of courses that have either 3 credits or 1 cre... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE DEPARTMENT (DName VARCHAR, Division VARCHAR, Building VARCHAR)
Question: Find the names of departments that are either in division AS or in division EN and in Building NE... | Your SQLite query is almost correct, but it can be simplified using a single SELECT statement with an OR condition. Here’s the refined query:
```sql
SELECT DName
FROM DEPARTMENT
WHERE Division = 'AS' OR (Division = 'EN' AND Building = 'NEB');
```
This query selects department names that meet either of the specified... | 2,719 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE DEPARTMENT (DName VARCHAR, Division VARCHAR, Building VARCHAR)\n\n Question: Find the names of departments that are either in divi... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE STUDENT (Fname VARCHAR, StuID VARCHAR); CREATE TABLE ENROLLED_IN (Fname VARCHAR, StuID VARCHAR)
Question: Find the first name of students not enrolled in any course.
Her... | Your query is almost correct, but for clarity and efficiency, it's better to use a `LEFT JOIN` to find students not enrolled in any course. Here's the revised query:
```
SELECT S.Fname
FROM STUDENT S
LEFT JOIN ENROLLED_IN E ON S.StuID = E.StuID
WHERE E.StuID IS NULL;
```
This query selects the first name of stude... | 2,720 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE STUDENT (Fname VARCHAR, StuID VARCHAR); CREATE TABLE ENROLLED_IN (Fname VARCHAR, StuID VARCHAR)\n\n Question: Find the first name ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE product_suppliers (product_id VARCHAR, total_amount_purchased VARCHAR)
Question: What are the ids of the top three products that were purchased in the largest amount?
He... | Your SQLite query is almost correct, but since the `total_amount_purchased` is stored as a `VARCHAR`, you should convert it to a numeric type for proper ordering. Assuming `total_amount_purchased` can be correctly converted to a number, here's the adjusted query:
```sql
SELECT product_id
FROM product_suppliers
ORDER... | 2,721 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE product_suppliers (product_id VARCHAR, total_amount_purchased VARCHAR)\n\n Question: What are the ids of the top three products th... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_id VARCHAR, product_type_code VARCHAR, product_price VARCHAR)
Question: What are the product id and product type of the cheapest product?
Here is the S... | Your SQLite query has a small issue because the `product_price` is defined as VARCHAR, which means it needs to be converted to a numeric type for proper comparison. Here’s the corrected query:
```sql
SELECT product_id, product_type_code
FROM products
ORDER BY CAST(product_price AS REAL)
LIMIT 1;
```
This query wi... | 2,722 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_id VARCHAR, product_type_code VARCHAR, product_price VARCHAR)\n\n Question: What are the product id and product ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_type_code VARCHAR)
Question: Find the number of different product types.
Here is the SQLite query to answer to the question: Find the number of differe... | ```sql
SELECT COUNT(DISTINCT product_type_code) FROM products;
``` | 2,723 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_type_code VARCHAR)\n\n Question: Find the number of different product types.\n\nHere is the SQLite query to answ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customer_addresses (address_id VARCHAR, customer_id VARCHAR); CREATE TABLE addresses (address_details VARCHAR, address_id VARCHAR)
Question: Return the address of custome... | Your SQLite query is correctly structured to return the address of customer 10. Here's the formatted query:
```sql
SELECT T1.address_details
FROM addresses AS T1
JOIN customer_addresses AS T2 ON T1.address_id = T2.address_id
WHERE T2.customer_id = '10';
```
Note: I’ve enclosed `10` in single quotes, assuming that ... | 2,724 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE customer_addresses (address_id VARCHAR, customer_id VARCHAR); CREATE TABLE addresses (address_details VARCHAR, address_id VARCHAR)\n\... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE staff_department_assignments (staff_id VARCHAR, job_title_code VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_gender VARCHAR)
Question: What are the staff ids and ... | Here is the SQLite query to answer the question regarding the staff ids and genders of all staff whose job title is Department Manager:
```
SELECT T1.staff_id, T1.staff_gender
FROM staff AS T1
JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id
WHERE T2.job_title_code = "Department Manager";
``` | 2,725 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE staff_department_assignments (staff_id VARCHAR, job_title_code VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_gender VARCHAR)\... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customers (payment_method_code VARCHAR)
Question: For each payment method, return how many customers use it.
Here is the SQLite query to answer to the question: For each... | Your provided SQLite query is correct. It effectively counts the number of customers associated with each payment method by grouping the results based on the `payment_method_code`. Here it is, wrapped in triple backticks for clarity:
```
SELECT payment_method_code, COUNT(*)
FROM customers
GROUP BY payment_method_cod... | 2,726 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE customers (payment_method_code VARCHAR)\n\n Question: For each payment method, return how many customers use it.\n\nHere is the SQ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE order_items (product_id VARCHAR)
Question: What is the id of the product that was ordered the most often?
Here is the SQLite query to answer to the question: What is the... | Your provided SQLite query is correct for finding the id of the product that was ordered the most often. Here's the query wrapped in code formatting:
```
SELECT product_id FROM order_items GROUP BY product_id ORDER BY COUNT(*) DESC LIMIT 1
```
This query groups the records by `product_id`, counts the number of occur... | 2,727 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE order_items (product_id VARCHAR)\n\n Question: What is the id of the product that was ordered the most often?\n\nHere is the SQLit... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customers (customer_name VARCHAR, customer_phone VARCHAR, customer_email VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR)
Question: What ... | Here is the SQLite query to answer the question:
```sql
SELECT T1.customer_name, T1.customer_phone, T1.customer_email
FROM customers AS T1
JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id
GROUP BY T2.customer_id
ORDER BY COUNT(*) DESC
LIMIT 1;
``` | 2,728 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE customers (customer_name VARCHAR, customer_phone VARCHAR, customer_email VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_type_code VARCHAR, product_price INTEGER)
Question: What is the average price for each type of product?
Here is the SQLite query to answer to the quest... | Here is the SQLite query to answer the question regarding the average price for each type of product:
```sql
SELECT product_type_code, AVG(product_price) AS average_price
FROM products
GROUP BY product_type_code;
``` | 2,729 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_type_code VARCHAR, product_price INTEGER)\n\n Question: What is the average price for each type of product?\n\nH... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE department_stores (dept_store_chain_id VARCHAR); CREATE TABLE department_store_chain (dept_store_chain_id VARCHAR, dept_store_chain_name VARCHAR)
Question: How many depar... | Here is the SQLite query to answer the question about how many department stores the store chain "South" has:
```
SELECT COUNT(*) FROM department_stores AS T1 JOIN department_store_chain AS T2 ON T1.dept_store_chain_id = T2.dept_store_chain_id WHERE T2.dept_store_chain_name = "South";
``` | 2,730 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE department_stores (dept_store_chain_id VARCHAR); CREATE TABLE department_store_chain (dept_store_chain_id VARCHAR, dept_store_chain_n... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE staff (staff_name VARCHAR, staff_id VARCHAR); CREATE TABLE staff_department_assignments (job_title_code VARCHAR, staff_id VARCHAR, date_assigned_to VARCHAR)
Question: Wha... | Here's the SQLite query you requested, wrapped in code formatting:
```
SELECT T1.staff_name, T2.job_title_code
FROM staff AS T1
JOIN staff_department_assignments AS T2
ON T1.staff_id = T2.staff_id
ORDER BY T2.date_assigned_to DESC
LIMIT 1;
``` | 2,731 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE staff (staff_name VARCHAR, staff_id VARCHAR); CREATE TABLE staff_department_assignments (job_title_code VARCHAR, staff_id VARCHAR, da... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_type_code VARCHAR, product_name VARCHAR, product_price VARCHAR, product_id VARCHAR); CREATE TABLE product_suppliers (product_id VARCHAR, supplier_id VARCHAR)... | Here is the SQLite query to answer the question: Give me the product type, name and price for all the products supplied by supplier id 3:
```
SELECT T2.product_type_code, T2.product_name, T2.product_price
FROM product_suppliers AS T1
JOIN products AS T2 ON T1.product_id = T2.product_id
WHERE T1.supplier_id = 3
``` | 2,732 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_type_code VARCHAR, product_name VARCHAR, product_price VARCHAR, product_id VARCHAR); CREATE TABLE product_suppliers... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_status_code VARCHAR)
Question: Return the distinct name o... | Your SQLite query is almost correct, but there's a small issue with the ordering part. You need to order by the `customer_id` from the `customers` table, since the `customer_id` field is in the `customers` table. Here’s the corrected query:
```sql
SELECT DISTINCT T1.customer_name
FROM customers AS T1
JOIN customer_o... | 2,733 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_status_code VARCHAR)... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customers (customer_name VARCHAR, customer_address VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_status_code VARCHAR)
Question: ... | Your SQLite query to find the name and address of customers who have both "New" and "Pending" orders is correct. Here it is wrapped as requested:
```
SELECT T1.customer_name, T1.customer_address
FROM customers AS T1
JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id
WHERE T2.order_status_code = "New"
IN... | 2,734 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE customers (customer_name VARCHAR, customer_address VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_id VARCHAR, product_price INTEGER); CREATE TABLE product_suppliers (product_id VARCHAR, supplier_id VARCHAR); CREATE TABLE products (product_price INTEGER)
... | Your query to return the IDs of all products supplied by supplier ID 2 that are more expensive than the average price of all products is correctly structured. However, please note that the `products` table is mentioned twice in your schema, which is likely an oversight. Below is the valid SQLite query wrapped appropria... | 2,735 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_id VARCHAR, product_price INTEGER); CREATE TABLE product_suppliers (product_id VARCHAR, supplier_id VARCHAR); CREAT... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE department_stores (dept_store_id VARCHAR, store_name VARCHAR); CREATE TABLE departments (dept_store_id VARCHAR, department_name VARCHAR)
Question: What is the id and name... | Your SQLite query looks correct for finding the department store ID and name that has both marketing and managing departments. Here it is, properly formatted as requested:
```
SELECT T2.dept_store_id, T2.store_name
FROM departments AS T1
JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id
WHERE T1.d... | 2,736 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE department_stores (dept_store_id VARCHAR, store_name VARCHAR); CREATE TABLE departments (dept_store_id VARCHAR, department_name VARCH... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE department_stores (dept_store_chain_id VARCHAR)
Question: What are the ids of the two department store chains with the largest number of department stores?
Here is the S... | Your SQLite query looks correct for finding the IDs of the two department store chains with the largest number of department stores. Here's the query wrapped in code formatting:
```
SELECT dept_store_chain_id
FROM department_stores
GROUP BY dept_store_chain_id
ORDER BY COUNT(*) DESC
LIMIT 2;
```
This query group... | 2,737 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE department_stores (dept_store_chain_id VARCHAR)\n\n Question: What are the ids of the two department store chains with the largest... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE staff_department_assignments (department_id VARCHAR)
Question: What is the id of the department with the least number of staff?
Here is the SQLite query to answer to the... | Your query for finding the department ID with the least number of staff looks good, but it can be made slightly clearer by using the `MIN()` function along with a subquery to accurately find the minimum staff count. Here’s an alternative version of your query:
```sql
SELECT department_id
FROM staff_department_assignm... | 2,738 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE staff_department_assignments (department_id VARCHAR)\n\n Question: What is the id of the department with the least number of staff... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_type_code VARCHAR, product_price INTEGER)
Question: For each product type, return the maximum and minimum price.
Here is the SQLite query to answer to ... | Your SQLite query is correct and effectively returns the maximum and minimum price for each product type. Here it is wrapped as requested:
```
SELECT product_type_code, MAX(product_price), MIN(product_price) FROM products GROUP BY product_type_code
``` | 2,739 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_type_code VARCHAR, product_price INTEGER)\n\n Question: For each product type, return the maximum and minimum pr... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_type_code VARCHAR, product_price INTEGER)
Question: Find the product type whose average price is higher than the average price of all products.
Here is... | Your provided SQLite query is indeed correct for finding the product types whose average price is higher than the average price of all products. Here it is formatted as requested:
```
SELECT product_type_code
FROM products
GROUP BY product_type_code
HAVING AVG(product_price) > (SELECT AVG(product_price) FROM produc... | 2,740 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_type_code VARCHAR, product_price INTEGER)\n\n Question: Find the product type whose average price is higher than... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Staff_Department_Assignments (staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_name VARCHAR)
Question: Find the id and name of the staff who has been assign... | The SQL query you provided attempts to find the staff assigned for the shortest period, but it has some issues, including missing date columns and incorrect syntax for date calculation. Since the schema provided does not include any date columns, the query cannot compute the assignment duration.
Assuming you have colu... | 2,741 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Staff_Department_Assignments (staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_name VARCHAR)\n\n Question: Find the ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_name VARCHAR, product_id VARCHAR, product_price INTEGER)
Question: Return the names and ids of all products whose price is between 600 and 700.
Here is... | Here is the SQLite query to return the names and ids of all products whose price is between 600 and 700:
```
SELECT product_name, product_id FROM products WHERE product_price BETWEEN 600 AND 700;
``` | 2,742 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_name VARCHAR, product_id VARCHAR, product_price INTEGER)\n\n Question: Return the names and ids of all products ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Customer_Orders (customer_id VARCHAR, order_date INTEGER, order_status_code VARCHAR)
Question: Find the ids of all distinct customers who made order after some orders tha... | Here is the SQLite query to find the IDs of all distinct customers who made orders after some orders that were Cancelled:
```
SELECT DISTINCT customer_id
FROM Customer_Orders
WHERE order_date > (SELECT MIN(order_date)
FROM Customer_Orders
WHERE order_status_code = 'Cancell... | 2,743 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Customer_Orders (customer_id VARCHAR, order_date INTEGER, order_status_code VARCHAR)\n\n Question: Find the ids of all distinct cu... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Staff_Department_Assignments (staff_id VARCHAR, date_assigned_to INTEGER, job_title_code VARCHAR)
Question: What is id of the staff who had a Staff Department Assignment ... | Your SQLite query looks good for the question you are trying to answer. Here's the formatted code:
```sql
SELECT staff_id
FROM Staff_Department_Assignments
WHERE date_assigned_to < (
SELECT MIN(date_assigned_to)
FROM Staff_Department_Assignments
WHERE job_title_code = 'Clerical Staff'
)
```
In this qu... | 2,744 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Staff_Department_Assignments (staff_id VARCHAR, date_assigned_to INTEGER, job_title_code VARCHAR)\n\n Question: What is id of the ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR, customer_address VARCHAR)
Question: What are the names and ids of customers whose address contains TN?
Here is the... | Here is the SQLite query to answer the question regarding customers whose address contains "TN":
```
SELECT customer_name, customer_id FROM customers WHERE customer_address LIKE "%TN%"
``` | 2,745 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR, customer_address VARCHAR)\n\n Question: What are the names and ids of custo... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE staff (staff_name VARCHAR, staff_gender VARCHAR, staff_id VARCHAR); CREATE TABLE staff_department_assignments (staff_id VARCHAR, date_assigned_from VARCHAR)
Question: Ret... | Here is the SQLite query to answer the question of returning the name and gender of the staff who was assigned in 2016:
```
SELECT T1.staff_name, T1.staff_gender
FROM staff AS T1
JOIN staff_department_assignments AS T2
ON T1.staff_id = T2.staff_id
WHERE T2.date_assigned_from LIKE "2016%"
``` | 2,746 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE staff (staff_name VARCHAR, staff_gender VARCHAR, staff_id VARCHAR); CREATE TABLE staff_department_assignments (staff_id VARCHAR, date... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE staff (staff_name VARCHAR, staff_id VARCHAR); CREATE TABLE staff_department_assignments (staff_id VARCHAR)
Question: List the name of staff who has been assigned multiple... | Here is the SQLite query to list the name of staff who has been assigned multiple jobs:
```sql
SELECT T1.staff_name
FROM staff AS T1
JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id
GROUP BY T2.staff_id
HAVING COUNT(*) > 1
``` | 2,747 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE staff (staff_name VARCHAR, staff_id VARCHAR); CREATE TABLE staff_department_assignments (staff_id VARCHAR)\n\n Question: List the ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE addresses (address_id VARCHAR, address_details VARCHAR); CREATE TABLE supplier_addresses (supplier_id VARCHAR, address_id VARCHAR); CREATE TABLE Suppliers (supplier_name VARCH... | Here is the SQLite query to answer the question of listing the name and phone number of all suppliers in the alphabetical order of their addresses:
```
SELECT T1.supplier_name, T1.supplier_phone
FROM Suppliers AS T1
JOIN supplier_addresses AS T2 ON T1.supplier_id = T2.supplier_id
JOIN addresses AS T3 ON T2.address_... | 2,748 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE addresses (address_id VARCHAR, address_details VARCHAR); CREATE TABLE supplier_addresses (supplier_id VARCHAR, address_id VARCHAR); C... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE suppliers (customer_phone VARCHAR, supplier_phone VARCHAR); CREATE TABLE customers (customer_phone VARCHAR, supplier_phone VARCHAR)
Question: What are the phone numbers o... | Your SQLite query correctly retrieves the phone numbers of all customers and suppliers. However, to ensure that all unique phone numbers are captured, you can simplify your query slightly while still using `UNION` to combine the results from both tables. Here’s the refactored query:
```
SELECT customer_phone FROM cust... | 2,749 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE suppliers (customer_phone VARCHAR, supplier_phone VARCHAR); CREATE TABLE customers (customer_phone VARCHAR, supplier_phone VARCHAR)\n... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Order_Items (product_id VARCHAR, total_amount_purchased INTEGER); CREATE TABLE Product_Suppliers (product_id VARCHAR, total_amount_purchased INTEGER)
Question: Return the... | Here is the SQLite query to answer the question:
```
SELECT product_id
FROM Order_Items
GROUP BY product_id
HAVING COUNT(*) > 3
UNION
SELECT product_id
FROM Product_Suppliers
GROUP BY product_id
HAVING SUM(total_amount_purchased) > 80000;
``` | 2,750 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Order_Items (product_id VARCHAR, total_amount_purchased INTEGER); CREATE TABLE Product_Suppliers (product_id VARCHAR, total_amount_pu... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_id VARCHAR, product_name VARCHAR, product_price VARCHAR)
Question: What are id and name of the products whose price is lower than 600 or higher than 900... | Here is the corrected SQLite query to answer the question about products whose price is lower than 600 or higher than 900:
```sql
SELECT product_id, product_name
FROM products
WHERE CAST(product_price AS INTEGER) < 600 OR CAST(product_price AS INTEGER) > 900;
```
In this query, we use `CAST(product_price AS INTEGE... | 2,751 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_id VARCHAR, product_name VARCHAR, product_price VARCHAR)\n\n Question: What are id and name of the products whos... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Product_Suppliers (supplier_id VARCHAR, total_amount_purchased INTEGER)
Question: Find the id of suppliers whose average amount purchased for each product is above 50000 ... | Here is the SQLite query to find the id of suppliers whose average amount purchased for each product is above 50000 or below 30000:
```
SELECT supplier_id
FROM Product_Suppliers
GROUP BY supplier_id
HAVING AVG(total_amount_purchased) > 50000 OR AVG(total_amount_purchased) < 30000
``` | 2,752 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Product_Suppliers (supplier_id VARCHAR, total_amount_purchased INTEGER)\n\n Question: Find the id of suppliers whose average amoun... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Product_Suppliers (total_amount_purchased INTEGER, total_value_purchased INTEGER, supplier_id VARCHAR)
Question: What are the average amount purchased and value purchased... | Here is the SQLite query to find the average amount purchased and value purchased for the supplier who supplies the most products:
```
SELECT AVG(total_amount_purchased) AS average_amount_purchased,
AVG(total_value_purchased) AS average_value_purchased
FROM Product_Suppliers
WHERE supplier_id = (
SELECT sup... | 2,753 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Product_Suppliers (total_amount_purchased INTEGER, total_value_purchased INTEGER, supplier_id VARCHAR)\n\n Question: What are the ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Customers (customer_code INTEGER)
Question: What is the largest and smallest customer codes?
Here is the SQLite query to answer to the question: What is the largest and ... | Here is the SQLite query to answer the question about the largest and smallest customer codes:
```
SELECT MAX(customer_code), MIN(customer_code) FROM Customers;
``` | 2,754 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Customers (customer_code INTEGER)\n\n Question: What is the largest and smallest customer codes?\n\nHere is the SQLite query to an... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE order_items (order_id VARCHAR, product_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE products (product_id VARCHAR, product_nam... | Your provided SQLite query correctly answers the question of listing the names of all distinct customers who bought a keyboard. Here it is, wrapped appropriately:
```
SELECT DISTINCT T1.customer_name
FROM customers AS T1
JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id
JOIN order_items AS T3 ON T2.orde... | 2,755 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE order_items (order_id VARCHAR, product_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE product_suppliers (supplier_id VARCHAR, product_id VARCHAR); CREATE TABLE suppliers (supplier_name VARCHAR, supplier_phone VARCHAR, supplier_id VARCHAR); CREATE TABLE products... | Here is the SQLite query to answer the question: List the names and phone numbers of all the distinct suppliers who supply red jeans.
```
SELECT DISTINCT T1.supplier_name, T1.supplier_phone
FROM suppliers AS T1
JOIN product_suppliers AS T2 ON T1.supplier_id = T2.supplier_id
JOIN products AS T3 ON T2.product_id = T3... | 2,756 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE product_suppliers (supplier_id VARCHAR, product_id VARCHAR); CREATE TABLE suppliers (supplier_name VARCHAR, supplier_phone VARCHAR, s... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_type_code VARCHAR, product_price INTEGER)
Question: What are the highest and lowest prices of products, grouped by and alphabetically ordered by product... | Your provided SQLite query is correct for retrieving the highest and lowest prices of products, grouped by product type and ordered alphabetically. Here it is properly wrapped:
```
SELECT MAX(product_price) AS highest_price, MIN(product_price) AS lowest_price, product_type_code
FROM products
GROUP BY product_type_co... | 2,757 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_type_code VARCHAR, product_price INTEGER)\n\n Question: What are the highest and lowest prices of products, grou... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customer_orders (order_id VARCHAR, customer_id VARCHAR, order_status_code VARCHAR, order_date VARCHAR)
Question: List the order id, customer id for orders in Cancelled st... | Here is the SQLite query to list the order id and customer id for orders in Cancelled status, ordered by their order dates:
```
SELECT order_id, customer_id FROM customer_orders WHERE order_status_code = "Cancelled" ORDER BY order_date;
``` | 2,758 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE customer_orders (order_id VARCHAR, customer_id VARCHAR, order_status_code VARCHAR, order_date VARCHAR)\n\n Question: List the orde... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE customer_orders (order_id VARCHAR, customer_id VARCHAR); CREATE TABLE order_items (order_id VARCHAR, product_... | Here is the SQLite query you requested, formatted correctly:
```
SELECT DISTINCT T3.product_name
FROM customer_orders AS T1
JOIN order_items AS T2 ON T1.order_id = T2.order_id
JOIN products AS T3 ON T2.product_id = T3.product_id
GROUP BY T3.product_id
HAVING COUNT(DISTINCT T1.customer_id) >= 2;
``` | 2,759 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE customer_orders (order_id VARCHAR, customer_id VARCHAR); CREATE TAB... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE order_items (order_id VARCHAR, product_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, ord... | Here is the SQLite query that finds the names of customers who have bought at least three distinct products:
```sql
SELECT DISTINCT T1.customer_name
FROM customers AS T1
JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id
JOIN order_items AS T3 ON T2.order_id = T3.order_id
GROUP BY T1.customer_id
HAVING... | 2,760 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE order_items (order_id VARCHAR, product_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE staff (staff_name VARCHAR, staff_gender VARCHAR, staff_id VARCHAR); CREATE TABLE Staff_Department_Assignments (staff_id VARCHAR, job_title_code VARCHAR)
Question: Find th... | Here is the SQLite query you requested, formatted properly:
```
SELECT T1.staff_name, T1.staff_gender
FROM staff AS T1
JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id
WHERE T2.job_title_code = "Sales Person"
EXCEPT
SELECT T1.staff_name, T1.staff_gender
FROM staff AS T1
JOIN Staff_Department... | 2,761 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE staff (staff_name VARCHAR, staff_gender VARCHAR, staff_id VARCHAR); CREATE TABLE Staff_Department_Assignments (staff_id VARCHAR, job_... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customers (customer_id VARCHAR, customer_name VARCHAR, customer_address VARCHAR, payment_method_code VARCHAR)
Question: Find the id and name of customers whose address co... | Here is the SQLite query to find the id and name of customers whose address contains WY state and do not use credit card for payment:
```
SELECT customer_id, customer_name
FROM customers
WHERE customer_address LIKE "%WY%"
AND payment_method_code <> "Credit Card";
``` | 2,762 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE customers (customer_id VARCHAR, customer_name VARCHAR, customer_address VARCHAR, payment_method_code VARCHAR)\n\n Question: Find t... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_price INTEGER, product_type_code VARCHAR)
Question: Find the average price of all product clothes.
Here is the SQLite query to answer to the question: ... | Here is the SQLite query to find the average price of all product clothes:
```
SELECT AVG(product_price) FROM products WHERE product_type_code = 'Clothes'
``` | 2,763 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_price INTEGER, product_type_code VARCHAR)\n\n Question: Find the average price of all product clothes.\n\nHere i... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_name VARCHAR, product_type_code VARCHAR, product_price VARCHAR)
Question: Find the name of the most expensive hardware product.
Here is the SQLite quer... | Your provided SQLite query looks almost correct, but since `product_price` is defined as a `VARCHAR`, you need to ensure that the comparison is done correctly by converting it to a numerical type. Here is the corrected query:
```sql
SELECT product_name
FROM products
WHERE product_type_code = 'Hardware'
ORDER BY CAS... | 2,764 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE products (product_name VARCHAR, product_type_code VARCHAR, product_price VARCHAR)\n\n Question: Find the name of the most expensiv... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE aircraft (Id VARCHAR)
Question: How many aircrafts are there?
Here is the SQLite query to answer to the question: How many aircrafts are there?:
```
SELECT COUNT(*) FROM... | Here is the SQLite query to answer the question: How many aircrafts are there?:
```
SELECT COUNT(*) FROM aircraft
``` | 2,765 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE aircraft (Id VARCHAR)\n\n Question: How many aircrafts are there?\n\nHere is the SQLite query to answer to the question: How many ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE aircraft (Description VARCHAR)
Question: List the description of all aircrafts.
Here is the SQLite query to answer to the question: List the description of all aircrafts... | Here is the SQLite query to list the description of all aircrafts:
```
SELECT Description FROM aircraft;
``` | 2,766 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE aircraft (Description VARCHAR)\n\n Question: List the description of all aircrafts.\n\nHere is the SQLite query to answer to the q... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE airport (International_Passengers INTEGER)
Question: What is the average number of international passengers of all airports?
Here is the SQLite query to answer to the qu... | Here is the SQLite query to answer the question about the average number of international passengers of all airports:
```
SELECT AVG(International_Passengers) FROM airport;
``` | 2,767 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE airport (International_Passengers INTEGER)\n\n Question: What is the average number of international passengers of all airports?\n... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE airport (International_Passengers VARCHAR, Domestic_Passengers VARCHAR, Airport_Name VARCHAR)
Question: What are the number of international and domestic passengers of th... | Here is the SQLite query you requested, wrapped in the appropriate format:
```
SELECT International_Passengers, Domestic_Passengers FROM airport WHERE Airport_Name = "London Heathrow";
``` | 2,768 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE airport (International_Passengers VARCHAR, Domestic_Passengers VARCHAR, Airport_Name VARCHAR)\n\n Question: What are the number of... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE airport (Domestic_Passengers INTEGER, Airport_Name VARCHAR)
Question: What are the total number of Domestic Passengers of airports that contain the word "London".
Here i... | Here is the SQLite query to answer the question regarding the total number of Domestic Passengers of airports that contain the word "London":
```
SELECT SUM(Domestic_Passengers) FROM airport WHERE Airport_Name LIKE "%London%"
``` | 2,769 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE airport (Domestic_Passengers INTEGER, Airport_Name VARCHAR)\n\n Question: What are the total number of Domestic Passengers of airp... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE airport (Transit_Passengers INTEGER)
Question: What are the maximum and minimum number of transit passengers of all aiports.
Here is the SQLite query to answer to the qu... | Your SQLite query is correctly formulated to retrieve the maximum and minimum number of transit passengers from the `airport` table. Here it is again for clarity:
```
SELECT MAX(Transit_Passengers), MIN(Transit_Passengers) FROM airport
``` | 2,770 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE airport (Transit_Passengers INTEGER)\n\n Question: What are the maximum and minimum number of transit passengers of all aiports.\n... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE pilot (Name VARCHAR, Age VARCHAR)
Question: What are the name of pilots aged 25 or older?
Here is the SQLite query to answer to the question: What are the name of pilots... | Your SQLite query looks almost correct, but it's worth noting that since the `Age` column is defined as `VARCHAR`, it should be treated as text in the comparison. This could lead to incorrect results if the ages are not properly formatted as integers. A better approach would be to convert the `Age` values to integers d... | 2,771 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE pilot (Name VARCHAR, Age VARCHAR)\n\n Question: What are the name of pilots aged 25 or older?\n\nHere is the SQLite query to answe... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE pilot (Name VARCHAR)
Question: List all pilot names in ascending alphabetical order.
Here is the SQLite query to answer to the question: List all pilot names in ascendin... | Your SQLite query to list all pilot names in ascending alphabetical order is correct. Here it is again wrapped in code format:
```
SELECT Name FROM pilot ORDER BY Name;
``` | 2,772 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE pilot (Name VARCHAR)\n\n Question: List all pilot names in ascending alphabetical order.\n\nHere is the SQLite query to answer to ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE pilot (Name VARCHAR, Age VARCHAR)
Question: List names of all pilot aged 30 or younger in descending alphabetical order.
Here is the SQLite query to answer to the questi... | Here is the SQLite query to answer the question:
```sql
SELECT Name FROM pilot WHERE Age <= '30' ORDER BY Name DESC;
``` | 2,773 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE pilot (Name VARCHAR, Age VARCHAR)\n\n Question: List names of all pilot aged 30 or younger in descending alphabetical order.\n\nHe... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE airport (Airport_ID VARCHAR, Airport_Name VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR); CREATE TABLE airport_aircraft (Aircraft_ID VARCHAR, Airport_... | Here is the SQLite query to show the names of aircrafts associated with the airport named "London Gatwick":
```sql
SELECT T1.Aircraft
FROM aircraft AS T1
JOIN airport_aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID
JOIN airport AS T3 ON T2.Airport_ID = T3.Airport_ID
WHERE T3.Airport_Name = "London Gatwick"
``` | 2,774 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE airport (Airport_ID VARCHAR, Airport_Name VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR); CREATE TABLE airpo... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE airport (Airport_ID VARCHAR, Total_Passengers INTEGER); CREATE TABLE aircraft (Aircraft VARCHAR, Description VARCHAR, Aircraft_ID VARCHAR); CREATE TABLE airport_aircraft (Airc... | Here is the SQLite query to answer the question regarding the names and descriptions of aircraft associated with airports that have a total number of passengers greater than 10,000,000:
```
SELECT T1.Aircraft, T1.Description
FROM aircraft AS T1
JOIN airport_aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID
JOIN air... | 2,775 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE airport (Airport_ID VARCHAR, Total_Passengers INTEGER); CREATE TABLE aircraft (Aircraft VARCHAR, Description VARCHAR, Aircraft_ID VAR... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE airport (Total_Passengers INTEGER, Airport_ID VARCHAR); CREATE TABLE aircraft (Aircraft_ID VARCHAR, Aircraft VARCHAR); CREATE TABLE airport_aircraft (Aircraft_ID VARCHAR, Airp... | Your SQLite query looks correct for retrieving the average total number of passengers of airports associated with the aircraft "Robinson R-22". Here it is wrapped properly:
```
SELECT AVG(T3.Total_Passengers)
FROM aircraft AS T1
JOIN airport_aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID
JOIN airport AS T3 ON T2... | 2,776 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE airport (Total_Passengers INTEGER, Airport_ID VARCHAR); CREATE TABLE aircraft (Aircraft_ID VARCHAR, Aircraft VARCHAR); CREATE TABLE a... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE MATCH (Location VARCHAR, Winning_Aircraft VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR)
Question: Please list the location and the winning aircr... | Here is the SQLite query to list the location and the winning aircraft name:
```sql
SELECT T2.Location, T1.Aircraft
FROM MATCH AS T2
JOIN aircraft AS T1 ON T2.Winning_Aircraft = T1.Aircraft_ID;
``` | 2,777 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE MATCH (Location VARCHAR, Winning_Aircraft VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR)\n\n Question: Pl... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE MATCH (Winning_Aircraft VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR)
Question: List the name of the aircraft that has been named winning aircra... | Your SQLite query seems to have an issue in the join condition since the `MATCH` table contains `Winning_Aircraft` as a `VARCHAR`, but the `aircraft` table has `Aircraft_ID`. You need to ensure that you're matching the correct columns.
Here is a corrected version of your query that properly counts the wins and returns... | 2,778 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE MATCH (Winning_Aircraft VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR)\n\n Question: List the name of the... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE MATCH (Winning_Aircraft VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR)
Question: List the names of aircrafts and the number of times it won match... | Your query is almost correct, but it has a small mistake. You should group by `T1.Aircraft` instead of `T2.Winning_Aircraft` to ensure you get the count of matches each aircraft has won. Here’s the corrected query:
```sql
SELECT T1.Aircraft, COUNT(*) AS Wins
FROM aircraft AS T1
JOIN MATCH AS T2 ON T1.Aircraft_ID = T2.... | 2,779 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE MATCH (Winning_Aircraft VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR)\n\n Question: List the names of ai... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE pilot (Name VARCHAR, Age VARCHAR)
Question: List names of all pilot in descending order of age.
Here is the SQLite query to answer to the question: List names of all pil... | Your provided query is almost correct, but since the `Age` column is defined as `VARCHAR`, you may want to convert it to an integer for proper numerical sorting. Here’s the modified query wrapped in the appropriate format:
```
SELECT Name FROM pilot ORDER BY CAST(Age AS INTEGER) DESC
```
This ensures that the ages a... | 2,780 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE pilot (Name VARCHAR, Age VARCHAR)\n\n Question: List names of all pilot in descending order of age.\n\nHere is the SQLite query to... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE MATCH (Winning_Aircraft VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR)
Question: List the names of aircrafts and that won matches at least twice.... | Here is the correct SQLite query to list the names of aircraft that won matches at least twice, with the appropriate formatting:
```
SELECT T1.Aircraft
FROM aircraft AS T1
JOIN MATCH AS T2 ON T1.Aircraft_ID = T2.Winning_Aircraft
GROUP BY T2.Winning_Aircraft
HAVING COUNT(*) >= 2;
``` | 2,781 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE MATCH (Winning_Aircraft VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR)\n\n Question: List the names of ai... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR, Winning_Aircraft VARCHAR); CREATE TABLE MATCH (Aircraft VARCHAR, Aircraft_ID VARCHAR, Winning_Aircraft VARCHAR)
Question:... | Your provided SQLite query is almost correct, but it has a slight inconsistency based on the schema where it seems to use `Winning_Aircraft` incorrectly. Also, we should ensure that we consider aircraft that did not win in both tables if needed.
Assuming you want to find aircraft that didn't win in the `MATCH` table,... | 2,782 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR, Winning_Aircraft VARCHAR); CREATE TABLE MATCH (Aircraft VARCHAR, Aircraft_ID VARCHAR... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE airport (Airport_ID VARCHAR, Airport_Name VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR); CREATE TABLE airport_aircraft (Aircraft_ID VARCHAR, Airport_... | Here is the SQLite query to show the names of aircraft that are associated with both an airport named "London Heathrow" and an airport named "London Gatwick":
```
SELECT T1.Aircraft
FROM aircraft AS T1
JOIN airport_aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID
JOIN airport AS T3 ON T2.Airport_ID = T3.Airport_ID... | 2,783 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE airport (Airport_ID VARCHAR, Airport_Name VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR); CREATE TABLE airpo... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE airport (International_Passengers VARCHAR)
Question: Show all information on the airport that has the largest number of international passengers.
Here is the SQLite quer... | Your query is correctly formatted to retrieve all information from the `airport` table for the airport with the largest number of international passengers. It orders the results by the `International_Passengers` column in descending order and limits the result to one record.
Here is the query once again, wrapped appro... | 2,784 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE airport (International_Passengers VARCHAR)\n\n Question: Show all information on the airport that has the largest number of intern... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE MATCH (winning_pilot VARCHAR); CREATE TABLE pilot (name VARCHAR, age INTEGER, pilot_id VARCHAR)
Question: find the name and age of the pilot who has won the most number o... | Here is the SQLite query that answers the question of finding the name and age of the pilot who has won the most number of times among those who are younger than 30:
```sql
SELECT t1.name, t1.age
FROM pilot AS t1
JOIN MATCH AS t2 ON t1.pilot_id = t2.winning_pilot
WHERE t1.age < 30
GROUP BY t1.pilot_id
ORDER BY CO... | 2,785 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE MATCH (winning_pilot VARCHAR); CREATE TABLE pilot (name VARCHAR, age INTEGER, pilot_id VARCHAR)\n\n Question: find the name and ag... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE pilot (name VARCHAR, age VARCHAR, pilot_id VARCHAR); CREATE TABLE MATCH (winning_pilot VARCHAR)
Question: what is the name and age of the youngest winning pilot?
Here is... | Your query to find the name and age of the youngest winning pilot is almost correct, but you need to correctly use the `age` column to ensure the youngest pilot is the one with the smallest age. Since age is stored as a VARCHAR, you might want to use it as an integer if it's possible. Here is a revised version of your ... | 2,786 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE pilot (name VARCHAR, age VARCHAR, pilot_id VARCHAR); CREATE TABLE MATCH (winning_pilot VARCHAR)\n\n Question: what is the name and... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE MATCH (name VARCHAR, pilot_id VARCHAR, Winning_Pilot VARCHAR, country VARCHAR); CREATE TABLE pilot (name VARCHAR, pilot_id VARCHAR, Winning_Pilot VARCHAR, country VARCHAR)
... | Here is the SQLite query to find the name of pilots who did not win the matches held in the country of Australia:
```
SELECT name FROM pilot WHERE pilot_id NOT IN (SELECT Winning_Pilot FROM MATCH WHERE country = 'Australia');
``` | 2,787 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE MATCH (name VARCHAR, pilot_id VARCHAR, Winning_Pilot VARCHAR, country VARCHAR); CREATE TABLE pilot (name VARCHAR, pilot_id VARCHAR, W... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE properties (property_id VARCHAR); CREATE TABLE residents (property_id VARCHAR)
Question: How many residents does each property have? List property id and resident count.
... | Your query is structured correctly to retrieve the number of residents for each property. Here’s the query wrapped in code formatting as requested:
```sql
SELECT T1.property_id, COUNT(*) AS resident_count
FROM properties AS T1
JOIN residents AS T2 ON T1.property_id = T2.property_id
GROUP BY T1.property_id;
```
This ... | 2,788 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE properties (property_id VARCHAR); CREATE TABLE residents (property_id VARCHAR)\n\n Question: How many residents does each property... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE services (service_type_code VARCHAR, organization_id VARCHAR); CREATE TABLE organizations (organization_id VARCHAR, organization_details VARCHAR)
Question: What is the di... | Here is the SQLite query to answer the question: What is the distinct service types that are provided by the organization which has detail 'Denesik and Sons Party'?:
```
SELECT DISTINCT T1.service_type_code
FROM services AS T1
JOIN organizations AS T2 ON T1.organization_id = T2.organization_id
WHERE T2.organization... | 2,789 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE services (service_type_code VARCHAR, organization_id VARCHAR); CREATE TABLE organizations (organization_id VARCHAR, organization_deta... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Residents_Services (resident_id VARCHAR); CREATE TABLE Residents (resident_id VARCHAR, other_details VARCHAR)
Question: How many services has each resident requested? Lis... | Here is the SQLite query to answer the question about how many services each resident has requested, along with the resident ID and details, sorted in descending order of the count:
```
SELECT T1.resident_id, T1.other_details, COUNT(*) AS service_count
FROM Residents AS T1
JOIN Residents_Services AS T2 ON T1.resident_... | 2,790 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Residents_Services (resident_id VARCHAR); CREATE TABLE Residents (resident_id VARCHAR, other_details VARCHAR)\n\n Question: How ma... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Services (service_id VARCHAR, service_details VARCHAR); CREATE TABLE Residents_Services (service_id VARCHAR)
Question: What is the maximum number that a certain service i... | Your provided SQLite query is almost correct for retrieving the maximum number of times a service is provided along with the service details. However, if you want to also include the service details correctly, you should ensure that you are using aliases properly.
Here is the refined version of your query:
```sql
SE... | 2,791 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Services (service_id VARCHAR, service_details VARCHAR); CREATE TABLE Residents_Services (service_id VARCHAR)\n\n Question: What is... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Organizations (organization_details VARCHAR, organization_id VARCHAR); CREATE TABLE Things (thing_id VARCHAR, type_of_Thing_Code VARCHAR, organization_id VARCHAR)
Questio... | Here is the SQLite query to answer your question:
```
SELECT T1.thing_id, T1.type_of_Thing_Code, T2.organization_details
FROM Things AS T1
JOIN Organizations AS T2 ON T1.organization_id = T2.organization_id;
``` | 2,792 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Organizations (organization_details VARCHAR, organization_id VARCHAR); CREATE TABLE Things (thing_id VARCHAR, type_of_Thing_Code VARC... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Customers (customer_id VARCHAR, customer_details VARCHAR); CREATE TABLE Customer_Events (customer_id VARCHAR)
Question: What are the id and details of the customers who h... | Here is the SQLite query to answer the question regarding customers who have at least 3 events:
```
SELECT T1.customer_id, T1.customer_details
FROM Customers AS T1
JOIN Customer_Events AS T2 ON T1.customer_id = T2.customer_id
GROUP BY T1.customer_id
HAVING COUNT(*) >= 3
``` | 2,793 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Customers (customer_id VARCHAR, customer_details VARCHAR); CREATE TABLE Customer_Events (customer_id VARCHAR)\n\n Question: What a... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Customer_Events (date_moved_in VARCHAR, customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, customer_details VARCHAR)
Question: What is each customer's mov... | Here is the SQLite query to answer your question about each customer's move-in date, along with their corresponding customer ID and details:
```sql
SELECT T2.date_moved_in, T1.customer_id, T1.customer_details
FROM Customers AS T1
JOIN Customer_Events AS T2 ON T1.customer_id = T2.customer_id;
``` | 2,794 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Customer_Events (date_moved_in VARCHAR, customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, customer_details VARCHAR)\... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Customer_Events (Customer_Event_ID VARCHAR, property_id VARCHAR, customer_event_id VARCHAR); CREATE TABLE Customer_Event_Notes (Customer_Event_ID VARCHAR)
Question: Which... | Here is the SQLite query that answers the question regarding events that have the number of notes between one and three, along with the event ID and the property ID:
```sql
SELECT T1.Customer_Event_ID, T1.property_id
FROM Customer_Events AS T1
JOIN Customer_Event_Notes AS T2 ON T1.Customer_Event_ID = T2.Customer_Eve... | 2,795 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Customer_Events (Customer_Event_ID VARCHAR, property_id VARCHAR, customer_event_id VARCHAR); CREATE TABLE Customer_Event_Notes (Custo... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Timed_Status_of_Things (thing_id VARCHAR, Status_of_Thing_Code VARCHAR, Date_and_Date VARCHAR); CREATE TABLE Things (thing_id VARCHAR, Type_of_Thing_Code VARCHAR)
Questio... | Here is the SQLite query to answer the question about the distinct id and type of the thing that has the status 'Close' or has a status record before the date '2017-06-19 02:59:21':
```sql
SELECT DISTINCT T2.thing_id, T2.Type_of_Thing_Code
FROM Timed_Status_of_Things AS T1
JOIN Things AS T2 ON T1.thing_id = T2.thing_i... | 2,796 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Timed_Status_of_Things (thing_id VARCHAR, Status_of_Thing_Code VARCHAR, Date_and_Date VARCHAR); CREATE TABLE Things (thing_id VARCHAR... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Timed_Locations_of_Things (Location_Code VARCHAR, thing_id VARCHAR); CREATE TABLE Things (thing_id VARCHAR, service_details VARCHAR)
Question: How many distinct locations... | Your SQLite query looks almost correct, but it has a small issue with aliasing. The alias `T2` should be used for the `Timed_Locations_of_Things` table and `T1` for the `Things` table. Here's the corrected version of your query:
```sql
SELECT COUNT(DISTINCT T2.Location_Code)
FROM Things AS T1
JOIN Timed_Locations_of... | 2,797 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Timed_Locations_of_Things (Location_Code VARCHAR, thing_id VARCHAR); CREATE TABLE Things (thing_id VARCHAR, service_details VARCHAR)\... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE Timed_Status_of_Things (Status_of_Thing_Code VARCHAR)
Question: How many different status codes of things are there?
Here is the SQLite query to answer to the question: ... | Here is the SQLite query to answer the question of how many different status codes of things are there:
```
SELECT COUNT(DISTINCT Status_of_Thing_Code) FROM Timed_Status_of_Things;
``` | 2,798 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE Timed_Status_of_Things (Status_of_Thing_Code VARCHAR)\n\n Question: How many different status codes of things are there?\n\nHere i... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE organizations (organization_id VARCHAR, parent_organization_id VARCHAR)
Question: Which organizations are not a parent organization of others? List the organization id.
... | Your provided SQLite query is correct. It identifies organizations that are not listed as a parent organization of other organizations by using the `EXCEPT` clause. Here’s the query wrapped in code formatting:
```
SELECT organization_id FROM organizations EXCEPT SELECT parent_organization_id FROM organizations;
```
... | 2,799 | [
{
"from": "human",
"value": " Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:\n Schema: CREATE TABLE organizations (organization_id VARCHAR, parent_organization_id VARCHAR)\n\n Question: Which organizations are not a parent organiz... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.