Dataset Viewer
Auto-converted to Parquet Duplicate
instruction
stringlengths
8
43
input
stringclasses
10 values
output
stringlengths
27
270
amy가 2025년 1월 1일에 주문한 내역 알려줘
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT * FROM orders o JOIN users u ON o.user_id = u.id WHERE u.name = 'amy' and o.order_date='2025-01-01';"
30세 이상인 남성들의 이름과 나이를 보여줘.
{"schema": {"users": {"columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}}}
"SELECT name, age FROM users WHERE age >= 30 AND gender = 'male';"
2025년 1월에 주문된 모든 주문 내역을 보여줘.
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT * FROM orders WHERE order_date BETWEEN '2025-01-01' AND '2025-01-31';"
톰이 2024년 3월 5일에 주문한 상품들의 이름과 개수를 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}, "items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT i.name, oi.amount FROM orders o JOIN users u ON o.user_id = u.id JOIN order_item oi ON o.id = oi.order_id JOIN items i ON oi.item_id = i.id WHERE u.name = '톰' AND o.order_date = '2024-03-05';"
총 가격이 50,000원 이상인 주문들의 주문 날짜와 총 가격을 보여줘.
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT order_date, total_price FROM orders WHERE total_price >= 50000;"
여성 사용자의 이름과 나이를 모두 보여줘.
{"schema": {"users": {"columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}}}
"SELECT name, age FROM users WHERE gender = 'female';"
가장 비싼 상품의 이름과 가격을 알려줘.
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}}}
"SELECT name, price FROM items WHERE price = (SELECT MAX(price) FROM items);"
2023년 4월 동안 주문된 각 상품의 총 판매 개수를 알려줘.
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}, "items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT i.name, SUM(oi.amount) AS total_amount FROM order_item oi JOIN items i ON oi.item_id = i.id JOIN orders o ON oi.order_id = o.id WHERE o.order_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY i.name;"
캘리가 주문한 상품들의 총 가격을 계산해줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}, "items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT SUM(i.price * oi.amount) AS total_spent FROM orders o JOIN users u ON o.user_id = u.id JOIN order_item oi ON o.id = oi.order_id JOIN items i ON oi.item_id = i.id WHERE u.name = '캘리';"
각 주문 상태별 주문 수를 계산해줘.
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT order_state, COUNT(*) AS order_count FROM orders GROUP BY order_state;"
2024년 11월 28일에 주문된 상품들의 이름과 총 주문 수를 보여줘.
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}, "items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT i.name, SUM(oi.amount) AS total_ordered FROM order_item oi JOIN items i ON oi.item_id = i.id JOIN orders o ON oi.order_id = o.id WHERE o.order_date = '2024-11-28' GROUP BY i.name;"
주문 상태가 'delivery'인 주문들의 주문 ID와 사용자 이름을 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT o.id AS order_id, u.name AS user_name FROM orders o JOIN users u ON o.user_id = u.id WHERE o.order_state = 'delivery';"
각 사용자가 주문한 총 금액을 계산해줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT u.name AS user_name, SUM(o.total_price) AS total_spent FROM orders o JOIN users u ON o.user_id = u.id GROUP BY u.name;"
2024년 11월 28일에 주문된 상품들의 이름과 총 주문 수를 보여줘.
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT i.name, SUM(oi.amount) AS total_ordered FROM order_item oi JOIN items i ON oi.item_id = i.id GROUP BY i.name ORDER BY total_ordered DESC LIMIT 1;"
사용자 별로 주문한 상품의 수를 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT u.name AS user_name, COUNT(o.id) AS order_count FROM orders o JOIN users u ON o.user_id = u.id GROUP BY u.name;"
평균 주문 금액이 10,000원 이상인 사용자의 이름과 평균 금액을 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT u.name AS user_name, AVG(o.total_price) AS avg_order_price FROM orders o JOIN users u ON o.user_id = u.id GROUP BY u.name HAVING avg_order_price >= 10000;"
모든 상품의 총 판매량과 총 수익을 계산해줘.
{"schema": {"order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT SUM(oi.amount) AS total_items_sold, SUM(oi.amount * i.price) AS total_revenue FROM order_item oi JOIN items i ON oi.item_id = i.id;"
30세 미만 사용자가 주문한 모든 주문의 ID와 주문 날짜를 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT o.id AS order_id, o.order_date FROM orders o JOIN users u ON o.user_id = u.id WHERE u.age < 30;"
사용자 별로 주문한 상품들의 총 개수를 계산해줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT u.name AS user_name, SUM(oi.amount) AS total_items_ordered FROM orders o JOIN users u ON o.user_id = u.id JOIN order_item oi ON o.id = oi.order_id GROUP BY u.name;"
주문된 상품이 없는 사용자들의 이름을 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT u.name FROM users u LEFT JOIN orders o ON u.id = o.user_id WHERE o.id IS NULL;"
여성 사용자가 주문한 총 주문 수와 총 금액을 계산해줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT COUNT(o.id) AS total_orders, SUM(o.total_price) AS total_spent FROM orders o JOIN users u ON o.user_id = u.id WHERE u.gender = 'female';"
주문 상태가 'done'인 주문들의 사용자 이름과 주문 날짜를 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT u.name AS user_name, o.order_date FROM orders o JOIN users u ON o.user_id = u.id WHERE o.order_state = 'done';"
상품 이름이 'Laptop'인 상품을 주문한 사용자들의 이름을 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}, "items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT DISTINCT u.name FROM order_item oi JOIN items i ON oi.item_id = i.id JOIN orders o ON oi.order_id = o.id JOIN users u ON o.user_id = u.id WHERE i.name = 'Laptop';"
2022년 7월에 주문된 모든 주문의 ID와 총 금액을 보여줘.
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT o.id AS order_id, o.total_price FROM orders o WHERE EXTRACT(YEAR FROM o.order_date) = 2022 AND EXTRACT(MONTH FROM o.order_date) = 7;"
20세 이하의 사용자가 주문한 상품들의 이름과 총 주문 수를 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}, "items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT i.name, SUM(oi.amount) AS total_ordered FROM order_item oi JOIN items i ON oi.item_id = i.id JOIN orders o ON oi.order_id = o.id JOIN users u ON o.user_id = u.id WHERE u.age <= 20 GROUP BY i.name;"
총 주문 금액이 가장 낮은 사용자의 이름과 그 금액을 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT u.name AS user_name, SUM(o.total_price) AS total_spent FROM orders o JOIN users u ON o.user_id = u.id GROUP BY u.name ORDER BY total_spent LIMIT 1;"
2025년에 주문된 각 상품별 총 판매량을 보여줘.
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}, "items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT i.name, SUM(oi.amount) AS total_sold FROM order_item oi JOIN items i ON oi.item_id = i.id JOIN orders o ON oi.order_id = o.id WHERE EXTRACT(YEAR FROM o.order_date) = 2025 GROUP BY i.name;"
한 번도 주문하지 않은 상품들의 이름을 보여줘.
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT i.name FROM items i LEFT JOIN order_item oi ON i.id = oi.item_id WHERE oi.id IS NULL;"
주문 상태가 'paid'인 주문들의 총 주문 수와 평균 주문 금액을 계산해줘.
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT COUNT(o.id) AS total_orders, AVG(o.total_price) AS avg_order_price FROM orders o WHERE o.order_state = 'paid';"
가장 비싼 상품을 주문한 사용자의 이름과 그 상품의 가격을 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}, "items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT u.name AS user_name, i.price FROM order_item oi JOIN items i ON oi.item_id = i.id JOIN orders o ON oi.order_id = o.id JOIN users u ON o.user_id = u.id WHERE i.price = (SELECT MAX(price) FROM items);"
한 번도 주문하지 않은 사용자들의 이름을 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT u.name FROM users u LEFT JOIN orders o ON u.id = o.user_id WHERE o.id IS NULL;"
주문한 상품 수가 5개 이상인 사용자들의 이름과 총 주문 수를 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT u.name, COUNT(o.id) AS total_orders FROM users u JOIN orders o ON u.id = o.user_id WHERE o.total_count >= 5 GROUP BY u.name;"
2023년 5월에 가장 많이 판매된 상품의 이름과 판매량을 보여줘.
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}, "items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT i.name, SUM(oi.amount) AS total_sold FROM order_item oi JOIN items i ON oi.item_id = i.id JOIN orders o ON oi.order_id = o.id WHERE EXTRACT(YEAR FROM o.order_date) = 2023 AND EXTRACT(MONTH FROM o.order_date) = 5 GROUP BY i.name ORDER BY total_sold DESC LIMIT 1;"
사용자가 주문한 상품의 총 금액을 사용자별로 계산해서 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT u.name, SUM(o.total_price) AS total_spent FROM orders o JOIN users u ON o.user_id = u.id GROUP BY u.name;"
주문 상태가 'delivery'인 주문의 사용자 이름과 주문 ID를 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT u.name AS user_name, o.id AS order_id FROM orders o JOIN users u ON o.user_id = u.id WHERE o.order_state = 'delivery';"
모든 주문에서 가장 적게 주문된 상품의 이름과 주문 수를 보여줘.
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT i.name, SUM(oi.amount) AS total_ordered FROM order_item oi JOIN items i ON oi.item_id = i.id GROUP BY i.name ORDER BY total_ordered ASC LIMIT 1;"
2024년에 주문된 각 주문의 ID와 총 금액을 날짜순으로 정렬해서 보여줘.
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT o.id AS order_id, o.total_price FROM orders o WHERE EXTRACT(YEAR FROM o.order_date) = 2024 ORDER BY o.order_date ASC;"
사용자별로 가장 최근 주문 날짜를 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT u.name, MAX(o.order_date) AS last_order_date FROM orders o JOIN users u ON o.user_id = u.id GROUP BY u.name;"
총 판매량이 10개 이상인 상품의 이름과 총 판매량을 보여줘.
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT i.name, SUM(oi.amount) AS total_sold FROM order_item oi JOIN items i ON oi.item_id = i.id GROUP BY i.name HAVING total_sold >= 10;"
사용자가 주문한 각 상품의 이름과 주문 수를 사용자별로 그룹화하여 보여줘.
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}, "orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}, "items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT u.name AS user_name, i.name AS item_name, SUM(oi.amount) AS total_ordered FROM order_item oi JOIN items i ON oi.item_id = i.id JOIN orders o ON oi.order_id = o.id JOIN users u ON o.user_id = u.id GROUP BY u.name, i.name ORDER BY u.name, total_ordered DESC;"
모든 사용자의 이름과 나이를 조회해줘
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}}}
"SELECT name, age FROM users;"
20대 사용자만 조회해줘
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}}}
"SELECT * FROM users WHERE age BETWEEN 20 AND 29;"
남자만 조회해줘
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}}}
"SELECT * FROM users WHERE gender = 'male';"
50살 이상 사용자의 이름과 성별 조회해줘
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}}}
"SELECT name, gender FROM users WHERE age >= 50;"
나이가 가장 많은 사용자를 조회해줘
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}}}
"SELECT * FROM users ORDER BY age DESC LIMIT 1;"
사용자 이름에 'a'가 포함된 사용자 조회해줘
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}}}
"SELECT * FROM users WHERE name LIKE '%a%';"
사용자 테이블에서 중복 없이 성별만 조회해줘
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}}}
"SELECT DISTINCT gender FROM users;"
사용자의 평균 나이 알려줘
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}}}
"SELECT AVG(age) AS average_age FROM users;"
여성 사용자의 총 인원이 몇인지 알려줘
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}}}
"SELECT COUNT(*) AS female_count FROM users WHERE gender = 'female';"
이름이 'John'인 사용자 조회해줘
{"schema": {"users": {"description": "user information", "columns": {"id": ["INT", "user id"], "name": ["VARCHAR", "user name"], "age": ["INT", "user age"], "gender": ["VARCHAR", "user gender [male, female]"]}, "primary_key": "id"}}}
"SELECT * FROM users WHERE name = 'John';"
모든 주문의 ID와 날짜를 조회
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT id, order_date FROM orders;"
'paid' 상태인 주문만 조회
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT * FROM orders WHERE order_state = 'paid';"
2025년에 주문된 주문 조회
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT * FROM orders WHERE EXTRACT(YEAR FROM order_date) = 2025;"
총 금액이 100,000 이상인 주문 조회
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT * FROM orders WHERE total_price >= 100000;"
주문 날짜 순으로 모든 주문 조회
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT * FROM orders ORDER BY order_date ASC;"
최근 주문된 주문 3건 조회
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT * FROM orders ORDER BY order_date DESC LIMIT 3;"
'delivery' 상태인 주문 수 계산
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT COUNT(*) AS delivery_count FROM orders WHERE order_state = 'delivery';"
'ordered' 상태의 평균 주문 금액 계산
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT AVG(total_price) AS average_order_price FROM orders WHERE order_state = 'ordered';"
주문 상태별 주문 수 알려줘
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT order_state, COUNT(*) AS state_count FROM orders GROUP BY order_state;"
총 상품 수가 10개 이상인 주문 조회
{"schema": {"orders": {"description": "order list", "columns": {"id": ["INT", "order id"], "user_id": ["INT", "ordered user id"], "order_date": ["DATE", "order date"], "order_state": ["DATE", "order state [ordered, paid, delivery, done]"], "total_count": ["INT", "order items total count"], "total_price": ["INT", "order total price"]}, "primary_key": "id", "foreign_keys": {"user_id": "users.id"}}}}
"SELECT * FROM orders WHERE total_count >= 10;"
모든 상품의 이름과 가격 조회
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}}}
"SELECT name, price FROM items;"
가격이 500,000원 이상인 상품 조회
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}}}
"SELECT * FROM items WHERE price >= 500000;"
가격이 5,000원 이하인 상품 조회
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}}}
"SELECT * FROM items WHERE price <= 5000;"
가장 비싼 상품 조회
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}}}
"SELECT * FROM items ORDER BY price DESC LIMIT 1;"
가장 저렴한 상품 조회
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}}}
"SELECT * FROM items ORDER BY price ASC LIMIT 1;"
상품 이름에 'toy'가 포함된 상품 조회
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}}}
"SELECT * FROM items WHERE name LIKE '%toy%';"
상품의 평균 가격 계산
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}}}
"SELECT AVG(price) AS average_price FROM items;"
가격이 높은 순서대로 모든 상품 조회
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}}}
"SELECT * FROM items ORDER BY price DESC;"
상품 이름 중복 없이 조회
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}}}
"SELECT DISTINCT name FROM items;"
상품 이름이 'Book'인 상품 조회
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}}}
"SELECT * FROM items WHERE name = 'Book';"
모든 주문 항목 조회
{"schema": {"order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT * FROM order_item;"
특정 주문(id = 1)에 대한 모든 주문 항목 조회
{"schema": {"order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT * FROM order_item WHERE order_id = 1;"
주문별로 포함된 상품 개수 조회
{"schema": {"order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT order_id, SUM(amount) AS total_items FROM order_item GROUP BY order_id;"
특정 주문에 대해 주문된 총 금액 계산 (가격 x 수량)
{"schema": {"items": {"description": "item information", "colums": {"id": ["INT", "item id"], "name": ["varchar", "item name"], "price": ["INT", "item price"]}, "primary_key": "id"}, "order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT oi.order_id, SUM(i.price * oi.amount) AS total_price FROM order_item oi JOIN items i ON oi.item_id = i.id WHERE oi.order_id = 1 GROUP BY oi.order_id;"
주문 항목의 수량이 5개 이상인 주문 항목 조회
{"schema": {"order_item": {"description": "order's item list", "colums": {"id": ["INT", "order_item id"], "order_id": ["INT", "order_id"], "item_id": ["INT", "item_id"], "amount": ["INT", "ordered item amount"]}, "primary_key": "id", "foreign_keys": {"order_id": "orders.id", "item_id": "items.id"}}}}
"SELECT * FROM order_item WHERE amount >= 5;"
README.md exists but content is empty.
Downloads last month
1