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 railway (Id VARCHAR)
Question: How many railways are there?
Here is the SQLite query to answer to the question: How many railways are there?:
```
SELECT COUNT(*) FROM ra... | Here is the SQLite query to answer the question: How many railways are there?:
```
SELECT COUNT(*) FROM railway;
``` | 3,200 | [
{
"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 railway (Id VARCHAR)\n\n Question: How many railways are there?\n\nHere is the SQLite query to answer to the question: How many ra... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE railway (Builder VARCHAR)
Question: List the builders of railways in ascending alphabetical order.
Here is the SQLite query to answer to the question: List the builders ... | Here is the SQLite query to list the builders of railways in ascending alphabetical order:
```
SELECT Builder FROM railway ORDER BY Builder ASC;
``` | 3,201 | [
{
"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 railway (Builder VARCHAR)\n\n Question: List the builders of railways in ascending alphabetical order.\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 railway (Wheels VARCHAR, LOCATION VARCHAR)
Question: List the wheels and locations of the railways.
Here is the SQLite query to answer to the question: List the wheels a... | Here is the SQLite query to answer the question:
```
SELECT Wheels, LOCATION FROM railway
``` | 3,202 | [
{
"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 railway (Wheels VARCHAR, LOCATION VARCHAR)\n\n Question: List the wheels and locations of the railways.\n\nHere is the SQLite quer... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE manager (LEVEL INTEGER, Country VARCHAR)
Question: What is the maximum level of managers in countries that are not "Australia"?
Here is the SQLite query to answer to the... | Your SQLite query is almost correct, but it contains an extra space character after "Australia". Here's the corrected query:
```sql
SELECT MAX(LEVEL) FROM manager WHERE Country <> 'Australia';
```
This query selects the maximum level from the `manager` table where the `Country` is not "Australia". | 3,203 | [
{
"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 manager (LEVEL INTEGER, Country VARCHAR)\n\n Question: What is the maximum level of managers in countries that are not \"Australia... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE manager (Age INTEGER)
Question: What is the average age for all managers?
Here is the SQLite query to answer to the question: What is the average age for all managers?:
... | Here is the SQLite query to answer the question about the average age for all managers:
```
SELECT AVG(Age) FROM manager;
``` | 3,204 | [
{
"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 manager (Age INTEGER)\n\n Question: What is the average age for all managers?\n\nHere is the SQLite query to answer to the questio... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE manager (Name VARCHAR, LEVEL VARCHAR)
Question: What are the names of managers in ascending order of level?
Here is the SQLite query to answer to the question: What are ... | Here is the SQLite query that answers the question regarding the names of managers in ascending order of level:
```
SELECT Name FROM manager ORDER BY LEVEL ASC
``` | 3,205 | [
{
"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 manager (Name VARCHAR, LEVEL VARCHAR)\n\n Question: What are the names of managers in ascending order of level?\n\nHere is the SQL... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE train (Name VARCHAR, Arrival VARCHAR)
Question: What are the names and arrival times of trains?
Here is the SQLite query to answer to the question: What are the names an... | Here is the SQLite query to answer the question about the names and arrival times of trains:
```
SELECT Name, Arrival FROM train
``` | 3,206 | [
{
"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 train (Name VARCHAR, Arrival VARCHAR)\n\n Question: What are the names and arrival times of trains?\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 manager (Name VARCHAR, Age VARCHAR)
Question: What is the name of the oldest manager?
Here is the SQLite query to answer to the question: What is the name of the oldest ... | Your query is almost correct, but assuming the `Age` column contains age as a VARCHAR, you'll need to convert it to an integer for correct ordering. Here’s the refined SQLite query:
```sql
SELECT Name FROM manager ORDER BY CAST(Age AS INTEGER) DESC LIMIT 1
```
This will ensure that the sorting is done numerically, a... | 3,207 | [
{
"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 manager (Name VARCHAR, Age VARCHAR)\n\n Question: What is the name of the oldest manager?\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 railway (Location VARCHAR, Railway_ID VARCHAR); CREATE TABLE train (Name VARCHAR, Railway_ID VARCHAR)
Question: Show the names of trains and locations of railways they ar... | Here is the SQLite query to show the names of trains and the locations of the railways they are in:
```
SELECT T2.Name, T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID
``` | 3,208 | [
{
"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 railway (Location VARCHAR, Railway_ID VARCHAR); CREATE TABLE train (Name VARCHAR, Railway_ID VARCHAR)\n\n Question: Show the names... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE railway (Builder VARCHAR, Railway_ID VARCHAR); CREATE TABLE train (Railway_ID VARCHAR, Name VARCHAR)
Question: Show the builder of railways associated with the trains nam... | Your SQLite query is correctly structured to retrieve the builder of railways associated with the train named "Andaman Exp". Below is the SQL code wrapped in the appropriate code block:
```
SELECT T1.Builder FROM railway AS T1
JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID
WHERE T2.Name = "Andaman Exp";
``` | 3,209 | [
{
"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 railway (Builder VARCHAR, Railway_ID VARCHAR); CREATE TABLE train (Railway_ID VARCHAR, Name VARCHAR)\n\n Question: Show the builde... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE railway (Location VARCHAR, Railway_ID VARCHAR); CREATE TABLE train (Railway_ID VARCHAR)
Question: Show id and location of railways that are associated with more than one ... | Here is the SQLite query that answers the question of showing the ID and location of railways that are associated with more than one train:
```
SELECT T1.Railway_ID, T1.Location
FROM railway AS T1
JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID
GROUP BY T1.Railway_ID, T1.Location
HAVING COUNT(T2.Railway_ID) > 1;... | 3,210 | [
{
"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 railway (Location VARCHAR, Railway_ID VARCHAR); CREATE TABLE train (Railway_ID VARCHAR)\n\n Question: Show id and location of rail... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE train (Railway_ID VARCHAR); CREATE TABLE railway (Builder VARCHAR, Railway_ID VARCHAR)
Question: Show the id and builder of the railway that are associated with the most ... | You've provided a correct SQLite query to find the railway ID and builder associated with the most trains. Here it is wrapped properly:
```
SELECT T2.Railway_ID, T1.Builder
FROM railway AS T1
JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID
GROUP BY T2.Railway_ID
ORDER BY COUNT(*) DESC
LIMIT 1;
```
This query ... | 3,211 | [
{
"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 train (Railway_ID VARCHAR); CREATE TABLE railway (Builder VARCHAR, Railway_ID VARCHAR)\n\n Question: Show the id and builder of th... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE railway (Builder VARCHAR)
Question: Show different builders of railways, along with the corresponding number of railways using each builder.
Here is the SQLite query to ... | Here is the SQLite query to answer the question about different builders of railways, along with the corresponding number of railways using each builder:
```
SELECT Builder, COUNT(*) AS NumberOfRailways
FROM railway
GROUP BY Builder;
``` | 3,212 | [
{
"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 railway (Builder VARCHAR)\n\n Question: Show different builders of railways, along with the corresponding number of railways using... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE railway (Builder VARCHAR)
Question: Show the most common builder of railways.
Here is the SQLite query to answer to the question: Show the most common builder of railway... | Your SQLite query to find the most common builder of railways is correct. Here it is wrapped as requested:
```
SELECT Builder FROM railway GROUP BY Builder ORDER BY COUNT(*) DESC LIMIT 1
``` | 3,213 | [
{
"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 railway (Builder VARCHAR)\n\n Question: Show the most common builder of railways.\n\nHere is the SQLite query to answer to the que... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE railway (LOCATION VARCHAR)
Question: Show different locations of railways along with the corresponding number of railways at each location.
Here is the SQLite query to a... | Here is the SQLite query to show different locations of railways along with the corresponding number of railways at each location:
```
SELECT LOCATION, COUNT(*) AS railway_count FROM railway GROUP BY LOCATION;
``` | 3,214 | [
{
"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 railway (LOCATION VARCHAR)\n\n Question: Show different locations of railways along with the corresponding number of railways at e... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE railway (LOCATION VARCHAR)
Question: Show the locations that have more than one railways.
Here is the SQLite query to answer to the question: Show the locations that hav... | Your SQL query is correct for the provided schema and question. Here it is wrapped in the requested code format:
```
SELECT LOCATION FROM railway GROUP BY LOCATION HAVING COUNT(*) > 1
``` | 3,215 | [
{
"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 railway (LOCATION VARCHAR)\n\n Question: Show the locations that have more than one railways.\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 train (ObjectNumber VARCHAR, Railway_ID VARCHAR); CREATE TABLE railway (ObjectNumber VARCHAR, Railway_ID VARCHAR)
Question: List the object number of railways that do not... | Your query is close to what you need, but to accurately find the object numbers of railways that do not have any trains, you should use a `LEFT JOIN` or `NOT EXISTS` approach. Here is a corrected version of the query:
Using `LEFT JOIN`:
```sql
SELECT r.ObjectNumber
FROM railway r
LEFT JOIN train t ON r.Railway_ID =... | 3,216 | [
{
"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 train (ObjectNumber VARCHAR, Railway_ID VARCHAR); CREATE TABLE railway (ObjectNumber VARCHAR, Railway_ID VARCHAR)\n\n Question: Li... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE manager (Country VARCHAR, Age INTEGER)
Question: Show the countries that have both managers of age above 50 and managers of age below 46.
Here is the SQLite query to ans... | Your provided SQL query is correctly formatted to find the countries that have both managers above the age of 50 and managers below the age of 46. Here is the query wrapped in the code block as requested:
```
SELECT Country FROM manager WHERE Age > 50 INTERSECT SELECT Country FROM manager WHERE Age < 46;
``` | 3,217 | [
{
"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 manager (Country VARCHAR, Age INTEGER)\n\n Question: Show the countries that have both managers of age above 50 and managers of ag... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE manager (Country VARCHAR)
Question: Show the distinct countries of managers.
Here is the SQLite query to answer to the question: Show the distinct countries of managers.... | Here is the SQLite query to show the distinct countries of managers:
```
SELECT DISTINCT Country FROM manager
``` | 3,218 | [
{
"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 manager (Country VARCHAR)\n\n Question: Show the distinct countries of managers.\n\nHere is the SQLite query to answer to the ques... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE manager (Working_year_starts VARCHAR, LEVEL VARCHAR)
Question: Show the working years of managers in descending order of their level.
Here is the SQLite query to answer ... | Your SQLite query looks good for showing the working years of managers in descending order of their level. Here it is again, wrapped in the requested code block:
```
SELECT Working_year_starts FROM manager ORDER BY LEVEL DESC;
```
This query selects the `Working_year_starts` column from the `manager` table and order... | 3,219 | [
{
"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 manager (Working_year_starts VARCHAR, LEVEL VARCHAR)\n\n Question: Show the working years of managers in descending order of their... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE manager (Country VARCHAR, Age VARCHAR)
Question: Show the countries that have managers of age above 50 or below 46.
Here is the SQLite query to answer to the question: S... | Your provided SQLite query is almost correct, but there's an important detail to consider: the `Age` is defined as a `VARCHAR`, which means it is stored as a string. To properly compare it as a number, you should convert it to an integer.
Here is the corrected query:
```
SELECT Country FROM manager WHERE CAST(Age AS... | 3,220 | [
{
"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 manager (Country VARCHAR, Age VARCHAR)\n\n Question: Show the countries that have managers of age above 50 or below 46.\n\nHere is... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE addresses (country VARCHAR)
Question: How many addresses are there in country USA?
Here is the SQLite query to answer to the question: How many addresses are there in co... | Here is the SQLite query to answer the question regarding the number of addresses in the country USA:
```
SELECT COUNT(*) FROM addresses WHERE country = 'USA';
``` | 3,221 | [
{
"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 (country VARCHAR)\n\n Question: How many addresses are there in country USA?\n\nHere is the SQLite query to answer to th... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE addresses (city VARCHAR)
Question: Show all distinct cities in the address record.
Here is the SQLite query to answer to the question: Show all distinct cities in the ad... | Your SQLite query is correct. To show all distinct cities in the address record, you can use the following query:
```
SELECT DISTINCT city FROM addresses
```
This query retrieves all unique city names from the `addresses` table. | 3,222 | [
{
"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 (city VARCHAR)\n\n Question: Show all distinct cities in the address record.\n\nHere is the SQLite query to answer to th... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE addresses (state_province_county VARCHAR)
Question: Show each state and the number of addresses in each state.
Here is the SQLite query to answer to the question: Show e... | Your query is almost correct, but it looks like you're grouping by `state_province_county`, which may not give the desired results if you want to count addresses specifically by state. Assuming that the `state_province_county` column contains values formatted in a way that includes state information (for example, as "S... | 3,223 | [
{
"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 (state_province_county VARCHAR)\n\n Question: Show each state and the number of addresses in each state.\n\nHere is the ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customer_address_history (customer_name VARCHAR, customer_phone VARCHAR, customer_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_phone VARCHAR, customer_... | Your SQLite query to show names and phones of customers who do not have address information is correctly structured. Here's the code wrapped as requested:
```
SELECT customer_name, customer_phone
FROM customers
WHERE customer_id NOT IN (SELECT customer_id FROM customer_address_history);
``` | 3,224 | [
{
"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_address_history (customer_name VARCHAR, customer_phone VARCHAR, customer_id VARCHAR); CREATE TABLE customers (customer_name ... | |
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)
Question: Show the name of the customer who has the most orders... | Here is the SQLite query to show the name of the customer who has the most orders:
```sql
SELECT T1.customer_name
FROM customers AS T1
JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id
GROUP BY T1.customer_id
ORDER BY COUNT(*) DESC
LIMIT 1;
``` | 3,225 | [
{
"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)\n\n Question: Show the ... | |
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: Show the product type codes which have at least two products.
Here is the SQLite query to answer to the question: Show the... | Your SQLite query looks correct. It effectively groups the records in the `products` table by `product_type_code` and uses the `HAVING` clause to filter out those groups that have at least two products. Here is the wrapped code again for clarity:
```
SELECT product_type_code FROM products GROUP BY product_type_code HA... | 3,226 | [
{
"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: Show the product type codes which have at least two products.\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 customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_status_code VARCHAR)
Question: Show the names of customer... | Your SQLite query is well-structured to find the names of customers who have both an order in completed status and an order in part status. Here it is wrapped appropriately:
```
SELECT T1.customer_name
FROM customers AS T1
JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id
WHERE T2.order_status_code = 'C... | 3,227 | [
{
"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_phone VARCHAR, payment_method_code VARCHAR, customer_number VARCHAR)
Question: Show the name, phone, and payment method code fo... | Here is the SQLite query to answer your question:
```
SELECT customer_name, customer_phone, payment_method_code FROM customers ORDER BY customer_number DESC;
``` | 3,228 | [
{
"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, payment_method_code VARCHAR, customer_number VARCHAR)\n\n Question: Show... | |
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 order_items (order_quantity INTEGER, product_id VARCHAR)
Question: Show the product name and total order... | Your SQLite query is almost correct, but it is necessary to modify the `GROUP BY` clause to align it with what you're selecting to ensure that we're grouping by the correct column. Here is the refined version of your query:
```sql
SELECT T1.product_name, SUM(T2.order_quantity) AS total_order_quantity
FROM products AS ... | 3,229 | [
{
"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 order_items (order_quantity INTEGER, product_id VARCHAR)\n\n Que... | |
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)
Question: Show the minimum, maximum, average price for all products.
Here is the SQLite query to answer to the question: Show the minimu... | Here is the SQLite query to answer the question:
```
SELECT MIN(product_price), MAX(product_price), AVG(product_price) FROM products;
``` | 3,230 | [
{
"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)\n\n Question: Show the minimum, maximum, average price for all products.\n\nHere is the SQLite qu... | |
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)
Question: How many products have a price higher than the average?
Here is the SQLite query to answer to the question: How many products ... | Here is the SQLite query to answer the question of how many products have a price higher than the average:
```
SELECT COUNT(*) FROM products WHERE product_price > (SELECT AVG(product_price) FROM products);
``` | 3,231 | [
{
"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)\n\n Question: How many products have a price higher than the average?\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 addresses (city VARCHAR, address_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_address_history (date_from VARCHAR, da... | Here is the SQLite query that answers the question:
```
SELECT T2.customer_name, T3.city, T1.date_from, T1.date_to
FROM customer_address_history AS T1
JOIN customers AS T2 ON T1.customer_id = T2.customer_id
JOIN addresses AS T3 ON T1.address_id = T3.address_id;
``` | 3,232 | [
{
"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 (city VARCHAR, address_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE custo... | |
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, payment_method_code VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR)
Question: Show the names of custom... | Here is the SQLite query to answer the question of showing the names of customers who use Credit Card payment method and have more than 2 orders:
```sql
SELECT T1.customer_name
FROM customers AS T1
JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id
WHERE T1.payment_method_code = 'Credit Card'
GROUP BY T... | 3,233 | [
{
"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, payment_method_code VARCHAR); CREATE TABLE customer_orders (customer_id VARCHA... | |
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, order_quantity INTEGER); CREATE TABLE customers (customer_name VARCHAR, customer_phone VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orde... | Here is the SQLite query to answer the question: What are the name and phone of the customer with the most ordered product quantity?:
```
SELECT T1.customer_name, T1.customer_phone
FROM customers AS T1
JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id
JOIN order_items AS T3 ON T3.order_id = T2.order_id ... | 3,234 | [
{
"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, order_quantity INTEGER); CREATE TABLE customers (customer_name VARCHAR, customer_phone VARCHAR, custom... | |
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)
Question: Show the product type and name for the products with price higher than 1000 or... | Your SQLite query is almost correct, but since `product_price` is stored as a VARCHAR, you'll need to convert it to a numeric type for the comparisons to work correctly. Here’s the corrected query:
```
SELECT product_type_code, product_name
FROM products
WHERE CAST(product_price AS REAL) > 1000 OR CAST(product_price... | 3,235 | [
{
"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)\n\n Question: Show the product type and name for... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (dorm_name VARCHAR, gender VARCHAR)
Question: Find the name of dorms only for female (F gender).
Here is the SQLite query to answer to the question: Find the name o... | Here is the SQLite query to find the name of dorms only for female (F gender):
```
SELECT dorm_name FROM dorm WHERE gender = 'F'
``` | 3,236 | [
{
"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 dorm (dorm_name VARCHAR, gender VARCHAR)\n\n Question: Find the name of dorms only for female (F gender).\n\nHere is the SQLite qu... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (dorm_name VARCHAR, student_capacity INTEGER)
Question: Find the name of dorms that can accommodate more than 300 students.
Here is the SQLite query to answer to th... | Your SQLite query to find the names of dorms that can accommodate more than 300 students is correct. Here it is wrapped as you requested:
```
SELECT dorm_name FROM dorm WHERE student_capacity > 300;
``` | 3,237 | [
{
"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 dorm (dorm_name VARCHAR, student_capacity INTEGER)\n\n Question: Find the name of dorms that can accommodate more than 300 student... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE student (sex VARCHAR, age VARCHAR)
Question: How many female students (sex is F) whose age is below 25?
Here is the SQLite query to answer to the question: How many fema... | Here is the SQLite query to answer the question of how many female students (sex is F) whose age is below 25:
```sql
SELECT COUNT(*) FROM student WHERE sex = 'F' AND age < 25;
``` | 3,238 | [
{
"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 (sex VARCHAR, age VARCHAR)\n\n Question: How many female students (sex is F) whose age is below 25?\n\nHere is the SQLite ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE student (fname VARCHAR, age INTEGER)
Question: Find the first name of students who is older than 20.
Here is the SQLite query to answer to the question: Find the first n... | Sure! Here's the SQLite query to find the first name of students who are older than 20:
```
SELECT fname FROM student WHERE age > 20
``` | 3,239 | [
{
"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, age INTEGER)\n\n Question: Find the first name of students who is older than 20.\n\nHere is the SQLite que... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE student (fname VARCHAR, city_code VARCHAR, age VARCHAR)
Question: Find the first name of students living in city PHL whose age is between 20 and 25.
Here is the SQLite q... | Here is the SQLite query to find the first name of students living in city PHL whose age is between 20 and 25:
```
SELECT fname FROM student WHERE city_code = 'PHL' AND age BETWEEN '20' AND '25'
``` | 3,240 | [
{
"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, city_code VARCHAR, age VARCHAR)\n\n Question: Find the first name of students living in city PHL whose age... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (Id VARCHAR)
Question: How many dorms are there?
Here is the SQLite query to answer to the question: How many dorms are there?:
```
SELECT COUNT(*) FROM dorm
``` | Here is the SQLite query to answer the question: How many dorms are there?:
```
SELECT COUNT(*) FROM dorm;
``` | 3,241 | [
{
"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 dorm (Id VARCHAR)\n\n Question: How many dorms are there?\n\nHere is the SQLite query to answer to the question: How many dorms ar... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm_amenity (Id VARCHAR)
Question: Find the number of distinct amenities.
Here is the SQLite query to answer to the question: Find the number of distinct amenities.:
``... | Your query is almost correct, but to find the number of distinct amenities, you should use the `COUNT(DISTINCT ...)` function. Here’s the corrected SQLite query:
```sql
SELECT COUNT(DISTINCT Id) FROM dorm_amenity;
``` | 3,242 | [
{
"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 dorm_amenity (Id VARCHAR)\n\n Question: Find the number of distinct amenities.\n\nHere is the SQLite query to answer to the questi... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (student_capacity INTEGER)
Question: Find the total capacity of all dorms.
Here is the SQLite query to answer to the question: Find the total capacity of all dorms.... | Here is the SQLite query to answer the question: Find the total capacity of all dorms:
```
SELECT SUM(student_capacity) FROM dorm
``` | 3,243 | [
{
"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 dorm (student_capacity INTEGER)\n\n Question: Find the total capacity of all dorms.\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 student (city_code VARCHAR, age INTEGER)
Question: Find the average age of all students living in the each city.
Here is the SQLite query to answer to the question: Find... | Here is the SQLite query to find the average age of all students living in each city:
```sql
SELECT AVG(age) AS average_age, city_code FROM student GROUP BY city_code;
``` | 3,244 | [
{
"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 (city_code VARCHAR, age INTEGER)\n\n Question: Find the average age of all students living in the each city.\n\nHere is th... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (student_capacity INTEGER, gender VARCHAR)
Question: Find the average and total capacity of dorms for the students with gender X.
Here is the SQLite query to answer... | Here is the SQLite query wrapped in code format as you requested:
```
SELECT AVG(student_capacity), SUM(student_capacity) FROM dorm WHERE gender = 'X';
``` | 3,245 | [
{
"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 dorm (student_capacity INTEGER, gender VARCHAR)\n\n Question: Find the average and total capacity of dorms for the students with g... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE has_amenity (dormid VARCHAR)
Question: Find the number of dorms that have some amenity.
Here is the SQLite query to answer to the question: Find the number of dorms that... | Your query looks perfect for counting the number of distinct dorms that have amenities. Here it is wrapped as you requested:
```
SELECT COUNT(DISTINCT dormid) FROM has_amenity;
``` | 3,246 | [
{
"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 has_amenity (dormid VARCHAR)\n\n Question: Find the number of dorms that have some amenity.\n\nHere is the SQLite query to answer ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE has_amenity (dorm_name VARCHAR, dormid VARCHAR)
Question: Find the name of dorms that do not have any amenity
Here... | Your SQLite query is mostly correct but can be slightly optimized for readability. Here's the adjusted query to find the name of dorms that do not have any amenity:
```
SELECT dorm_name
FROM dorm
WHERE dormid NOT IN (SELECT dormid FROM has_amenity);
```
This query selects the `dorm_name` from the `dorm` table where... | 3,247 | [
{
"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 dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE has_amenity (dorm_name VARCHAR, dormid VARCHAR)\n\n Question: Find the name... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (gender VARCHAR)
Question: Find the number of distinct gender for dorms.
Here is the SQLite query to answer to the question: Find the number of distinct gender for ... | Here is the SQLite query to find the number of distinct genders for dorms:
```sql
SELECT COUNT(DISTINCT gender) FROM dorm;
``` | 3,248 | [
{
"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 dorm (gender VARCHAR)\n\n Question: Find the number of distinct gender for dorms.\n\nHere is the SQLite query to answer to the que... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (student_capacity VARCHAR, gender VARCHAR, dorm_name VARCHAR)
Question: Find the capacity and gender type of the dorm whose name has substring ‘Donor’.
Here is the ... | Your provided SQL query correctly identifies the capacity and gender type of the dorm whose name contains the substring 'Donor'. Here it is wrapped in the requested format:
```
SELECT student_capacity, gender FROM dorm WHERE dorm_name LIKE '%Donor%'
``` | 3,249 | [
{
"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 dorm (student_capacity VARCHAR, gender VARCHAR, dorm_name VARCHAR)\n\n Question: Find the capacity and gender type of the dorm who... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (dorm_name VARCHAR, gender VARCHAR, student_capacity VARCHAR)
Question: Find the name and gender type of the dorms whose capacity is greater than 300 or less than 10... | Here is the SQLite query to answer the question regarding the dorms whose capacity is greater than 300 or less than 100:
```
SELECT dorm_name, gender FROM dorm WHERE student_capacity > 300 OR student_capacity < 100
``` | 3,250 | [
{
"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 dorm (dorm_name VARCHAR, gender VARCHAR, student_capacity VARCHAR)\n\n Question: Find the name and gender type of the dorms whose ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE student (major VARCHAR, city_code VARCHAR)
Question: Find the numbers of different majors and cities.
Here is the SQLite query to answer to the question: Find the number... | Here is the SQLite query to find the numbers of different majors and cities:
```
SELECT COUNT(DISTINCT major) AS unique_majors, COUNT(DISTINCT city_code) AS unique_cities FROM student;
``` | 3,251 | [
{
"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 (major VARCHAR, city_code VARCHAR)\n\n Question: Find the numbers of different majors and cities.\n\nHere is the SQLite qu... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (amenid VARCHAR, amenity_name VARCHAR)
Ques... | Here is the SQLite query to find the names of dorms that have both TV Lounge and Study Room as amenities:
```
SELECT T1.dorm_name
FROM dorm AS T1
JOIN has_amenity AS T2 ON T1.dormid = T2.dormid
JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid
WHERE T3.amenity_name = 'TV Lounge'
INTERSECT
SELECT T1.dorm_name
F... | 3,252 | [
{
"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 dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (ameni... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (amenid VARCHAR, amenity_name VARCHAR)
Ques... | Your query to find the name of dorms that have a TV Lounge but no Study Room as an amenity looks good. However, here is a slightly reformatted version for better readability and clarity, while preserving the logic you intended:
```sql
SELECT T1.dorm_name
FROM dorm AS T1
JOIN has_amenity AS T2 ON T1.dormid = T2.dormi... | 3,253 | [
{
"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 dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (ameni... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE student (lname VARCHAR, sex VARCHAR, city_code VARCHAR, age VARCHAR)
Question: Find the last name of students who is either female (sex is F) and living in the city of co... | Here is the SQLite query you requested, formatted correctly:
```
SELECT lname FROM student WHERE sex = 'F' AND city_code = 'BAL'
UNION
SELECT lname FROM student WHERE sex = 'M' AND age < 20;
``` | 3,254 | [
{
"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 (lname VARCHAR, sex VARCHAR, city_code VARCHAR, age VARCHAR)\n\n Question: Find the last name of students who is either fe... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (dorm_name VARCHAR, student_capacity VARCHAR)
Question: Find the name of the dorm with the largest capacity.
Here is the SQLite query to answer to the question: Fin... | Your SQL query is almost correct, but there is a small issue regarding the data type of `student_capacity`. Since it is defined as `VARCHAR`, when you order by it, it will sort lexicographically rather than numerically. To ensure that you are ordering by the numerical value of the capacity, you should cast it to an int... | 3,255 | [
{
"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 dorm (dorm_name VARCHAR, student_capacity VARCHAR)\n\n Question: Find the name of the dorm with the largest capacity.\n\nHere is t... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm_amenity (amenity_name VARCHAR)
Question: List in alphabetic order all different amenities.
Here is the SQLite query to answer to the question: List in alphabetic or... | Here is the SQLite query to list in alphabetic order all different amenities:
```
SELECT DISTINCT amenity_name FROM dorm_amenity ORDER BY amenity_name
``` | 3,256 | [
{
"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 dorm_amenity (amenity_name VARCHAR)\n\n Question: List in alphabetic order all different amenities.\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 student (city_code VARCHAR)
Question: Find the code of city where most of students are living in.
Here is the SQLite query to answer to the question: Find the code of ci... | Here is the SQLite query to find the code of the city where most students are living:
```
SELECT city_code FROM student GROUP BY city_code ORDER BY COUNT(*) DESC LIMIT 1
``` | 3,257 | [
{
"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 (city_code VARCHAR)\n\n Question: Find the code of city where most of students are living in.\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 student (fname VARCHAR, lname VARCHAR, age INTEGER)
Question: Find the first and last name of students whose age is younger than the average age.
Here is the SQLite quer... | Your SQLite query is correct. Here's the formatted query wrapped in code blocks:
```
SELECT fname, lname FROM student WHERE age < (SELECT AVG(age) FROM student);
```
This query retrieves the first and last names of students whose ages are less than the average age of all students in the `student` table. | 3,258 | [
{
"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, age INTEGER)\n\n Question: Find the first and last name of students whose age is younger th... | |
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, city_code VARCHAR, age VARCHAR)
Question: List the first and last name of students who are not living in the city with code HKG, an... | Here is the SQLite query to answer the question about listing the first and last names of students who are not living in the city with code HKG, sorted by their ages:
```
SELECT fname, lname FROM student WHERE city_code <> 'HKG' ORDER BY age;
``` | 3,259 | [
{
"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, city_code VARCHAR, age VARCHAR)\n\n Question: List the first and last name of students who ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE has_amenity (amenid VARCHAR, dormid VARCHAR); CREATE TABLE dorm_amenity (amenity_name VARCHAR, amenid VARCHAR); CREATE TABLE dorm (dormid VARCHAR, dorm_name VARCHAR)
Ques... | Your query looks great! It effectively retrieves the names of all amenities associated with "Anonymous Donor Hall" and sorts them in alphabetical order. Here’s your query formatted correctly:
```
SELECT T1.amenity_name
FROM dorm_amenity AS T1
JOIN has_amenity AS T2 ON T2.amenid = T1.amenid
JOIN dorm AS T3 ON T2.dor... | 3,260 | [
{
"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 has_amenity (amenid VARCHAR, dormid VARCHAR); CREATE TABLE dorm_amenity (amenity_name VARCHAR, amenid VARCHAR); CREATE TABLE dorm (do... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (gender VARCHAR, student_capacity INTEGER)
Question: Find the number of dorms and total capacity for each gender.
Here is the SQLite query to answer to the question... | Your SQLite query is correct for finding the number of dorms and the total capacity for each gender. Here it is wrapped properly:
```
SELECT COUNT(*) AS number_of_dorms, SUM(student_capacity) AS total_capacity, gender
FROM dorm
GROUP BY gender;
```
This query counts the number of dorms (`COUNT(*)`) and sums up the... | 3,261 | [
{
"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 dorm (gender VARCHAR, student_capacity INTEGER)\n\n Question: Find the number of dorms and total capacity for each gender.\n\nHere... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE student (sex VARCHAR, age INTEGER)
Question: Find the average and oldest age for students with different sex.
Here is the SQLite query to answer to the question: Find th... | Your SQLite query is correctly structured to find the average and oldest age for students grouped by sex. Here’s the query wrapped properly:
```
SELECT AVG(age) AS average_age, MAX(age) AS oldest_age, sex
FROM student
GROUP BY sex;
```
This query will return the average age and the maximum (oldest) age for each se... | 3,262 | [
{
"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 (sex VARCHAR, age INTEGER)\n\n Question: Find the average and oldest age for students with different sex.\n\nHere is the S... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE student (major VARCHAR)
Question: Find the number of students in each major.
Here is the SQLite query to answer to the question: Find the number of students in each majo... | Here is the SQLite query to answer the question: Find the number of students in each major:
```
SELECT COUNT(*) AS number_of_students, major FROM student GROUP BY major;
``` | 3,263 | [
{
"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 (major VARCHAR)\n\n Question: Find the number of students in each major.\n\nHere is the SQLite query to answer to the ques... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE student (city_code VARCHAR, age INTEGER)
Question: Find the number and average age of students living in each city.
Here is the SQLite query to answer to the question: F... | Your provided SQLite query is correct for finding the number and average age of students living in each city. Here it is, wrapped as you requested:
```
SELECT COUNT(*) AS student_count, AVG(age) AS average_age, city_code
FROM student
GROUP BY city_code;
```
This query counts the number of students and calculates t... | 3,264 | [
{
"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 (city_code VARCHAR, age INTEGER)\n\n Question: Find the number and average age of students living in each city.\n\nHere is... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE student (city_code VARCHAR, age INTEGER, sex VARCHAR)
Question: Find the average age and number of male students (with sex M) from each city.
Here is the SQLite query to... | The provided SQLite query is correct and effectively retrieves the average age and number of male students from each city. Here's the query wrapped in the requested format:
```
SELECT COUNT(*), AVG(age), city_code FROM student WHERE sex = 'M' GROUP BY city_code
```
This query counts the number of male students (wher... | 3,265 | [
{
"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 (city_code VARCHAR, age INTEGER, sex VARCHAR)\n\n Question: Find the average age and number of male students (with sex M) ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE student (city_code VARCHAR)
Question: Find the number of students for the cities where have more than one student.
Here is the SQLite query to answer to the question: Fi... | Your SQLite query to find the number of students for cities that have more than one student is correct. Here's the query wrapped in the specified format:
```
SELECT COUNT(*), city_code FROM student GROUP BY city_code HAVING COUNT(*) > 1
```
This query groups the students by their `city_code`, counts the number of st... | 3,266 | [
{
"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 (city_code VARCHAR)\n\n Question: Find the number of students for the cities where have more than one student.\n\nHere is ... | |
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, major VARCHAR)
Question: Find the first and last name of students who are not in the largest major.
Here is the SQLite query to an... | Your provided SQLite query is correct for the given requirement. It effectively retrieves the first and last names of students who do not belong to the largest major by using a subquery to identify that major. Here it is wrapped in code formatting as requested:
```
SELECT fname, lname FROM student
WHERE major <> (SEL... | 3,267 | [
{
"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, major VARCHAR)\n\n Question: Find the first and last name of students who are not in the la... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE student (sex VARCHAR, age INTEGER)
Question: Find the number of students whose age is older than the average age for each gender.
Here is the SQLite query to answer to t... | Your query is almost correct, but it computes the average age across all students instead of calculating the average age for each gender. To correctly implement the average age calculation per gender and filter students older than that average, the query should perform a correlated subquery for the average age calculat... | 3,268 | [
{
"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 (sex VARCHAR, age INTEGER)\n\n Question: Find the number of students whose age is older than the average age for each gend... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE student (age INTEGER, stuid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR)
Question: Find the aver... | Your SQLite query is correctly structured to find the average age of students living in each dorm along with the name of the dorm. Here is the query wrapped in code format as requested:
```
SELECT AVG(T1.age), T3.dorm_name
FROM student AS T1
JOIN lives_in AS T2 ON T1.stuid = T2.stuid
JOIN dorm AS T3 ON T3.dormid = ... | 3,269 | [
{
"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 dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE student (age INTEGER, stuid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, do... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (dormid VARCHAR, student_capacity INTEGER); CREATE TABLE has_amenity (dormid VARCHAR)
Question: Find the number of amenities for each of the dorms that can accommoda... | Here is the SQLite query to answer the question regarding the number of amenities for each of the dorms that can accommodate more than 100 students:
```
SELECT COUNT(*) AS amenity_count, T1.dormid
FROM dorm AS T1
JOIN has_amenity AS T2 ON T1.dormid = T2.dormid
WHERE T1.student_capacity > 100
GROUP BY T1.dormid;
``... | 3,270 | [
{
"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 dorm (dormid VARCHAR, student_capacity INTEGER); CREATE TABLE has_amenity (dormid VARCHAR)\n\n Question: Find the number of amenit... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE student (stuid VARCHAR, age INTEGER)
Question: Find the numb... | Here is the SQLite query to find the number of students who are older than 20 in each dorm:
```
SELECT COUNT(*) AS num_students, T3.dorm_name
FROM student AS T1
JOIN lives_in AS T2 ON T1.stuid = T2.stuid
JOIN dorm AS T3 ON T3.dormid = T2.dormid
WHERE T1.age > 20
GROUP BY T3.dorm_name;
``` | 3,271 | [
{
"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 dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE student (stuid VARCHAR,... | |
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 lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE dorm (dormid VARCHAR, dorm_name VARCHAR)
Question: Find the fi... | Here is the SQLite query to find the first names of students who are living in the Smith Hall:
```sql
SELECT T1.fname
FROM student AS T1
JOIN lives_in AS T2 ON T1.stuid = T2.stuid
JOIN dorm AS T3 ON T3.dormid = T2.dormid
WHERE T3.dorm_name = 'Smith Hall'
``` | 3,272 | [
{
"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 lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE dorm (dormid VARCHAR, dor... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (student_capacity INTEGER); CREATE TABLE student (age INTEGER, stuid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE dorm (dormid VARCHAR, s... | Here is the SQLite query to answer the question of finding the average age of students who are living in the dorm with the largest capacity:
```sql
SELECT AVG(T1.age)
FROM student AS T1
JOIN lives_in AS T2 ON T1.stuid = T2.stuid
JOIN dorm AS T3 ON T3.dormid = T2.dormid
WHERE T3.student_capacity = (SELECT MAX(stude... | 3,273 | [
{
"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 dorm (student_capacity INTEGER); CREATE TABLE student (age INTEGER, stuid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARC... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (dormid VARCHAR, gender VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE student (stuid VARCHAR)
Question: Find the total number of stud... | Your SQLite query to find the total number of students living in the male dorm is well-structured. Here it is wrapped in the proper code block:
```
SELECT COUNT(*)
FROM student AS T1
JOIN lives_in AS T2 ON T1.stuid = T2.stuid
JOIN dorm AS T3 ON T3.dormid = T2.dormid
WHERE T3.gender = 'M';
```
This query counts t... | 3,274 | [
{
"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 dorm (dormid VARCHAR, gender VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE student (stuid VARCHAR)\n\... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE student (stuid VARCHAR, sex VARCHAR); CREATE TABLE dorm (dormid VARCHAR, dorm_name VARCHAR)
Question: Find the numb... | Here is the SQLite query to find the number of female students (with F sex) living in Smith Hall:
```sql
SELECT COUNT(*)
FROM student AS T1
JOIN lives_in AS T2 ON T1.stuid = T2.stuid
JOIN dorm AS T3 ON T3.dormid = T2.dormid
WHERE T3.dorm_name = 'Smith Hall' AND T1.sex = 'F';
``` | 3,275 | [
{
"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 lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE student (stuid VARCHAR, sex VARCHAR); CREATE TABLE dorm (dormid VARCHAR, dorm_... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (amenity_name VARCHAR, amenid VARCHAR); CREATE TABLE dorm (dormid VARCHAR, dorm_name VARCHAR)
Ques... | Here is the SQLite query to find the name of amenities that Smith Hall dorm has:
```
SELECT T3.amenity_name FROM dorm AS T1
JOIN has_amenity AS T2 ON T1.dormid = T2.dormid
JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid
WHERE T1.dorm_name = 'Smith Hall';
``` | 3,276 | [
{
"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 has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (amenity_name VARCHAR, amenid VARCHAR); CREATE TABLE dorm (do... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (amenity_name VARCHAR, amenid VARCHAR); CREATE TABLE dorm (dormid VARCHAR, dorm_name VARCHAR)
Ques... | Here is the SQLite query to find the names of amenities that Smith Hall dorm has, ordered by amenity names:
```
SELECT T3.amenity_name
FROM dorm AS T1
JOIN has_amenity AS T2 ON T1.dormid = T2.dormid
JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid
WHERE T1.dorm_name = 'Smith Hall'
ORDER BY T3.amenity_name;
``` | 3,277 | [
{
"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 has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (amenity_name VARCHAR, amenid VARCHAR); CREATE TABLE dorm (do... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm_amenity (amenity_name VARCHAR, amenid VARCHAR); CREATE TABLE has_amenity (amenid VARCHAR)
Question: Find the name of amenity that is most common in all dorms.
Here ... | Your SQLite query is almost correct, but it doesn't quite fulfill the requirement of finding the most common amenity across all dorms. Instead, we need to count the occurrences of each amenity based on its presence in the `has_amenity` table and return the one with the highest count.
Here's the improved SQLite query:
... | 3,278 | [
{
"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 dorm_amenity (amenity_name VARCHAR, amenid VARCHAR); CREATE TABLE has_amenity (amenid VARCHAR)\n\n Question: Find the name of amen... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm_amenity (amenid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE dorm (dormid VARCHAR); CREATE TABLE student (fname VARCHAR, stuid VARCHAR); ... | Your provided SQLite query is correct and successfully retrieves the first names of students living in the dorm that has the most amenities. Here's the formatted query again for clarity:
```sql
SELECT T1.fname
FROM student AS T1
JOIN lives_in AS T2 ON T1.stuid = T2.stuid
WHERE T2.dormid IN (
SELECT T2.dormid
... | 3,279 | [
{
"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 dorm_amenity (amenid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE dorm (dormid VARCHAR); CREATE TABL... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (amenid VARCHAR); CREATE TABLE dorm (dorm_name VARCHAR, student_capacity VARCHAR, dormid VARCHAR)
... | Here is the SQLite query to find the name and capacity of the dorm with the least number of amenities:
```sql
SELECT T1.dorm_name, T1.student_capacity
FROM dorm AS T1
LEFT JOIN has_amenity AS T2 ON T1.dormid = T2.dormid
GROUP BY T1.dormid
ORDER BY COUNT(T2.amenid) ASC
LIMIT 1;
```
This query uses a `LEFT JOIN` ... | 3,280 | [
{
"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 has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (amenid VARCHAR); CREATE TABLE dorm (dorm_name VARCHAR, stude... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm (dorm_name VARCHAR); CREATE TABLE dorm_amenity (amenid V... | Here is the SQLite query to find the names of dorms that do not have the amenity "TV Lounge":
```sql
SELECT dorm_name
FROM dorm
WHERE dormid NOT IN (
SELECT T1.dormid
FROM dorm AS T1
JOIN has_amenity AS T2 ON T1.dormid = T2.dormid
JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid
WHERE T3.amen... | 3,281 | [
{
"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 dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm (dorm_name VAR... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE student (fname VARCHAR, lname VARCHAR, stuid VARCHAR); CREATE... | Here is the SQLite query that answers the given question:
```sql
SELECT T1.fname, T1.lname
FROM student AS T1
JOIN lives_in AS T2 ON T1.stuid = T2.stuid
WHERE T2.dormid IN (
SELECT T3.dormid
FROM has_amenity AS T3
JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid
WHERE T4.amenity_name = 'TV Lounge... | 3,282 | [
{
"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 has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE student (fname VARC... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE student (fname VARCHAR, age VARCHAR, stuid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE T... | Here's the SQLite query to find the first name and age of students who are living in the dorms that do not have the amenity "TV Lounge":
```sql
SELECT T1.fname, T1.age
FROM student AS T1
JOIN lives_in AS T2 ON T1.stuid = T2.stuid
WHERE T2.dormid NOT IN (
SELECT T3.dormid
FROM has_amenity AS T3
JOIN do... | 3,283 | [
{
"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 has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE student (fname VARCHAR, age VARCHAR, stuid VARCHAR); CREATE TABLE lives_in... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE student (stuid VARCHAR, lname VARCHAR); CREATE TABLE dorm (dormid VARCHAR); CREATE TABLE lives_in (dormid VARCHAR, stuid VARCHAR); CREATE TABLE has_amenity (dormid VARCHAR, am... | Here is the SQLite query to find the names of the amenities of the dorm where the student with the last name Smith is living:
```
SELECT T3.amenity_name
FROM dorm AS T1
JOIN has_amenity AS T2 ON T1.dormid = T2.dormid
JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid
JOIN lives_in AS T4 ON T4.dormid = T1.dormid
JOI... | 3,284 | [
{
"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 (stuid VARCHAR, lname VARCHAR); CREATE TABLE dorm (dormid VARCHAR); CREATE TABLE lives_in (dormid VARCHAR, stuid VARCHAR); CR... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customers (email_address VARCHAR, phone_number VARCHAR)
Question: Find the emails and phone numbers of all the customers, ordered by email address and phone number.
Here... | Here is the SQLite query to find the emails and phone numbers of all the customers, ordered by email address and phone number:
```
SELECT email_address, phone_number FROM customers ORDER BY email_address, phone_number;
``` | 3,285 | [
{
"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 (email_address VARCHAR, phone_number VARCHAR)\n\n Question: Find the emails and phone numbers of all the customers, orde... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customers (town_city VARCHAR, customer_type_code VARCHAR)
Question: Which city has the least number of customers whose type code is "Good Credit Rating"?
Here is the SQL... | Your query is mostly correct, but it is best to use the `COUNT` function directly in the `ORDER BY` clause to ensure that it counts the customers properly. Here’s the revised version:
```sql
SELECT town_city
FROM customers
WHERE customer_type_code = "Good Credit Rating"
GROUP BY town_city
ORDER BY COUNT(*) ASC
LI... | 3,286 | [
{
"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 (town_city VARCHAR, customer_type_code VARCHAR)\n\n Question: Which city has the least number of customers whose type co... | |
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 complaints (product_id VARCHAR)
Question: List the name of all products along with the number of complai... | Here is the SQLite query to list the name of all products along with the number of complaints that they have received:
```sql
SELECT p.product_name, COUNT(c.product_id) AS complaint_count
FROM products AS p
LEFT JOIN complaints AS c ON p.product_id = c.product_id
GROUP BY p.product_name;
``` | 3,287 | [
{
"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 complaints (product_id VARCHAR)\n\n Question: List the name of a... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customers (email_address VARCHAR, customer_id VARCHAR); CREATE TABLE complaints (customer_id VARCHAR)
Question: Find the emails of customers who has filed a complaints of... | The provided query is not quite correct for the requirement. To find the emails of customers who have filed complaints for the product with the most complaints, we first need to identify that product and then retrieve the emails of those customers who filed complaints related to that product.
However, based on the sch... | 3,288 | [
{
"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 (email_address VARCHAR, customer_id VARCHAR); CREATE TABLE complaints (customer_id VARCHAR)\n\n Question: Find the email... | |
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); CREATE TABLE products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE complaints (product_id VARCHAR)
Question: Which products h... | Here is the corrected SQLite query to answer the question about which products have been complained about by the customer who has filed the least amount of complaints:
```sql
SELECT DISTINCT p.product_name
FROM products AS p
JOIN complaints AS c ON p.product_id = c.product_id
WHERE c.product_id IN (
SELECT produc... | 3,289 | [
{
"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); CREATE TABLE products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE complaints (product_i... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE customers (phone_number VARCHAR, customer_id VARCHAR); CREATE TABLE complaints (customer_id VARCHAR, date_complaint_raised VARCHAR)
Question: What is the phone number of ... | Here is the SQLite query to find the phone number of the customer who has filed the most recent complaint:
```sql
SELECT t1.phone_number
FROM customers AS t1
JOIN complaints AS t2 ON t1.customer_id = t2.customer_id
ORDER BY t2.date_complaint_raised DESC
LIMIT 1;
``` | 3,290 | [
{
"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 (phone_number VARCHAR, customer_id VARCHAR); CREATE TABLE complaints (customer_id VARCHAR, date_complaint_raised VARCHAR)\n... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE complaints (email_address VARCHAR, phone_number VARCHAR, customer_id VARCHAR); CREATE TABLE customers (email_address VARCHAR, phone_number VARCHAR, customer_id VARCHAR)
Q... | Here is the SQLite query to find the email and phone number of the customers who have never filed a complaint before:
```
SELECT email_address, phone_number
FROM customers
WHERE customer_id NOT IN (SELECT customer_id FROM complaints);
``` | 3,291 | [
{
"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 complaints (email_address VARCHAR, phone_number VARCHAR, customer_id VARCHAR); CREATE TABLE customers (email_address VARCHAR, phone_n... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE staff (phone_number VARCHAR); CREATE TABLE customers (phone_number VARCHAR)
Question: Find the phone number of all the customers and staff.
Here is the SQLite query to a... | Here's the SQLite query to find the phone number of all the customers and staff:
```
SELECT phone_number FROM customers UNION SELECT phone_number FROM staff;
``` | 3,292 | [
{
"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 (phone_number VARCHAR); CREATE TABLE customers (phone_number VARCHAR)\n\n Question: Find the phone number of all the custome... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_description VARCHAR, product_name VARCHAR)
Question: What is the description of the product named "Chocolate"?
Here is the SQLite query to answer to th... | Here is the SQLite query to answer the question about the description of the product named "Chocolate":
```
SELECT product_description FROM products WHERE product_name = "Chocolate";
``` | 3,293 | [
{
"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_description VARCHAR, product_name VARCHAR)\n\n Question: What is the description of the product named \"Chocolat... | |
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_category_code VARCHAR, product_price VARCHAR)
Question: Find the name and category of the most expensive product.
Here is the SQL... | The SQLite query you've provided is almost correct, but since `product_price` is defined as a VARCHAR, it's important to convert it to a numeric type for proper ordering. Here’s the revised query wrapped in code:
```
SELECT product_name, product_category_code
FROM products
ORDER BY CAST(product_price AS REAL) DESC
... | 3,294 | [
{
"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_category_code VARCHAR, product_price VARCHAR)\n\n Question: Find the name and category of ... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_price VARCHAR, product_id VARCHAR); CREATE TABLE complaints (product_price VARCHAR, product_id VARCHAR)
Question: Find the prices of products which has ... | Your SQLite query is almost correct, but here is a more conventional use of the `NOT EXISTS` clause to find the prices of products that have never received a complaint:
```sql
SELECT product_price
FROM products p
WHERE NOT EXISTS (
SELECT 1
FROM complaints c
WHERE c.product_id = p.product_id
);
```
Th... | 3,295 | [
{
"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 VARCHAR, product_id VARCHAR); CREATE TABLE complaints (product_price VARCHAR, product_id VARCHAR)\n\n Ques... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE products (product_category_code VARCHAR, product_price INTEGER)
Question: What is the average price of the products for each category?
Here is the SQLite query to answer... | Here is the SQLite query to calculate the average price of the products for each category:
```sql
SELECT AVG(product_price) AS average_price, product_category_code
FROM products
GROUP BY product_category_code;
``` | 3,296 | [
{
"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_category_code VARCHAR, product_price INTEGER)\n\n Question: What is the average price of the products for each c... | |
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 VARCHAR); CREATE TABLE complaints (staff_id VARCHAR, product_id VARCHAR); CREATE TABLE staff (last_name VARCHAR, staff_id VARCHAR)
... | Your SQLite query looks good, but there are a couple of improvements we can make for clarity and accuracy, especially with regard to handling prices as numerical values if they are stored as strings. Assuming `product_price` should be treated as a number, we should cast it to a numeric type during the comparison.
Here... | 3,297 | [
{
"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 VARCHAR); CREATE TABLE complaints (staff_id VARCHAR, product_id VARCHAR); CREATE TABLE st... | |
Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```:
Schema: CREATE TABLE complaints (complaint_status_code VARCHAR)
Question: Which complaint status has more than 3 records on file?
Here is the SQLite query to answer to the question: Which co... | Here is the SQLite query to answer the question about which complaint status has more than 3 records on file:
```
SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING COUNT(*) > 3
``` | 3,298 | [
{
"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 complaints (complaint_status_code VARCHAR)\n\n Question: Which complaint status has more than 3 records on file?\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 staff (last_name VARCHAR, email_address VARCHAR)
Question: Find the last name of the staff whose email address contains "wrau".
Here is the SQLite query to answer to the... | Here is the SQLite query to find the last name of the staff whose email address contains "wrau":
```sql
SELECT last_name FROM staff WHERE email_address LIKE "%wrau%"
``` | 3,299 | [
{
"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 (last_name VARCHAR, email_address VARCHAR)\n\n Question: Find the last name of the staff whose email address contains \"wrau... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.