System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE travel.members (
  employee_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  zip_code varchar NOT NULL,
  account_status text,
  is_verified boolean,
  full_name character varying(64) NOT NULL,
  address character varying(64),
  store_id text -- reference to stores.store_id,
  FOREIGN KEY (store_id) REFERENCES stores(store_id)
)

CREATE TABLE travel.sales (
  order_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  processed_at date,
  exchange_rate character varying(64) NOT NULL,
  subtotal integer NOT NULL,
  product_id character varying(64),
  store_id text NOT NULL -- reference to stores.store_id,
  FOREIGN KEY (store_id) REFERENCES stores(store_id)
)

CREATE TABLE travel.stores (
  store_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at date,
  latitude char NOT NULL,
  name varchar,
  postal_code character varying(256),
  member_id text NOT NULL -- reference to members.employee_id,
  FOREIGN KEY (member_id) REFERENCES members(employee_id)
)

[User] Retrieve is_verified, full_name, store_id for every member.

[Assistant] SELECT is_verified, full_name, store_id FROM travel.members;

[User] Retrieve address, is_verified, member_id, latitude showing the relationship between members and stores.

[Assistant] SELECT is_verified, full_name, store_id, stores.member_id, stores.latitude FROM travel.members JOIN travel.stores ON members.store_id = stores.store_id;

[User] Restrict the output to 10 items.

[Assistant] SELECT is_verified, full_name, store_id, stores.member_id, stores.latitude FROM travel.members JOIN travel.stores ON members.store_id = stores.store_id LIMIT 10;


[User] List full_name, updated_at, store_id from members.

[Assistant] SELECT full_name, updated_at, store_id FROM travel.members;

[User] Show me members with full_name LIKE 'A%'.

[Assistant] SELECT full_name, updated_at, store_id FROM travel.members WHERE full_name LIKE 'A%';

[User] Sort the results by zip_code ascending.

[Assistant] SELECT full_name, updated_at, store_id FROM travel.members WHERE full_name LIKE 'A%' ORDER BY zip_code ASC;


[User] Retrieve all sales.

[Assistant] SELECT * FROM travel.sales;

[User] What order_id, exchange_rate, updated_at, latitude do we have for sales and their associated stores?

[Assistant] SELECT *, stores.updated_at, stores.latitude FROM travel.sales JOIN travel.stores ON sales.store_id = stores.store_id;

[User] Restrict the output to 5 items.

[Assistant] SELECT *, stores.updated_at, stores.latitude FROM travel.sales JOIN travel.stores ON sales.store_id = stores.store_id LIMIT 5;


[User] Retrieve address, account_status, full_name for every member.

[Assistant] SELECT address, account_status, full_name FROM travel.members;

[User] List members that have is_verified = TRUE.

[Assistant] SELECT address, account_status, full_name FROM travel.members WHERE is_verified = TRUE;

[User] Show me the count of members grouped by full_name.

[Assistant] SELECT full_name, COUNT(*) AS count FROM travel.members GROUP BY full_name ORDER BY count DESC;


[User] Show me all stores.

[Assistant] SELECT * FROM travel.stores;

[User] List stores that have name LIKE 'A%'.

[Assistant] SELECT * FROM travel.stores WHERE name LIKE 'A%';

[User] Tally up stores by latitude.

[Assistant] SELECT latitude, COUNT(*) AS count FROM travel.stores GROUP BY latitude ORDER BY count DESC;


[User] List all sales.

[Assistant] SELECT * FROM travel.sales;

[User] Show me order_id, product_id, name, updated_at from sales and their related stores.

[Assistant] SELECT *, stores.name, stores.updated_at FROM travel.sales JOIN travel.stores ON sales.store_id = stores.store_id;

[User] How many sales are there per exchange_rate?

[Assistant] SELECT exchange_rate, COUNT(*) AS count FROM travel.sales GROUP BY exchange_rate ORDER BY count DESC;


[User] Get all stores.

[Assistant] SELECT * FROM travel.stores;

[User] Show me stores that were created in the last 30 days.

[Assistant] SELECT * FROM travel.stores WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Group stores by name and show the average of updated_at.

[Assistant] SELECT name, AVERAGE(updated_at) AS average_updated_at FROM travel.stores GROUP BY name;


[User] Retrieve processed_at, product_id, updated_at for every sale.

[Assistant] SELECT processed_at, product_id, updated_at FROM travel.sales;

[User] Can you order these by updated_at ascending?

[Assistant] SELECT processed_at, product_id, updated_at FROM travel.sales ORDER BY updated_at ASC;

[User] Count the number of sales in each exchange_rate category.

[Assistant] SELECT exchange_rate, COUNT(*) AS count FROM travel.sales GROUP BY exchange_rate ORDER BY count DESC;


[User] Show me updated_at, product_id, subtotal for all sales.

[Assistant] SELECT updated_at, product_id, subtotal FROM travel.sales;

[User] Show me sales with exchange_rate LIKE 'A%'.

[Assistant] SELECT updated_at, product_id, subtotal FROM travel.sales WHERE exchange_rate LIKE 'A%';

[User] Sort the results by subtotal descending.

[Assistant] SELECT updated_at, product_id, subtotal FROM travel.sales WHERE exchange_rate LIKE 'A%' ORDER BY subtotal DESC;


[User] Get all members.

[Assistant] SELECT * FROM travel.members;

[User] Find members older than 6 months.

[Assistant] SELECT * FROM travel.members WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Count the number of members in each address category.

[Assistant] SELECT address, COUNT(*) AS count FROM travel.members GROUP BY address ORDER BY count DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.users (
  user_id text PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  created_at timestamp,
  password_hash character varying(256) NOT NULL,
  country character varying(128) NOT NULL,
  website character varying(256),
  address char,
  display_name character varying(128) NOT NULL,
  asset_id text NOT NULL -- reference to assets.product_id,
  FOREIGN KEY (asset_id) REFERENCES assets(product_id)
)

CREATE TABLE tradingplatform.orders (
  payment_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  currency character varying(128) NOT NULL,
  amount numeric,
  exchange_rate char,
  discount integer,
  total numeric NOT NULL,
  user_id text NOT NULL -- reference to users.user_id,
  FOREIGN KEY (user_id) REFERENCES users(user_id)
)

CREATE TABLE tradingplatform.assets (
  product_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  created_at timestamp,
  thumbnail_url character varying(256),
  stock_level character varying(256),
  discount numeric,
  order_id integer -- reference to orders.payment_id,
  FOREIGN KEY (order_id) REFERENCES orders(payment_id)
)

[User] Display all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] Can you order these by website descending?

[Assistant] SELECT * FROM tradingplatform.users ORDER BY website DESC;

[User] Order the output by website descending.

[Assistant] SELECT * FROM tradingplatform.users ORDER BY website DESC;


[User] List all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Get orders that match discount > 33.

[Assistant] SELECT * FROM tradingplatform.orders WHERE discount > 33;

[User] Calculate max of created_at for each user_id in orders.

[Assistant] SELECT user_id, MAX(created_at) AS max_created_at FROM tradingplatform.orders GROUP BY user_id;


[User] List website, password_hash, country from users.

[Assistant] SELECT website, password_hash, country FROM tradingplatform.users;

[User] Get users that match asset_id LIKE 'A%'.

[Assistant] SELECT website, password_hash, country FROM tradingplatform.users WHERE asset_id LIKE 'A%';

[User] Group users by display_name and show the min of address.

[Assistant] SELECT display_name, MIN(address) AS min_address FROM tradingplatform.users GROUP BY display_name;


[User] Show me all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Order the output by order_id ascending.

[Assistant] SELECT * FROM tradingplatform.assets ORDER BY order_id ASC;

[User] Get min of updated_at by discount from assets.

[Assistant] SELECT discount, MIN(updated_at) AS min_updated_at FROM tradingplatform.assets GROUP BY discount;


[User] Retrieve all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Get all assets from 2023.

[Assistant] SELECT * FROM tradingplatform.assets WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Get the distribution of assets across different stock_level values.

[Assistant] SELECT stock_level, COUNT(*) AS count FROM tradingplatform.assets GROUP BY stock_level ORDER BY count DESC;


[User] Get all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Retrieve orders where exchange_rate LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.orders WHERE exchange_rate LIKE 'A%';

[User] How many orders are there per created_at?

[Assistant] SELECT created_at, COUNT(*) AS count FROM tradingplatform.orders GROUP BY created_at ORDER BY count DESC;


[User] Get all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Show me orders that were from 2023.

[Assistant] SELECT * FROM tradingplatform.orders WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Only show the top 5 results.

[Assistant] SELECT * FROM tradingplatform.orders WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 5;


[User] Retrieve all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] Find users between January and March.

[Assistant] SELECT * FROM tradingplatform.users WHERE joined_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Get the distribution of users across different display_name values.

[Assistant] SELECT display_name, COUNT(*) AS count FROM tradingplatform.users GROUP BY display_name ORDER BY count DESC;


[User] Show me stock_level, order_id, updated_at for all assets.

[Assistant] SELECT stock_level, order_id, updated_at FROM tradingplatform.assets;

[User] Arrange the results with stock_level in ascending order.

[Assistant] SELECT stock_level, order_id, updated_at FROM tradingplatform.assets ORDER BY stock_level ASC;

[User] Limit the results to 5 rows.

[Assistant] SELECT stock_level, order_id, updated_at FROM tradingplatform.assets ORDER BY stock_level ASC LIMIT 5;


[User] Get discount, order_id, stock_level from all assets.

[Assistant] SELECT discount, order_id, stock_level FROM tradingplatform.assets;

[User] List assets that have discount > 79.

[Assistant] SELECT discount, order_id, stock_level FROM tradingplatform.assets WHERE discount > 79;

[User] Order the output by created_at ascending.

[Assistant] SELECT discount, order_id, stock_level FROM tradingplatform.assets WHERE discount > 79 ORDER BY created_at ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.assets (
  product_id integer PRIMARY KEY -- unique identifier,
  published_at date,
  updated_at date,
  price integer,
  available character varying(64),
  popularity_score text,
  backorder varchar,
  stock_level char,
  thumbnail_url varchar NOT NULL,
  media_url char,
  order_id integer -- reference to orders.invoice_id,
  FOREIGN KEY (order_id) REFERENCES orders(invoice_id)
)

CREATE TABLE tradingplatform.orders (
  invoice_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at date,
  approval_status character varying(128),
  delivery_status character varying(256),
  card_type character varying(256) NOT NULL,
  product_id character varying(256) NOT NULL,
  quantity char NOT NULL,
  asset_id integer -- reference to assets.product_id,
  FOREIGN KEY (asset_id) REFERENCES assets(product_id)
)

[User] Get all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Get card_type, product_id, updated_at, backorder by joining orders with assets.

[Assistant] SELECT *, assets.updated_at, assets.backorder FROM tradingplatform.orders JOIN tradingplatform.assets ON orders.asset_id = assets.product_id;

[User] Arrange the results with delivery_status in ascending order.

[Assistant] SELECT *, assets.updated_at, assets.backorder FROM tradingplatform.orders JOIN tradingplatform.assets ON orders.asset_id = assets.product_id ORDER BY delivery_status ASC;


[User] List all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Order the output by approval_status ascending.

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY approval_status ASC;

[User] Show me the count of orders grouped by delivery_status.

[Assistant] SELECT delivery_status, COUNT(*) AS count FROM tradingplatform.orders GROUP BY delivery_status ORDER BY count DESC;


[User] List all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Show me media_url, stock_level, card_type, updated_at from assets and their related orders.

[Assistant] SELECT *, orders.card_type, orders.updated_at FROM tradingplatform.assets JOIN tradingplatform.orders ON assets.order_id = orders.invoice_id;

[User] How many assets are there per price?

[Assistant] SELECT price, COUNT(*) AS count FROM tradingplatform.assets GROUP BY price ORDER BY count DESC;


[User] Get updated_at, popularity_score, published_at from all assets.

[Assistant] SELECT updated_at, popularity_score, published_at FROM tradingplatform.assets;

[User] Show me assets with backorder LIKE 'A%'.

[Assistant] SELECT updated_at, popularity_score, published_at FROM tradingplatform.assets WHERE backorder LIKE 'A%';

[User] Return just 20 rows.

[Assistant] SELECT updated_at, popularity_score, published_at FROM tradingplatform.assets WHERE backorder LIKE 'A%' LIMIT 20;


[User] Get all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Show me orders that were created after December 1st, 2023.

[Assistant] SELECT * FROM tradingplatform.orders WHERE created_at > '2023-12-01';

[User] Group orders by card_type and show the count of quantity.

[Assistant] SELECT card_type, COUNT(quantity) AS count_quantity FROM tradingplatform.orders GROUP BY card_type;


[User] List all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Show me orders with created_at > '2023-01-01'.

[Assistant] SELECT * FROM tradingplatform.orders WHERE created_at > '2023-01-01';

[User] Only show the top 20 results.

[Assistant] SELECT * FROM tradingplatform.orders WHERE created_at > '2023-01-01' LIMIT 20;


[User] List thumbnail_url, available, published_at from assets.

[Assistant] SELECT thumbnail_url, available, published_at FROM tradingplatform.assets;

[User] Find assets created in the last 30 days.

[Assistant] SELECT thumbnail_url, available, published_at FROM tradingplatform.assets WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Group assets by published_at and show the sum of published_at.

[Assistant] SELECT published_at, SUM(published_at) AS sum_published_at FROM tradingplatform.assets GROUP BY published_at;


[User] What are the backorder, thumbnail_url, updated_at of each asset?

[Assistant] SELECT backorder, thumbnail_url, updated_at FROM tradingplatform.assets;

[User] Get order_id, media_url, updated_at, asset_id by joining assets with orders.

[Assistant] SELECT backorder, thumbnail_url, updated_at, orders.updated_at, orders.asset_id FROM tradingplatform.assets JOIN tradingplatform.orders ON assets.order_id = orders.invoice_id;

[User] Group assets by media_url and show the average of order_id.

[Assistant] SELECT media_url, AVERAGE(order_id) AS average_order_id FROM tradingplatform.assets GROUP BY media_url;


[User] List updated_at, approval_status, delivery_status from orders.

[Assistant] SELECT updated_at, approval_status, delivery_status FROM tradingplatform.orders;

[User] Retrieve orders where the date is from 2023.

[Assistant] SELECT updated_at, approval_status, delivery_status FROM tradingplatform.orders WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Show the results sorted by updated_at ascending.

[Assistant] SELECT updated_at, approval_status, delivery_status FROM tradingplatform.orders WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY updated_at ASC;


[User] Show me backorder, price, available for all assets.

[Assistant] SELECT backorder, price, available FROM tradingplatform.assets;

[User] Show me popularity_score, thumbnail_url, quantity, delivery_status from assets and their related orders.

[Assistant] SELECT backorder, price, available, orders.quantity, orders.delivery_status FROM tradingplatform.assets JOIN tradingplatform.orders ON assets.order_id = orders.invoice_id;

[User] Arrange the results with price in descending order.

[Assistant] SELECT backorder, price, available, orders.quantity, orders.delivery_status FROM tradingplatform.assets JOIN tradingplatform.orders ON assets.order_id = orders.invoice_id ORDER BY price DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.payments (
  payment_id character varying(64) NOT NULL -- unique identifier,
  processed_at timestamp,
  updated_at timestamp without time zone,
  payment_status text,
  status text,
  subtotal numeric(38,14),
  seller_id character varying(64) -- identifier for seller,
  payment_method varchar,
  customer_id text -- reference to customers.user_id,
  FOREIGN KEY (customer_id) REFERENCES customers(user_id)
)

CREATE TABLE finance.accounts (
  account_id integer PRIMARY KEY -- unique identifier,
  due_date timestamp,
  exchange_rate char NOT NULL,
  balance integer NOT NULL,
  description text NOT NULL
)

CREATE TABLE finance.customers (
  user_id text PRIMARY KEY -- unique identifier,
  last_active timestamp,
  created_at timestamp,
  age text,
  display_name text,
  membership_level text NOT NULL,
  profile_picture_url character varying(128),
  last_login timestamp
)

[User] Get customer_id, status, seller_id from all payments.

[Assistant] SELECT customer_id, status, seller_id FROM finance.payments;

[User] Show the results sorted by processed_at ascending.

[Assistant] SELECT customer_id, status, seller_id FROM finance.payments ORDER BY processed_at ASC;

[User] Get sum of updated_at by payment_id from payments.

[Assistant] SELECT payment_id, SUM(updated_at) AS sum_updated_at FROM finance.payments GROUP BY payment_id;


[User] What are the payment_method, processed_at, payment_id of each payment?

[Assistant] SELECT payment_method, processed_at, payment_id FROM finance.payments;

[User] Arrange the results with status in ascending order.

[Assistant] SELECT payment_method, processed_at, payment_id FROM finance.payments ORDER BY status ASC;

[User] Count the number of payments in each processed_at category.

[Assistant] SELECT processed_at, COUNT(*) AS count FROM finance.payments GROUP BY processed_at ORDER BY count DESC;


[User] Retrieve all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Retrieve status, subtotal, last_active, last_login showing the relationship between payments and customers.

[Assistant] SELECT *, customers.last_active, customers.last_login FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.user_id;

[User] Group payments by updated_at and show the min of payment_id.

[Assistant] SELECT updated_at, MIN(payment_id) AS min_payment_id FROM finance.payments GROUP BY updated_at;


[User] Show me all payments.

[Assistant] SELECT * FROM finance.payments;

[User] What updated_at, processed_at, membership_level, last_login do we have for payments and their associated customers?

[Assistant] SELECT *, customers.membership_level, customers.last_login FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.user_id;

[User] Get the distribution of payments across different payment_status values.

[Assistant] SELECT payment_status, COUNT(*) AS count FROM finance.payments GROUP BY payment_status ORDER BY count DESC;


[User] Retrieve updated_at, seller_id, customer_id for every payment.

[Assistant] SELECT updated_at, seller_id, customer_id FROM finance.payments;

[User] Arrange the results with seller_id in descending order.

[Assistant] SELECT updated_at, seller_id, customer_id FROM finance.payments ORDER BY seller_id DESC;

[User] Calculate min of updated_at for each payment_method in payments.

[Assistant] SELECT payment_method, MIN(updated_at) AS min_updated_at FROM finance.payments GROUP BY payment_method;


[User] Get payment_method, subtotal, payment_status from all payments.

[Assistant] SELECT payment_method, subtotal, payment_status FROM finance.payments;

[User] Get all payments older than 6 months.

[Assistant] SELECT payment_method, subtotal, payment_status FROM finance.payments WHERE processed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Return just 25 rows.

[Assistant] SELECT payment_method, subtotal, payment_status FROM finance.payments WHERE processed_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 25;


[User] Display all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Can you order these by updated_at ascending?

[Assistant] SELECT * FROM finance.payments ORDER BY updated_at ASC;

[User] Sort the results by payment_id ascending.

[Assistant] SELECT * FROM finance.payments ORDER BY payment_id ASC;


[User] List customer_id, updated_at, payment_status from payments.

[Assistant] SELECT customer_id, updated_at, payment_status FROM finance.payments;

[User] Sort the results by customer_id ascending.

[Assistant] SELECT customer_id, updated_at, payment_status FROM finance.payments ORDER BY customer_id ASC;

[User] Count the number of payments in each status category.

[Assistant] SELECT status, COUNT(*) AS count FROM finance.payments GROUP BY status ORDER BY count DESC;


[User] Get all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Retrieve payments where the date is from last week.

[Assistant] SELECT * FROM finance.payments WHERE processed_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Get the distribution of payments across different updated_at values.

[Assistant] SELECT updated_at, COUNT(*) AS count FROM finance.payments GROUP BY updated_at ORDER BY count DESC;


[User] Get all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Order the output by payment_method ascending.

[Assistant] SELECT * FROM finance.payments ORDER BY payment_method ASC;

[User] Group payments by subtotal and show the min of seller_id.

[Assistant] SELECT subtotal, MIN(seller_id) AS min_seller_id FROM finance.payments GROUP BY subtotal;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.doctors (
  id text PRIMARY KEY -- unique identifier,
  last_active timestamp,
  joined_at date,
  city character varying(256),
  email text,
  membership_level character varying(64) NOT NULL,
  password_hash char,
  profile_picture_url text,
  department_id text NOT NULL -- reference to departments.message_id,
  FOREIGN KEY (department_id) REFERENCES departments(message_id)
)

CREATE TABLE healthcare.departments (
  message_id text PRIMARY KEY -- unique identifier,
  edited_at date,
  parent_id character varying(128),
  views character varying(128),
  text character varying(256),
  subject varchar NOT NULL,
  media_url character varying(256),
  author_id character varying(128) NOT NULL,
  thumbnail character varying(256) NOT NULL,
  doctor_id text -- reference to doctors.id,
  FOREIGN KEY (doctor_id) REFERENCES doctors(id)
)

[User] Show me all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Find doctors from 2023.

[Assistant] SELECT * FROM healthcare.doctors WHERE joined_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Get count of city by membership_level from doctors.

[Assistant] SELECT membership_level, COUNT(city) AS count_city FROM healthcare.doctors GROUP BY membership_level;


[User] Get last_active, email, joined_at from all doctors.

[Assistant] SELECT last_active, email, joined_at FROM healthcare.doctors;

[User] What profile_picture_url, city, author_id, doctor_id do we have for doctors and their associated departments?

[Assistant] SELECT last_active, email, joined_at, departments.author_id, departments.doctor_id FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.message_id;

[User] Show me the count of doctors grouped by email.

[Assistant] SELECT email, COUNT(*) AS count FROM healthcare.doctors GROUP BY email ORDER BY count DESC;


[User] Retrieve last_active, password_hash, profile_picture_url for every doctor.

[Assistant] SELECT last_active, password_hash, profile_picture_url FROM healthcare.doctors;

[User] Retrieve last_active, profile_picture_url, media_url, subject showing the relationship between doctors and departments.

[Assistant] SELECT last_active, password_hash, profile_picture_url, departments.media_url, departments.subject FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.message_id;

[User] Limit the results to 25 rows.

[Assistant] SELECT last_active, password_hash, profile_picture_url, departments.media_url, departments.subject FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.message_id LIMIT 25;


[User] Get email, last_active, password_hash from all doctors.

[Assistant] SELECT email, last_active, password_hash FROM healthcare.doctors;

[User] Get all doctors older than 6 months.

[Assistant] SELECT email, last_active, password_hash FROM healthcare.doctors WHERE last_active <= CURRENT_DATE - INTERVAL '6 months';

[User] Show only 20 records.

[Assistant] SELECT email, last_active, password_hash FROM healthcare.doctors WHERE last_active <= CURRENT_DATE - INTERVAL '6 months' LIMIT 20;


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Arrange the results with password_hash in ascending order.

[Assistant] SELECT * FROM healthcare.doctors ORDER BY password_hash ASC;

[User] Restrict the output to 25 items.

[Assistant] SELECT * FROM healthcare.doctors ORDER BY password_hash ASC LIMIT 25;


[User] Retrieve last_active, joined_at, password_hash for every doctor.

[Assistant] SELECT last_active, joined_at, password_hash FROM healthcare.doctors;

[User] Get all doctors from 2023.

[Assistant] SELECT last_active, joined_at, password_hash FROM healthcare.doctors WHERE last_active BETWEEN '2023-01-01' AND '2023-12-31';

[User] Return just 25 rows.

[Assistant] SELECT last_active, joined_at, password_hash FROM healthcare.doctors WHERE last_active BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 25;


[User] Get all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Arrange the results with doctor_id in descending order.

[Assistant] SELECT * FROM healthcare.departments ORDER BY doctor_id DESC;

[User] Arrange the results with text in ascending order.

[Assistant] SELECT * FROM healthcare.departments ORDER BY text ASC;


[User] Retrieve all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Get doctor_id, views, department_id, profile_picture_url by joining departments with doctors.

[Assistant] SELECT *, doctors.department_id, doctors.profile_picture_url FROM healthcare.departments JOIN healthcare.doctors ON departments.doctor_id = doctors.id;

[User] What is the sum author_id for each text in departments?

[Assistant] SELECT text, SUM(author_id) AS sum_author_id FROM healthcare.departments GROUP BY text;


[User] Show me edited_at, doctor_id, text for all departments.

[Assistant] SELECT edited_at, doctor_id, text FROM healthcare.departments;

[User] Sort the results by text descending.

[Assistant] SELECT edited_at, doctor_id, text FROM healthcare.departments ORDER BY text DESC;

[User] Limit the results to 10 rows.

[Assistant] SELECT edited_at, doctor_id, text FROM healthcare.departments ORDER BY text DESC LIMIT 10;


[User] Get all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] List city, department_id, doctor_id, edited_at for each doctor along with their department information.

[Assistant] SELECT *, departments.doctor_id, departments.edited_at FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.message_id;

[User] Show me sum of profile_picture_url grouped by email for doctors.

[Assistant] SELECT email, SUM(profile_picture_url) AS sum_profile_picture_url FROM healthcare.doctors GROUP BY email;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.grades (
  order_id text PRIMARY KEY -- unique identifier,
  cancelled_at timestamp without time zone,
  created_at timestamp without time zone,
  delivery_status text,
  amount decimal NOT NULL,
  payment_method varchar
)

CREATE TABLE education.departments (
  barcode integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  category varchar NOT NULL,
  currency character varying(64)
)

CREATE TABLE education.assignments (
  content_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  shares character varying(64),
  categories varchar,
  image_url character varying(256),
  text character varying(128) NOT NULL,
  likes character varying(64)
)

[User] Get all grades.

[Assistant] SELECT * FROM education.grades;

[User] Get all grades between January and March.

[Assistant] SELECT * FROM education.grades WHERE cancelled_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM education.grades WHERE cancelled_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 10;


[User] Get payment_method, cancelled_at, created_at from all grades.

[Assistant] SELECT payment_method, cancelled_at, created_at FROM education.grades;

[User] List grades with dates created after December 1st, 2023.

[Assistant] SELECT payment_method, cancelled_at, created_at FROM education.grades WHERE cancelled_at > '2023-12-01';

[User] Calculate min of delivery_status for each delivery_status in grades.

[Assistant] SELECT delivery_status, MIN(delivery_status) AS min_delivery_status FROM education.grades GROUP BY delivery_status;


[User] Show me cancelled_at, amount, payment_method for all grades.

[Assistant] SELECT cancelled_at, amount, payment_method FROM education.grades;

[User] Get all grades from 2023.

[Assistant] SELECT cancelled_at, amount, payment_method FROM education.grades WHERE cancelled_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Sort the results by cancelled_at ascending.

[Assistant] SELECT cancelled_at, amount, payment_method FROM education.grades WHERE cancelled_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY cancelled_at ASC;


[User] Display all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Order the output by shares descending.

[Assistant] SELECT * FROM education.assignments ORDER BY shares DESC;

[User] Count the number of assignments in each updated_at category.

[Assistant] SELECT updated_at, COUNT(*) AS count FROM education.assignments GROUP BY updated_at ORDER BY count DESC;


[User] List all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Arrange the results with updated_at in descending order.

[Assistant] SELECT * FROM education.assignments ORDER BY updated_at DESC;

[User] Show me sum of image_url grouped by shares for assignments.

[Assistant] SELECT shares, SUM(image_url) AS sum_image_url FROM education.assignments GROUP BY shares;


[User] What are the category, currency, created_at of each department?

[Assistant] SELECT category, currency, created_at FROM education.departments;

[User] Arrange the results with created_at in ascending order.

[Assistant] SELECT category, currency, created_at FROM education.departments ORDER BY created_at ASC;

[User] Get the distribution of departments across different currency values.

[Assistant] SELECT currency, COUNT(*) AS count FROM education.departments GROUP BY currency ORDER BY count DESC;


[User] Get all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Sort the results by updated_at descending.

[Assistant] SELECT * FROM education.assignments ORDER BY updated_at DESC;

[User] Can you order these by likes descending?

[Assistant] SELECT * FROM education.assignments ORDER BY likes DESC;


[User] Show me all grades.

[Assistant] SELECT * FROM education.grades;

[User] Sort the results by payment_method ascending.

[Assistant] SELECT * FROM education.grades ORDER BY payment_method ASC;

[User] Arrange the results with cancelled_at in ascending order.

[Assistant] SELECT * FROM education.grades ORDER BY cancelled_at ASC;


[User] List all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] List assignments that have text LIKE 'A%'.

[Assistant] SELECT * FROM education.assignments WHERE text LIKE 'A%';

[User] Only show the top 100 results.

[Assistant] SELECT * FROM education.assignments WHERE text LIKE 'A%' LIMIT 100;


[User] Get all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Retrieve assignments where the date is modified within the last hour.

[Assistant] SELECT * FROM education.assignments WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Count the number of assignments in each likes category.

[Assistant] SELECT likes, COUNT(*) AS count FROM education.assignments GROUP BY likes ORDER BY count DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.categories (
  account_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  reconciliation_status text NOT NULL,
  amount bigint,
  credit character varying(64) NOT NULL,
  payer_id varchar,
  verification_status char,
  product_id text NOT NULL -- reference to products.sku,
  FOREIGN KEY (product_id) REFERENCES products(sku)
)

CREATE TABLE e-commerce.products (
  sku varchar PRIMARY KEY -- unique identifier,
  expires_at date,
  quantity char,
  available varchar NOT NULL,
  stock_level char,
  manufacturer character varying(64),
  categorie_id text NOT NULL -- reference to categories.account_id,
  FOREIGN KEY (categorie_id) REFERENCES categories(account_id)
)

[User] What are the stock_level, manufacturer, quantity of each product?

[Assistant] SELECT stock_level, manufacturer, quantity FROM e-commerce.products;

[User] Find products from last week.

[Assistant] SELECT stock_level, manufacturer, quantity FROM e-commerce.products WHERE expires_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Can you order these by quantity ascending?

[Assistant] SELECT stock_level, manufacturer, quantity FROM e-commerce.products WHERE expires_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY quantity ASC;


[User] Get amount, credit, reconciliation_status from all categories.

[Assistant] SELECT amount, credit, reconciliation_status FROM e-commerce.categories;

[User] Get credit, created_at, stock_level, categorie_id by joining categories with products.

[Assistant] SELECT amount, credit, reconciliation_status, products.stock_level, products.categorie_id FROM e-commerce.categories JOIN e-commerce.products ON categories.product_id = products.sku;

[User] Show me max of created_at grouped by credit for categories.

[Assistant] SELECT credit, MAX(created_at) AS max_created_at FROM e-commerce.categories GROUP BY credit;


[User] List all products.

[Assistant] SELECT * FROM e-commerce.products;

[User] What quantity, expires_at, reconciliation_status, payer_id do we have for products and their associated categories?

[Assistant] SELECT *, categories.reconciliation_status, categories.payer_id FROM e-commerce.products JOIN e-commerce.categories ON products.categorie_id = categories.account_id;

[User] Calculate max of categorie_id for each quantity in products.

[Assistant] SELECT quantity, MAX(categorie_id) AS max_categorie_id FROM e-commerce.products GROUP BY quantity;


[User] Show me available, stock_level, expires_at for all products.

[Assistant] SELECT available, stock_level, expires_at FROM e-commerce.products;

[User] List products that have stock_level LIKE 'A%'.

[Assistant] SELECT available, stock_level, expires_at FROM e-commerce.products WHERE stock_level LIKE 'A%';

[User] Return just 20 rows.

[Assistant] SELECT available, stock_level, expires_at FROM e-commerce.products WHERE stock_level LIKE 'A%' LIMIT 20;


[User] List all products.

[Assistant] SELECT * FROM e-commerce.products;

[User] What expires_at, quantity, amount, reconciliation_status do we have for products and their associated categories?

[Assistant] SELECT *, categories.amount, categories.reconciliation_status FROM e-commerce.products JOIN e-commerce.categories ON products.categorie_id = categories.account_id;

[User] Show only 20 records.

[Assistant] SELECT *, categories.amount, categories.reconciliation_status FROM e-commerce.products JOIN e-commerce.categories ON products.categorie_id = categories.account_id LIMIT 20;


[User] Show me all categories.

[Assistant] SELECT * FROM e-commerce.categories;

[User] Show me categories that were between January and March.

[Assistant] SELECT * FROM e-commerce.categories WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Group categories by created_at and show the count of reconciliation_status.

[Assistant] SELECT created_at, COUNT(reconciliation_status) AS count_reconciliation_status FROM e-commerce.categories GROUP BY created_at;


[User] Show me all categories.

[Assistant] SELECT * FROM e-commerce.categories;

[User] Show me verification_status, amount, stock_level, manufacturer from categories and their related products.

[Assistant] SELECT *, products.stock_level, products.manufacturer FROM e-commerce.categories JOIN e-commerce.products ON categories.product_id = products.sku;

[User] Group categories by verification_status and show the average of credit.

[Assistant] SELECT verification_status, AVERAGE(credit) AS average_credit FROM e-commerce.categories GROUP BY verification_status;


[User] Show me all categories.

[Assistant] SELECT * FROM e-commerce.categories;

[User] Find categories created yesterday.

[Assistant] SELECT * FROM e-commerce.categories WHERE created_at = CURRENT_DATE - INTERVAL '1 day';

[User] Order the output by verification_status ascending.

[Assistant] SELECT * FROM e-commerce.categories WHERE created_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY verification_status ASC;


[User] List stock_level, expires_at, manufacturer from products.

[Assistant] SELECT stock_level, expires_at, manufacturer FROM e-commerce.products;

[User] Get available, quantity, created_at, reconciliation_status by joining products with categories.

[Assistant] SELECT stock_level, expires_at, manufacturer, categories.created_at, categories.reconciliation_status FROM e-commerce.products JOIN e-commerce.categories ON products.categorie_id = categories.account_id;

[User] Get the distribution of products across different categorie_id values.

[Assistant] SELECT categorie_id, COUNT(*) AS count FROM e-commerce.products GROUP BY categorie_id ORDER BY count DESC;


[User] List product_id, amount, verification_status from categories.

[Assistant] SELECT product_id, amount, verification_status FROM e-commerce.categories;

[User] List categories with dates from 2023.

[Assistant] SELECT product_id, amount, verification_status FROM e-commerce.categories WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Return just 25 rows.

[Assistant] SELECT product_id, amount, verification_status FROM e-commerce.categories WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 25;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.loans (
  sku integer PRIMARY KEY -- unique identifier,
  expires_at date,
  rating character varying(256),
  msrp character varying(256) NOT NULL,
  media_url character varying(128),
  image_url text NOT NULL,
  payment_id text NOT NULL -- reference to payments.transaction_id,
  FOREIGN KEY (payment_id) REFERENCES payments(transaction_id)
)

CREATE TABLE finance.payments (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  completed_at date,
  card_type text,
  quantity character varying(128),
  approval_status varchar,
  fee text,
  account_id character varying(256) NOT NULL -- identifier for account,
  customer_id text -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

CREATE TABLE finance.investments (
  id character varying(64) NOT NULL -- unique identifier,
  payment_date date,
  due_date timestamp,
  reconciliation_status char,
  invoice_number char,
  user_id char NOT NULL -- identifier for user
)

CREATE TABLE finance.customers (
  employee_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  last_active timestamp,
  timezone text,
  salt text NOT NULL,
  is_active boolean NOT NULL
)

[User] Show me all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Get all payments older than 6 months.

[Assistant] SELECT * FROM finance.payments WHERE completed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Calculate sum of approval_status for each approval_status in payments.

[Assistant] SELECT approval_status, SUM(approval_status) AS sum_approval_status FROM finance.payments GROUP BY approval_status;


[User] Show me expires_at, media_url, image_url for all loans.

[Assistant] SELECT expires_at, media_url, image_url FROM finance.loans;

[User] Find loans where media_url LIKE 'A%'.

[Assistant] SELECT expires_at, media_url, image_url FROM finance.loans WHERE media_url LIKE 'A%';

[User] Show the results sorted by expires_at ascending.

[Assistant] SELECT expires_at, media_url, image_url FROM finance.loans WHERE media_url LIKE 'A%' ORDER BY expires_at ASC;


[User] Retrieve completed_at, quantity, fee for every payment.

[Assistant] SELECT completed_at, quantity, fee FROM finance.payments;

[User] Find payments where created_at > '2023-01-01'.

[Assistant] SELECT completed_at, quantity, fee FROM finance.payments WHERE created_at > '2023-01-01';

[User] Show me min of account_id grouped by account_id for payments.

[Assistant] SELECT account_id, MIN(account_id) AS min_account_id FROM finance.payments GROUP BY account_id;


[User] List msrp, payment_id, media_url from loans.

[Assistant] SELECT msrp, payment_id, media_url FROM finance.loans;

[User] Show me payment_id, media_url, card_type, quantity from loans and their related payments.

[Assistant] SELECT msrp, payment_id, media_url, payments.card_type, payments.quantity FROM finance.loans JOIN finance.payments ON loans.payment_id = payments.transaction_id;

[User] Only show the top 20 results.

[Assistant] SELECT msrp, payment_id, media_url, payments.card_type, payments.quantity FROM finance.loans JOIN finance.payments ON loans.payment_id = payments.transaction_id LIMIT 20;


[User] What are the expires_at, payment_id, media_url of each loan?

[Assistant] SELECT expires_at, payment_id, media_url FROM finance.loans;

[User] Find loans where rating LIKE 'A%'.

[Assistant] SELECT expires_at, payment_id, media_url FROM finance.loans WHERE rating LIKE 'A%';

[User] Arrange the results with media_url in descending order.

[Assistant] SELECT expires_at, payment_id, media_url FROM finance.loans WHERE rating LIKE 'A%' ORDER BY media_url DESC;


[User] Retrieve payment_id, rating, expires_at for every loan.

[Assistant] SELECT payment_id, rating, expires_at FROM finance.loans;

[User] Retrieve image_url, msrp, created_at, card_type showing the relationship between loans and payments.

[Assistant] SELECT payment_id, rating, expires_at, payments.created_at, payments.card_type FROM finance.loans JOIN finance.payments ON loans.payment_id = payments.transaction_id;

[User] Limit the results to 5 rows.

[Assistant] SELECT payment_id, rating, expires_at, payments.created_at, payments.card_type FROM finance.loans JOIN finance.payments ON loans.payment_id = payments.transaction_id LIMIT 5;


[User] List all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Find payments where created_at > '2023-01-01'.

[Assistant] SELECT * FROM finance.payments WHERE created_at > '2023-01-01';

[User] Show only 15 records.

[Assistant] SELECT * FROM finance.payments WHERE created_at > '2023-01-01' LIMIT 15;


[User] Display all payments.

[Assistant] SELECT * FROM finance.payments;

[User] List payments that have completed_at > '2023-01-01'.

[Assistant] SELECT * FROM finance.payments WHERE completed_at > '2023-01-01';

[User] Show only 10 records.

[Assistant] SELECT * FROM finance.payments WHERE completed_at > '2023-01-01' LIMIT 10;


[User] Show me customer_id, approval_status, account_id for all payments.

[Assistant] SELECT customer_id, approval_status, account_id FROM finance.payments;

[User] Show me payments that were created after December 1st, 2023.

[Assistant] SELECT customer_id, approval_status, account_id FROM finance.payments WHERE created_at > '2023-12-01';

[User] Get the distribution of payments across different fee values.

[Assistant] SELECT fee, COUNT(*) AS count FROM finance.payments GROUP BY fee ORDER BY count DESC;


[User] Get payment_id, media_url, rating from all loans.

[Assistant] SELECT payment_id, media_url, rating FROM finance.loans;

[User] Get all loans modified within the last hour.

[Assistant] SELECT payment_id, media_url, rating FROM finance.loans WHERE expires_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Group loans by payment_id and show the sum of msrp.

[Assistant] SELECT payment_id, SUM(msrp) AS sum_msrp FROM finance.loans GROUP BY payment_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.users (
  customer_id integer PRIMARY KEY -- unique identifier,
  last_active timestamp,
  joined_at date,
  website character varying(256),
  timezone varchar,
  status text,
  order_item_id integer NOT NULL -- reference to order_items.transaction_id,
  FOREIGN KEY (order_item_id) REFERENCES order_items(transaction_id)
)

CREATE TABLE e-commerce.order_items (
  transaction_id integer PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  completed_at date,
  price decimal NOT NULL,
  delivery_status varchar,
  amount integer,
  payment_status varchar NOT NULL,
  exchange_rate text NOT NULL,
  user_id integer NOT NULL -- reference to users.customer_id,
  FOREIGN KEY (user_id) REFERENCES users(customer_id)
)

[User] List all order_items.

[Assistant] SELECT * FROM e-commerce.order_items;

[User] List order_items with dates created in the last 30 days.

[Assistant] SELECT * FROM e-commerce.order_items WHERE completed_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Can you order these by delivery_status ascending?

[Assistant] SELECT * FROM e-commerce.order_items WHERE completed_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY delivery_status ASC;


[User] Retrieve joined_at, timezone, last_active for every user.

[Assistant] SELECT joined_at, timezone, last_active FROM e-commerce.users;

[User] Can you order these by order_item_id descending?

[Assistant] SELECT joined_at, timezone, last_active FROM e-commerce.users ORDER BY order_item_id DESC;

[User] Get the distribution of users across different joined_at values.

[Assistant] SELECT joined_at, COUNT(*) AS count FROM e-commerce.users GROUP BY joined_at ORDER BY count DESC;


[User] Get completed_at, amount, payment_status from all order_items.

[Assistant] SELECT completed_at, amount, payment_status FROM e-commerce.order_items;

[User] Show me payment_status, exchange_rate, order_item_id, status from order_items and their related users.

[Assistant] SELECT completed_at, amount, payment_status, users.order_item_id, users.status FROM e-commerce.order_items JOIN e-commerce.users ON order_items.user_id = users.customer_id;

[User] Show me the count of order_items grouped by processed_at.

[Assistant] SELECT processed_at, COUNT(*) AS count FROM e-commerce.order_items GROUP BY processed_at ORDER BY count DESC;


[User] Retrieve last_active, timezone, website for every user.

[Assistant] SELECT last_active, timezone, website FROM e-commerce.users;

[User] Get website, joined_at, amount, exchange_rate by joining users with order_items.

[Assistant] SELECT last_active, timezone, website, order_items.amount, order_items.exchange_rate FROM e-commerce.users JOIN e-commerce.order_items ON users.order_item_id = order_items.transaction_id;

[User] Show only 50 records.

[Assistant] SELECT last_active, timezone, website, order_items.amount, order_items.exchange_rate FROM e-commerce.users JOIN e-commerce.order_items ON users.order_item_id = order_items.transaction_id LIMIT 50;


[User] List last_active, website, joined_at from users.

[Assistant] SELECT last_active, website, joined_at FROM e-commerce.users;

[User] Arrange the results with last_active in descending order.

[Assistant] SELECT last_active, website, joined_at FROM e-commerce.users ORDER BY last_active DESC;

[User] Restrict the output to 20 items.

[Assistant] SELECT last_active, website, joined_at FROM e-commerce.users ORDER BY last_active DESC LIMIT 20;


[User] Retrieve all order_items.

[Assistant] SELECT * FROM e-commerce.order_items;

[User] Retrieve order_items where the date is between January and March.

[Assistant] SELECT * FROM e-commerce.order_items WHERE processed_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Sort the results by completed_at ascending.

[Assistant] SELECT * FROM e-commerce.order_items WHERE processed_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY completed_at ASC;


[User] Show me price, completed_at, amount for all order_items.

[Assistant] SELECT price, completed_at, amount FROM e-commerce.order_items;

[User] Get all order_items created in the last 30 days.

[Assistant] SELECT price, completed_at, amount FROM e-commerce.order_items WHERE completed_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Group order_items by delivery_status and show the sum of payment_status.

[Assistant] SELECT delivery_status, SUM(payment_status) AS sum_payment_status FROM e-commerce.order_items GROUP BY delivery_status;


[User] Retrieve price, amount, exchange_rate for every order_item.

[Assistant] SELECT price, amount, exchange_rate FROM e-commerce.order_items;

[User] Get all order_items created in the last 30 days.

[Assistant] SELECT price, amount, exchange_rate FROM e-commerce.order_items WHERE processed_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Sort the results by exchange_rate descending.

[Assistant] SELECT price, amount, exchange_rate FROM e-commerce.order_items WHERE processed_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY exchange_rate DESC;


[User] What are the amount, user_id, price of each order_item?

[Assistant] SELECT amount, user_id, price FROM e-commerce.order_items;

[User] Sort the results by exchange_rate descending.

[Assistant] SELECT amount, user_id, price FROM e-commerce.order_items ORDER BY exchange_rate DESC;

[User] Tally up order_items by user_id.

[Assistant] SELECT user_id, COUNT(*) AS count FROM e-commerce.order_items GROUP BY user_id ORDER BY count DESC;


[User] Display all order_items.

[Assistant] SELECT * FROM e-commerce.order_items;

[User] Retrieve order_items where price > 29.

[Assistant] SELECT * FROM e-commerce.order_items WHERE price > 29;

[User] How many order_items are there per delivery_status?

[Assistant] SELECT delivery_status, COUNT(*) AS count FROM e-commerce.order_items GROUP BY delivery_status ORDER BY count DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.students (
  customer_id character varying(64) NOT NULL -- unique identifier,
  last_active date,
  created_at timestamp without time zone,
  is_verified bit,
  status character varying(256),
  address character varying(128),
  enrollment_id text -- reference to enrollments.id,
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(id)
)

CREATE TABLE education.enrollments (
  id varchar PRIMARY KEY -- unique identifier,
  due_date timestamp without time zone,
  updated_at timestamp without time zone,
  reconciliation_status char NOT NULL,
  customer_id text,
  amount integer NOT NULL,
  currency character varying(64),
  payee_id character varying(128) -- identifier for payee,
  reference_number character varying(256),
  exchange_rate character varying(256)
)

CREATE TABLE education.grades (
  account_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  verification_status character varying(64),
  user_id character varying(256) -- identifier for user,
  status char NOT NULL,
  balance bigint,
  customer_id character varying(64)
)

[User] What are the enrollment_id, last_active, address of each student?

[Assistant] SELECT enrollment_id, last_active, address FROM education.students;

[User] Sort the results by enrollment_id descending.

[Assistant] SELECT enrollment_id, last_active, address FROM education.students ORDER BY enrollment_id DESC;

[User] Show me the count of students grouped by customer_id.

[Assistant] SELECT customer_id, COUNT(*) AS count FROM education.students GROUP BY customer_id ORDER BY count DESC;


[User] Show me customer_id, created_at, last_active for all students.

[Assistant] SELECT customer_id, created_at, last_active FROM education.students;

[User] Sort the results by last_active descending.

[Assistant] SELECT customer_id, created_at, last_active FROM education.students ORDER BY last_active DESC;

[User] How many students are there per created_at?

[Assistant] SELECT created_at, COUNT(*) AS count FROM education.students GROUP BY created_at ORDER BY count DESC;


[User] Get all students.

[Assistant] SELECT * FROM education.students;

[User] Retrieve students where the date is created in the last 30 days.

[Assistant] SELECT * FROM education.students WHERE last_active >= CURRENT_DATE - INTERVAL '30 days';

[User] Can you order these by status descending?

[Assistant] SELECT * FROM education.students WHERE last_active >= CURRENT_DATE - INTERVAL '30 days' ORDER BY status DESC;


[User] Get all students.

[Assistant] SELECT * FROM education.students;

[User] Can you order these by customer_id ascending?

[Assistant] SELECT * FROM education.students ORDER BY customer_id ASC;

[User] Arrange the results with address in descending order.

[Assistant] SELECT * FROM education.students ORDER BY address DESC;


[User] Get address, customer_id, is_verified from all students.

[Assistant] SELECT address, customer_id, is_verified FROM education.students;

[User] Can you order these by is_verified ascending?

[Assistant] SELECT address, customer_id, is_verified FROM education.students ORDER BY is_verified ASC;

[User] Get the distribution of students across different created_at values.

[Assistant] SELECT created_at, COUNT(*) AS count FROM education.students GROUP BY created_at ORDER BY count DESC;


[User] Get last_active, status, created_at from all students.

[Assistant] SELECT last_active, status, created_at FROM education.students;

[User] Show me students with last_active > '2023-01-01'.

[Assistant] SELECT last_active, status, created_at FROM education.students WHERE last_active > '2023-01-01';

[User] How many students are there per customer_id?

[Assistant] SELECT customer_id, COUNT(*) AS count FROM education.students GROUP BY customer_id ORDER BY count DESC;


[User] Retrieve created_at, customer_id, is_verified for every student.

[Assistant] SELECT created_at, customer_id, is_verified FROM education.students;

[User] List students with dates between January and March.

[Assistant] SELECT created_at, customer_id, is_verified FROM education.students WHERE last_active BETWEEN '2023-01-01' AND '2023-03-31';

[User] Show only 25 records.

[Assistant] SELECT created_at, customer_id, is_verified FROM education.students WHERE last_active BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 25;


[User] Retrieve status, last_active, address for every student.

[Assistant] SELECT status, last_active, address FROM education.students;

[User] Show the results sorted by last_active ascending.

[Assistant] SELECT status, last_active, address FROM education.students ORDER BY last_active ASC;

[User] Get sum of customer_id by last_active from students.

[Assistant] SELECT last_active, SUM(customer_id) AS sum_customer_id FROM education.students GROUP BY last_active;


[User] Show me is_verified, enrollment_id, created_at for all students.

[Assistant] SELECT is_verified, enrollment_id, created_at FROM education.students;

[User] Can you order these by is_verified descending?

[Assistant] SELECT is_verified, enrollment_id, created_at FROM education.students ORDER BY is_verified DESC;

[User] Sort the results by last_active descending.

[Assistant] SELECT is_verified, enrollment_id, created_at FROM education.students ORDER BY last_active DESC;


[User] Get all students.

[Assistant] SELECT * FROM education.students;

[User] Get all students created yesterday.

[Assistant] SELECT * FROM education.students WHERE last_active = CURRENT_DATE - INTERVAL '1 day';

[User] Limit the results to 20 rows.

[Assistant] SELECT * FROM education.students WHERE last_active = CURRENT_DATE - INTERVAL '1 day' LIMIT 20;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE banking.sales (
  payment_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  payment_status character varying(256),
  fee text NOT NULL,
  payment_method character varying(64),
  exchange_rate character varying(256),
  approval_status character varying(128),
  amount decimal
)

CREATE TABLE banking.clients (
  user_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  joined_at date,
  email character varying(256),
  is_verified boolean NOT NULL,
  status character varying(64),
  website character varying(64) NOT NULL,
  password_hash character varying(128) NOT NULL,
  payment_id text -- reference to payments.id,
  FOREIGN KEY (payment_id) REFERENCES payments(id)
)

CREATE TABLE banking.payments (
  id text PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  status char,
  reference_number text,
  reconciliation_status varchar NOT NULL,
  debit text,
  approval_status text,
  category text,
  sale_id text -- reference to sales.payment_id,
  FOREIGN KEY (sale_id) REFERENCES sales(payment_id)
)

[User] Get all clients.

[Assistant] SELECT * FROM banking.clients;

[User] Arrange the results with status in descending order.

[Assistant] SELECT * FROM banking.clients ORDER BY status DESC;

[User] What is the max joined_at for each joined_at in clients?

[Assistant] SELECT joined_at, MAX(joined_at) AS max_joined_at FROM banking.clients GROUP BY joined_at;


[User] Get reconciliation_status, reference_number, sale_id from all payments.

[Assistant] SELECT reconciliation_status, reference_number, sale_id FROM banking.payments;

[User] Show the results sorted by reference_number descending.

[Assistant] SELECT reconciliation_status, reference_number, sale_id FROM banking.payments ORDER BY reference_number DESC;

[User] Only show the top 20 results.

[Assistant] SELECT reconciliation_status, reference_number, sale_id FROM banking.payments ORDER BY reference_number DESC LIMIT 20;


[User] Retrieve all payments.

[Assistant] SELECT * FROM banking.payments;

[User] Show me payments that were between January and March.

[Assistant] SELECT * FROM banking.payments WHERE payment_date BETWEEN '2023-01-01' AND '2023-03-31';

[User] Return just 50 rows.

[Assistant] SELECT * FROM banking.payments WHERE payment_date BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 50;


[User] Display all payments.

[Assistant] SELECT * FROM banking.payments;

[User] Find payments created yesterday.

[Assistant] SELECT * FROM banking.payments WHERE payment_date = CURRENT_DATE - INTERVAL '1 day';

[User] Count the number of payments in each approval_status category.

[Assistant] SELECT approval_status, COUNT(*) AS count FROM banking.payments GROUP BY approval_status ORDER BY count DESC;


[User] List approval_status, status, reconciliation_status from payments.

[Assistant] SELECT approval_status, status, reconciliation_status FROM banking.payments;

[User] Can you order these by reconciliation_status descending?

[Assistant] SELECT approval_status, status, reconciliation_status FROM banking.payments ORDER BY reconciliation_status DESC;

[User] Order the output by sale_id ascending.

[Assistant] SELECT approval_status, status, reconciliation_status FROM banking.payments ORDER BY sale_id ASC;


[User] What are the email, is_verified, website of each client?

[Assistant] SELECT email, is_verified, website FROM banking.clients;

[User] List clients with dates created in the last 30 days.

[Assistant] SELECT email, is_verified, website FROM banking.clients WHERE joined_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Group clients by password_hash and show the count of email.

[Assistant] SELECT password_hash, COUNT(email) AS count_email FROM banking.clients GROUP BY password_hash;


[User] Show me all clients.

[Assistant] SELECT * FROM banking.clients;

[User] List status, is_verified, sale_id, debit for each client along with their payment information.

[Assistant] SELECT *, payments.sale_id, payments.debit FROM banking.clients JOIN banking.payments ON clients.payment_id = payments.id;

[User] Restrict the output to 50 items.

[Assistant] SELECT *, payments.sale_id, payments.debit FROM banking.clients JOIN banking.payments ON clients.payment_id = payments.id LIMIT 50;


[User] List user_id, joined_at, updated_at from clients.

[Assistant] SELECT user_id, joined_at, updated_at FROM banking.clients;

[User] Get clients that match updated_at > '2023-01-01'.

[Assistant] SELECT user_id, joined_at, updated_at FROM banking.clients WHERE updated_at > '2023-01-01';

[User] Get average of user_id by status from clients.

[Assistant] SELECT status, AVERAGE(user_id) AS average_user_id FROM banking.clients GROUP BY status;


[User] List all payments.

[Assistant] SELECT * FROM banking.payments;

[User] Sort the results by payment_date descending.

[Assistant] SELECT * FROM banking.payments ORDER BY payment_date DESC;

[User] Calculate sum of reference_number for each sale_id in payments.

[Assistant] SELECT sale_id, SUM(reference_number) AS sum_reference_number FROM banking.payments GROUP BY sale_id;


[User] Get reference_number, reconciliation_status, sale_id from all payments.

[Assistant] SELECT reference_number, reconciliation_status, sale_id FROM banking.payments;

[User] What payment_date, debit, payment_status, exchange_rate do we have for payments and their associated sales?

[Assistant] SELECT reference_number, reconciliation_status, sale_id, sales.payment_status, sales.exchange_rate FROM banking.payments JOIN banking.sales ON payments.sale_id = sales.payment_id;

[User] How many payments are there per status?

[Assistant] SELECT status, COUNT(*) AS count FROM banking.payments GROUP BY status ORDER BY count DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE retail.clients (
  employee_id character varying(64) NOT NULL -- unique identifier,
  joined_at timestamp,
  created_at timestamp without time zone,
  avatar text NOT NULL,
  phone character varying(64) NOT NULL,
  country char,
  age char,
  birth_date date,
  booking_id text -- reference to bookings.id,
  FOREIGN KEY (booking_id) REFERENCES bookings(id)
)

CREATE TABLE retail.goods (
  product_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  price bigint,
  tax_rate text,
  rating text,
  stock_level text NOT NULL,
  title character varying(256)
)

CREATE TABLE retail.bookings (
  id text PRIMARY KEY -- unique identifier,
  cancelled_at timestamp without time zone,
  completed_at date,
  currency varchar,
  status char,
  delivery_status character varying(128),
  price decimal NOT NULL
)

[User] Retrieve phone, booking_id, created_at for every client.

[Assistant] SELECT phone, booking_id, created_at FROM retail.clients;

[User] Get all clients created in the last 30 days.

[Assistant] SELECT phone, booking_id, created_at FROM retail.clients WHERE joined_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Show me max of employee_id grouped by created_at for clients.

[Assistant] SELECT created_at, MAX(employee_id) AS max_employee_id FROM retail.clients GROUP BY created_at;


[User] List all clients.

[Assistant] SELECT * FROM retail.clients;

[User] Retrieve clients where employee_id LIKE 'A%'.

[Assistant] SELECT * FROM retail.clients WHERE employee_id LIKE 'A%';

[User] Limit the results to 20 rows.

[Assistant] SELECT * FROM retail.clients WHERE employee_id LIKE 'A%' LIMIT 20;


[User] What are the age, country, joined_at of each client?

[Assistant] SELECT age, country, joined_at FROM retail.clients;

[User] Get avatar, country, cancelled_at, status by joining clients with bookings.

[Assistant] SELECT age, country, joined_at, bookings.cancelled_at, bookings.status FROM retail.clients JOIN retail.bookings ON clients.booking_id = bookings.id;

[User] Can you order these by created_at ascending?

[Assistant] SELECT age, country, joined_at, bookings.cancelled_at, bookings.status FROM retail.clients JOIN retail.bookings ON clients.booking_id = bookings.id ORDER BY created_at ASC;


[User] Show me all clients.

[Assistant] SELECT * FROM retail.clients;

[User] Retrieve clients where avatar LIKE 'A%'.

[Assistant] SELECT * FROM retail.clients WHERE avatar LIKE 'A%';

[User] Show the results sorted by employee_id descending.

[Assistant] SELECT * FROM retail.clients WHERE avatar LIKE 'A%' ORDER BY employee_id DESC;


[User] Get booking_id, employee_id, avatar from all clients.

[Assistant] SELECT booking_id, employee_id, avatar FROM retail.clients;

[User] Show me age, country, status, delivery_status from clients and their related bookings.

[Assistant] SELECT booking_id, employee_id, avatar, bookings.status, bookings.delivery_status FROM retail.clients JOIN retail.bookings ON clients.booking_id = bookings.id;

[User] Show the results sorted by birth_date ascending.

[Assistant] SELECT booking_id, employee_id, avatar, bookings.status, bookings.delivery_status FROM retail.clients JOIN retail.bookings ON clients.booking_id = bookings.id ORDER BY birth_date ASC;


[User] Retrieve avatar, birth_date, joined_at for every client.

[Assistant] SELECT avatar, birth_date, joined_at FROM retail.clients;

[User] Find clients where joined_at > '2023-01-01'.

[Assistant] SELECT avatar, birth_date, joined_at FROM retail.clients WHERE joined_at > '2023-01-01';

[User] Only show the top 100 results.

[Assistant] SELECT avatar, birth_date, joined_at FROM retail.clients WHERE joined_at > '2023-01-01' LIMIT 100;


[User] What are the employee_id, phone, age of each client?

[Assistant] SELECT employee_id, phone, age FROM retail.clients;

[User] List clients that have booking_id LIKE 'A%'.

[Assistant] SELECT employee_id, phone, age FROM retail.clients WHERE booking_id LIKE 'A%';

[User] Arrange the results with country in descending order.

[Assistant] SELECT employee_id, phone, age FROM retail.clients WHERE booking_id LIKE 'A%' ORDER BY country DESC;


[User] Show me all clients.

[Assistant] SELECT * FROM retail.clients;

[User] Show me clients with created_at > '2023-01-01'.

[Assistant] SELECT * FROM retail.clients WHERE created_at > '2023-01-01';

[User] Arrange the results with phone in descending order.

[Assistant] SELECT * FROM retail.clients WHERE created_at > '2023-01-01' ORDER BY phone DESC;


[User] Display all clients.

[Assistant] SELECT * FROM retail.clients;

[User] Retrieve clients where the date is between January and March.

[Assistant] SELECT * FROM retail.clients WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Count the number of clients in each created_at category.

[Assistant] SELECT created_at, COUNT(*) AS count FROM retail.clients GROUP BY created_at ORDER BY count DESC;


[User] What are the created_at, birth_date, employee_id of each client?

[Assistant] SELECT created_at, birth_date, employee_id FROM retail.clients;

[User] Find clients created after December 1st, 2023.

[Assistant] SELECT created_at, birth_date, employee_id FROM retail.clients WHERE joined_at > '2023-12-01';

[User] Arrange the results with avatar in ascending order.

[Assistant] SELECT created_at, birth_date, employee_id FROM retail.clients WHERE joined_at > '2023-12-01' ORDER BY avatar ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.departments (
  post_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  edited_at timestamp,
  rating text,
  parent_id varchar -- identifier for parent,
  views varchar,
  grade_id text NOT NULL -- reference to grades.account_id,
  FOREIGN KEY (grade_id) REFERENCES grades(account_id)
)

CREATE TABLE education.grades (
  account_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  updated_at timestamp without time zone,
  amount decimal NOT NULL,
  category text,
  payer_id character varying(64) -- identifier for payer,
  department_id text NOT NULL -- reference to departments.post_id,
  FOREIGN KEY (department_id) REFERENCES departments(post_id)
)

CREATE TABLE education.enrollments (
  id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  payment_date timestamp,
  reconciliation_status character varying(256),
  category character varying(256) NOT NULL,
  invoice_number character varying(128) NOT NULL,
  amount numeric(38,14),
  exchange_rate character varying(256) NOT NULL,
  grade_id text NOT NULL -- reference to grades.account_id,
  FOREIGN KEY (grade_id) REFERENCES grades(account_id)
)

[User] Retrieve all departments.

[Assistant] SELECT * FROM education.departments;

[User] List edited_at, created_at, processed_at, category for each department along with their grade information.

[Assistant] SELECT *, grades.processed_at, grades.category FROM education.departments JOIN education.grades ON departments.grade_id = grades.account_id;

[User] What is the count parent_id for each edited_at in departments?

[Assistant] SELECT edited_at, COUNT(parent_id) AS count_parent_id FROM education.departments GROUP BY edited_at;


[User] Retrieve rating, parent_id, grade_id for every department.

[Assistant] SELECT rating, parent_id, grade_id FROM education.departments;

[User] Find departments created yesterday.

[Assistant] SELECT rating, parent_id, grade_id FROM education.departments WHERE created_at = CURRENT_DATE - INTERVAL '1 day';

[User] Show only 10 records.

[Assistant] SELECT rating, parent_id, grade_id FROM education.departments WHERE created_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 10;


[User] List all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Can you order these by amount descending?

[Assistant] SELECT * FROM education.enrollments ORDER BY amount DESC;

[User] What is the average category for each invoice_number in enrollments?

[Assistant] SELECT invoice_number, AVERAGE(category) AS average_category FROM education.enrollments GROUP BY invoice_number;


[User] What are the processed_at, payer_id, amount of each grade?

[Assistant] SELECT processed_at, payer_id, amount FROM education.grades;

[User] Sort the results by amount descending.

[Assistant] SELECT processed_at, payer_id, amount FROM education.grades ORDER BY amount DESC;

[User] Sort the results by payer_id descending.

[Assistant] SELECT processed_at, payer_id, amount FROM education.grades ORDER BY payer_id DESC;


[User] Show me all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Retrieve enrollments where the date is modified within the last hour.

[Assistant] SELECT * FROM education.enrollments WHERE payment_date >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Get the distribution of enrollments across different grade_id values.

[Assistant] SELECT grade_id, COUNT(*) AS count FROM education.enrollments GROUP BY grade_id ORDER BY count DESC;


[User] List amount, updated_at, payer_id from grades.

[Assistant] SELECT amount, updated_at, payer_id FROM education.grades;

[User] Find grades created yesterday.

[Assistant] SELECT amount, updated_at, payer_id FROM education.grades WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Show me count of updated_at grouped by processed_at for grades.

[Assistant] SELECT processed_at, COUNT(updated_at) AS count_updated_at FROM education.grades GROUP BY processed_at;


[User] Display all departments.

[Assistant] SELECT * FROM education.departments;

[User] Find departments between January and March.

[Assistant] SELECT * FROM education.departments WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Only show the top 15 results.

[Assistant] SELECT * FROM education.departments WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 15;


[User] Display all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Get all enrollments created yesterday.

[Assistant] SELECT * FROM education.enrollments WHERE payment_date = CURRENT_DATE - INTERVAL '1 day';

[User] Show the results sorted by amount descending.

[Assistant] SELECT * FROM education.enrollments WHERE payment_date = CURRENT_DATE - INTERVAL '1 day' ORDER BY amount DESC;


[User] What are the parent_id, created_at, rating of each department?

[Assistant] SELECT parent_id, created_at, rating FROM education.departments;

[User] List departments that have created_at > '2023-01-01'.

[Assistant] SELECT parent_id, created_at, rating FROM education.departments WHERE created_at > '2023-01-01';

[User] Sort the results by grade_id ascending.

[Assistant] SELECT parent_id, created_at, rating FROM education.departments WHERE created_at > '2023-01-01' ORDER BY grade_id ASC;


[User] Get all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] List grade_id, created_at, department_id, processed_at for each enrollment along with their grade information.

[Assistant] SELECT *, grades.department_id, grades.processed_at FROM education.enrollments JOIN education.grades ON enrollments.grade_id = grades.account_id;

[User] Calculate min of exchange_rate for each id in enrollments.

[Assistant] SELECT id, MIN(exchange_rate) AS min_exchange_rate FROM education.enrollments GROUP BY id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.loans (
  payment_id text PRIMARY KEY -- unique identifier,
  cancelled_at date,
  created_at timestamp without time zone,
  currency character varying(64),
  subtotal decimal,
  payment_status character varying(256),
  customer_id character varying(128) -- identifier for customer,
  status character varying(64)
)

CREATE TABLE finance.customers (
  id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  password_hash text,
  email character varying(128),
  country char,
  account_status character varying(256) NOT NULL
)

[User] Retrieve email, password_hash, joined_at for every customer.

[Assistant] SELECT email, password_hash, joined_at FROM finance.customers;

[User] List customers with dates created yesterday.

[Assistant] SELECT email, password_hash, joined_at FROM finance.customers WHERE joined_at = CURRENT_DATE - INTERVAL '1 day';

[User] Get the distribution of customers across different email values.

[Assistant] SELECT email, COUNT(*) AS count FROM finance.customers GROUP BY email ORDER BY count DESC;


[User] What are the email, account_status, joined_at of each customer?

[Assistant] SELECT email, account_status, joined_at FROM finance.customers;

[User] Retrieve customers where joined_at > '2023-01-01'.

[Assistant] SELECT email, account_status, joined_at FROM finance.customers WHERE joined_at > '2023-01-01';

[User] Show me sum of country grouped by country for customers.

[Assistant] SELECT country, SUM(country) AS sum_country FROM finance.customers GROUP BY country;


[User] List account_status, password_hash, email from customers.

[Assistant] SELECT account_status, password_hash, email FROM finance.customers;

[User] Show the results sorted by account_status ascending.

[Assistant] SELECT account_status, password_hash, email FROM finance.customers ORDER BY account_status ASC;

[User] Order the output by joined_at descending.

[Assistant] SELECT account_status, password_hash, email FROM finance.customers ORDER BY joined_at DESC;


[User] Show me created_at, subtotal, payment_status for all loans.

[Assistant] SELECT created_at, subtotal, payment_status FROM finance.loans;

[User] Show the results sorted by currency descending.

[Assistant] SELECT created_at, subtotal, payment_status FROM finance.loans ORDER BY currency DESC;

[User] How many loans are there per payment_status?

[Assistant] SELECT payment_status, COUNT(*) AS count FROM finance.loans GROUP BY payment_status ORDER BY count DESC;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Find customers from 2023.

[Assistant] SELECT * FROM finance.customers WHERE joined_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Only show the top 10 results.

[Assistant] SELECT * FROM finance.customers WHERE joined_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 10;


[User] List password_hash, joined_at, email from customers.

[Assistant] SELECT password_hash, joined_at, email FROM finance.customers;

[User] Retrieve customers where email LIKE 'A%'.

[Assistant] SELECT password_hash, joined_at, email FROM finance.customers WHERE email LIKE 'A%';

[User] Show me max of joined_at grouped by password_hash for customers.

[Assistant] SELECT password_hash, MAX(joined_at) AS max_joined_at FROM finance.customers GROUP BY password_hash;


[User] Get all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Show me loans with currency LIKE 'A%'.

[Assistant] SELECT * FROM finance.loans WHERE currency LIKE 'A%';

[User] How many loans are there per created_at?

[Assistant] SELECT created_at, COUNT(*) AS count FROM finance.loans GROUP BY created_at ORDER BY count DESC;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Show me customers with joined_at > '2023-01-01'.

[Assistant] SELECT * FROM finance.customers WHERE joined_at > '2023-01-01';

[User] Show the results sorted by password_hash ascending.

[Assistant] SELECT * FROM finance.customers WHERE joined_at > '2023-01-01' ORDER BY password_hash ASC;


[User] What are the email, password_hash, joined_at of each customer?

[Assistant] SELECT email, password_hash, joined_at FROM finance.customers;

[User] Show me customers that were created in the last 30 days.

[Assistant] SELECT email, password_hash, joined_at FROM finance.customers WHERE joined_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Restrict the output to 15 items.

[Assistant] SELECT email, password_hash, joined_at FROM finance.customers WHERE joined_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 15;


[User] Show me password_hash, email, account_status for all customers.

[Assistant] SELECT password_hash, email, account_status FROM finance.customers;

[User] Show the results sorted by account_status descending.

[Assistant] SELECT password_hash, email, account_status FROM finance.customers ORDER BY account_status DESC;

[User] Return just 20 rows.

[Assistant] SELECT password_hash, email, account_status FROM finance.customers ORDER BY account_status DESC LIMIT 20;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.users (
  user_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  updated_at timestamp without time zone,
  account_status character varying(64),
  token char NOT NULL,
  is_active boolean,
  password_hash character varying(128) NOT NULL,
  phone character varying(64),
  last_name character varying(128),
  zip_code varchar NOT NULL,
  order_item_id text NOT NULL -- reference to order_items.barcode,
  FOREIGN KEY (order_item_id) REFERENCES order_items(barcode)
)

CREATE TABLE e-commerce.shipping (
  payment_id integer PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  created_at timestamp,
  tax numeric,
  delivery_status character varying(64) NOT NULL,
  payment_method character varying(256),
  amount integer,
  product_id text,
  order_item_id text NOT NULL -- reference to order_items.barcode,
  FOREIGN KEY (order_item_id) REFERENCES order_items(barcode)
)

CREATE TABLE e-commerce.order_items (
  barcode varchar PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  updated_at timestamp,
  brand varchar,
  quantity character varying(64) NOT NULL,
  featured_rank character varying(256),
  views varchar,
  shippin_id integer NOT NULL -- reference to shipping.payment_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(payment_id)
)

[User] Get all shipping.

[Assistant] SELECT * FROM e-commerce.shipping;

[User] List shipping that have product_id LIKE 'A%'.

[Assistant] SELECT * FROM e-commerce.shipping WHERE product_id LIKE 'A%';

[User] Get sum of payment_method by order_item_id from shipping.

[Assistant] SELECT order_item_id, SUM(payment_method) AS sum_payment_method FROM e-commerce.shipping GROUP BY order_item_id;


[User] Show me all order_items.

[Assistant] SELECT * FROM e-commerce.order_items;

[User] List order_items with dates created in the last 30 days.

[Assistant] SELECT * FROM e-commerce.order_items WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Sort the results by views descending.

[Assistant] SELECT * FROM e-commerce.order_items WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY views DESC;


[User] List all users.

[Assistant] SELECT * FROM e-commerce.users;

[User] Retrieve users where the date is created after December 1st, 2023.

[Assistant] SELECT * FROM e-commerce.users WHERE updated_at > '2023-12-01';

[User] Count the number of users in each is_active category.

[Assistant] SELECT is_active, COUNT(*) AS count FROM e-commerce.users GROUP BY is_active ORDER BY count DESC;


[User] Display all shipping.

[Assistant] SELECT * FROM e-commerce.shipping;

[User] Find shipping created in the last 30 days.

[Assistant] SELECT * FROM e-commerce.shipping WHERE processed_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Group shipping by order_item_id and show the sum of tax.

[Assistant] SELECT order_item_id, SUM(tax) AS sum_tax FROM e-commerce.shipping GROUP BY order_item_id;


[User] Get all users.

[Assistant] SELECT * FROM e-commerce.users;

[User] Get users that match account_status LIKE 'A%'.

[Assistant] SELECT * FROM e-commerce.users WHERE account_status LIKE 'A%';

[User] Group users by account_status and show the max of token.

[Assistant] SELECT account_status, MAX(token) AS max_token FROM e-commerce.users GROUP BY account_status;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.students (
  person_id character varying(64) NOT NULL -- unique identifier,
  last_active date,
  birth_date timestamp without time zone,
  country character varying(256),
  timezone character varying(128),
  token character varying(128),
  first_name char,
  username varchar NOT NULL,
  assignment_id text -- reference to assignments.id,
  FOREIGN KEY (assignment_id) REFERENCES assignments(id)
)

CREATE TABLE education.assignments (
  id text PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  last_active timestamp without time zone,
  username character varying(64),
  language character varying(256),
  zip_code character varying(128) NOT NULL,
  full_name text
)

[User] Show me last_active, person_id, username for all students.

[Assistant] SELECT last_active, person_id, username FROM education.students;

[User] List students with dates older than 6 months.

[Assistant] SELECT last_active, person_id, username FROM education.students WHERE birth_date <= CURRENT_DATE - INTERVAL '6 months';

[User] Count the number of students in each username category.

[Assistant] SELECT username, COUNT(*) AS count FROM education.students GROUP BY username ORDER BY count DESC;


[User] What are the username, token, assignment_id of each student?

[Assistant] SELECT username, token, assignment_id FROM education.students;

[User] List students with dates older than 6 months.

[Assistant] SELECT username, token, assignment_id FROM education.students WHERE last_active <= CURRENT_DATE - INTERVAL '6 months';

[User] Show the results sorted by first_name descending.

[Assistant] SELECT username, token, assignment_id FROM education.students WHERE last_active <= CURRENT_DATE - INTERVAL '6 months' ORDER BY first_name DESC;


[User] Show me all students.

[Assistant] SELECT * FROM education.students;

[User] Get birth_date, country, joined_at, language by joining students with assignments.

[Assistant] SELECT *, assignments.joined_at, assignments.language FROM education.students JOIN education.assignments ON students.assignment_id = assignments.id;

[User] Tally up students by username.

[Assistant] SELECT username, COUNT(*) AS count FROM education.students GROUP BY username ORDER BY count DESC;


[User] List all students.

[Assistant] SELECT * FROM education.students;

[User] List timezone, person_id, joined_at, last_active for each student along with their assignment information.

[Assistant] SELECT *, assignments.joined_at, assignments.last_active FROM education.students JOIN education.assignments ON students.assignment_id = assignments.id;

[User] Restrict the output to 100 items.

[Assistant] SELECT *, assignments.joined_at, assignments.last_active FROM education.students JOIN education.assignments ON students.assignment_id = assignments.id LIMIT 100;


[User] List all students.

[Assistant] SELECT * FROM education.students;

[User] Get all students between January and March.

[Assistant] SELECT * FROM education.students WHERE last_active BETWEEN '2023-01-01' AND '2023-03-31';

[User] Show the results sorted by last_active descending.

[Assistant] SELECT * FROM education.students WHERE last_active BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY last_active DESC;


[User] Get username, assignment_id, first_name from all students.

[Assistant] SELECT username, assignment_id, first_name FROM education.students;

[User] Retrieve username, timezone, language, joined_at showing the relationship between students and assignments.

[Assistant] SELECT username, assignment_id, first_name, assignments.language, assignments.joined_at FROM education.students JOIN education.assignments ON students.assignment_id = assignments.id;

[User] Limit the results to 25 rows.

[Assistant] SELECT username, assignment_id, first_name, assignments.language, assignments.joined_at FROM education.students JOIN education.assignments ON students.assignment_id = assignments.id LIMIT 25;


[User] Display all students.

[Assistant] SELECT * FROM education.students;

[User] Show me students that were created after December 1st, 2023.

[Assistant] SELECT * FROM education.students WHERE last_active > '2023-12-01';

[User] Order the output by first_name descending.

[Assistant] SELECT * FROM education.students WHERE last_active > '2023-12-01' ORDER BY first_name DESC;


[User] What are the timezone, country, token of each student?

[Assistant] SELECT timezone, country, token FROM education.students;

[User] Get country, birth_date, joined_at, last_active by joining students with assignments.

[Assistant] SELECT timezone, country, token, assignments.joined_at, assignments.last_active FROM education.students JOIN education.assignments ON students.assignment_id = assignments.id;

[User] Show me the count of students grouped by birth_date.

[Assistant] SELECT birth_date, COUNT(*) AS count FROM education.students GROUP BY birth_date ORDER BY count DESC;


[User] Get person_id, last_active, username from all students.

[Assistant] SELECT person_id, last_active, username FROM education.students;

[User] Can you order these by birth_date descending?

[Assistant] SELECT person_id, last_active, username FROM education.students ORDER BY birth_date DESC;

[User] Get the distribution of students across different country values.

[Assistant] SELECT country, COUNT(*) AS count FROM education.students GROUP BY country ORDER BY count DESC;


[User] What are the assignment_id, last_active, country of each student?

[Assistant] SELECT assignment_id, last_active, country FROM education.students;

[User] Get all students created after December 1st, 2023.

[Assistant] SELECT assignment_id, last_active, country FROM education.students WHERE birth_date > '2023-12-01';

[User] Order the output by person_id ascending.

[Assistant] SELECT assignment_id, last_active, country FROM education.students WHERE birth_date > '2023-12-01' ORDER BY person_id ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.groups (
  item_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  expires_at timestamp without time zone,
  views varchar,
  category character varying(256),
  image_url character varying(64) NOT NULL,
  reserved char,
  post_id integer -- reference to posts.comment_id,
  FOREIGN KEY (post_id) REFERENCES posts(comment_id)
)

CREATE TABLE socialmedia.followers (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  expires_at date,
  category character varying(64),
  cost numeric,
  featured_rank character varying(64),
  popularity_score character varying(128) NOT NULL,
  thumbnail_url varchar,
  post_id integer NOT NULL -- reference to posts.comment_id,
  FOREIGN KEY (post_id) REFERENCES posts(comment_id)
)

CREATE TABLE socialmedia.posts (
  comment_id integer PRIMARY KEY -- unique identifier,
  created_at date,
  likes character varying(128),
  subject text
)

[User] List category, post_id, image_url from groups.

[Assistant] SELECT category, post_id, image_url FROM socialmedia.groups;

[User] Get groups that match updated_at > '2023-01-01'.

[Assistant] SELECT category, post_id, image_url FROM socialmedia.groups WHERE updated_at > '2023-01-01';

[User] Group groups by reserved and show the min of updated_at.

[Assistant] SELECT reserved, MIN(updated_at) AS min_updated_at FROM socialmedia.groups GROUP BY reserved;


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Order the output by cost ascending.

[Assistant] SELECT * FROM socialmedia.followers ORDER BY cost ASC;

[User] Only show the top 25 results.

[Assistant] SELECT * FROM socialmedia.followers ORDER BY cost ASC LIMIT 25;


[User] Show me all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Get groups that match reserved LIKE 'A%'.

[Assistant] SELECT * FROM socialmedia.groups WHERE reserved LIKE 'A%';

[User] Get the distribution of groups across different image_url values.

[Assistant] SELECT image_url, COUNT(*) AS count FROM socialmedia.groups GROUP BY image_url ORDER BY count DESC;


[User] Show me post_id, created_at, popularity_score for all followers.

[Assistant] SELECT post_id, created_at, popularity_score FROM socialmedia.followers;

[User] Show me cost, created_at, likes, created_at from followers and their related posts.

[Assistant] SELECT post_id, created_at, popularity_score, posts.likes, posts.created_at FROM socialmedia.followers JOIN socialmedia.posts ON followers.post_id = posts.comment_id;

[User] Tally up followers by expires_at.

[Assistant] SELECT expires_at, COUNT(*) AS count FROM socialmedia.followers GROUP BY expires_at ORDER BY count DESC;


[User] Display all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] What featured_rank, category, subject, likes do we have for followers and their associated posts?

[Assistant] SELECT *, posts.subject, posts.likes FROM socialmedia.followers JOIN socialmedia.posts ON followers.post_id = posts.comment_id;

[User] Only show the top 15 results.

[Assistant] SELECT *, posts.subject, posts.likes FROM socialmedia.followers JOIN socialmedia.posts ON followers.post_id = posts.comment_id LIMIT 15;


[User] Retrieve all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Show me expires_at, image_url, likes, subject from groups and their related posts.

[Assistant] SELECT *, posts.likes, posts.subject FROM socialmedia.groups JOIN socialmedia.posts ON groups.post_id = posts.comment_id;

[User] Group groups by expires_at and show the average of updated_at.

[Assistant] SELECT expires_at, AVERAGE(updated_at) AS average_updated_at FROM socialmedia.groups GROUP BY expires_at;


[User] List expires_at, views, updated_at from groups.

[Assistant] SELECT expires_at, views, updated_at FROM socialmedia.groups;

[User] Retrieve groups where updated_at > '2023-01-01'.

[Assistant] SELECT expires_at, views, updated_at FROM socialmedia.groups WHERE updated_at > '2023-01-01';

[User] Get max of category by category from groups.

[Assistant] SELECT category, MAX(category) AS max_category FROM socialmedia.groups GROUP BY category;


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show me followers that were created in the last 30 days.

[Assistant] SELECT * FROM socialmedia.followers WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Show me the count of followers grouped by category.

[Assistant] SELECT category, COUNT(*) AS count FROM socialmedia.followers GROUP BY category ORDER BY count DESC;


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Retrieve followers where category LIKE 'A%'.

[Assistant] SELECT * FROM socialmedia.followers WHERE category LIKE 'A%';

[User] Tally up followers by post_id.

[Assistant] SELECT post_id, COUNT(*) AS count FROM socialmedia.followers GROUP BY post_id ORDER BY count DESC;


[User] Retrieve updated_at, category, reserved for every group.

[Assistant] SELECT updated_at, category, reserved FROM socialmedia.groups;

[User] Retrieve post_id, expires_at, likes, created_at showing the relationship between groups and posts.

[Assistant] SELECT updated_at, category, reserved, posts.likes, posts.created_at FROM socialmedia.groups JOIN socialmedia.posts ON groups.post_id = posts.comment_id;

[User] Group groups by updated_at and show the max of expires_at.

[Assistant] SELECT updated_at, MAX(expires_at) AS max_expires_at FROM socialmedia.groups GROUP BY updated_at;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.grades (
  post_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  published_at date,
  shares char NOT NULL,
  attachment_url character varying(128),
  user_id varchar
)

CREATE TABLE education.students (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  last_active timestamp,
  state character varying(256) NOT NULL,
  api_key character varying(256),
  token character varying(64) NOT NULL,
  avatar character varying(64) NOT NULL,
  bio character varying(256)
)

[User] List all students.

[Assistant] SELECT * FROM education.students;

[User] List students that have last_active > '2023-01-01'.

[Assistant] SELECT * FROM education.students WHERE last_active > '2023-01-01';

[User] Show only 20 records.

[Assistant] SELECT * FROM education.students WHERE last_active > '2023-01-01' LIMIT 20;


[User] Get all grades.

[Assistant] SELECT * FROM education.grades;

[User] Retrieve grades where post_id LIKE 'A%'.

[Assistant] SELECT * FROM education.grades WHERE post_id LIKE 'A%';

[User] Group grades by updated_at and show the count of updated_at.

[Assistant] SELECT updated_at, COUNT(updated_at) AS count_updated_at FROM education.grades GROUP BY updated_at;


[User] Get bio, avatar, last_active from all students.

[Assistant] SELECT bio, avatar, last_active FROM education.students;

[User] Can you order these by bio descending?

[Assistant] SELECT bio, avatar, last_active FROM education.students ORDER BY bio DESC;

[User] Arrange the results with avatar in ascending order.

[Assistant] SELECT bio, avatar, last_active FROM education.students ORDER BY avatar ASC;


[User] Show me token, id, bio for all students.

[Assistant] SELECT token, id, bio FROM education.students;

[User] Arrange the results with api_key in descending order.

[Assistant] SELECT token, id, bio FROM education.students ORDER BY api_key DESC;

[User] Count the number of students in each api_key category.

[Assistant] SELECT api_key, COUNT(*) AS count FROM education.students GROUP BY api_key ORDER BY count DESC;