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 (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  user_id text,
  currency text NOT NULL,
  amount numeric NOT NULL,
  course_id text NOT NULL -- reference to courses.product_id,
  FOREIGN KEY (course_id) REFERENCES courses(product_id)
)

CREATE TABLE education.enrollments (
  payment_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  user_id character varying(128),
  customer_id character varying(64) NOT NULL,
  reconciliation_status character varying(256),
  department_id text NOT NULL -- reference to departments.invoice_id,
  FOREIGN KEY (department_id) REFERENCES departments(invoice_id)
)

CREATE TABLE education.courses (
  product_id varchar PRIMARY KEY -- unique identifier,
  published_at date,
  created_at timestamp,
  price integer,
  manufacturer character varying(64),
  thumbnail_url varchar,
  tax_rate character varying(256),
  media_url text NOT NULL
)

[User] Display all departments.

[Assistant] SELECT * FROM education.departments;

[User] List amount, processed_at, thumbnail_url, tax_rate for each department along with their course information.

[Assistant] SELECT *, courses.thumbnail_url, courses.tax_rate FROM education.departments JOIN education.courses ON departments.course_id = courses.product_id;

[User] Restrict the output to 25 items.

[Assistant] SELECT *, courses.thumbnail_url, courses.tax_rate FROM education.departments JOIN education.courses ON departments.course_id = courses.product_id LIMIT 25;


[User] Show me all departments.

[Assistant] SELECT * FROM education.departments;

[User] Retrieve currency, processed_at, price, tax_rate showing the relationship between departments and courses.

[Assistant] SELECT *, courses.price, courses.tax_rate FROM education.departments JOIN education.courses ON departments.course_id = courses.product_id;

[User] Order the output by amount ascending.

[Assistant] SELECT *, courses.price, courses.tax_rate FROM education.departments JOIN education.courses ON departments.course_id = courses.product_id ORDER BY amount ASC;


[User] Retrieve course_id, processed_at, user_id for every department.

[Assistant] SELECT course_id, processed_at, user_id FROM education.departments;

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

[Assistant] SELECT course_id, processed_at, user_id FROM education.departments ORDER BY currency DESC;

[User] How many departments are there per currency?

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


[User] Retrieve user_id, customer_id, payment_id for every enrollment.

[Assistant] SELECT user_id, customer_id, payment_id FROM education.enrollments;

[User] Show the results sorted by reconciliation_status descending.

[Assistant] SELECT user_id, customer_id, payment_id FROM education.enrollments ORDER BY reconciliation_status DESC;

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

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


[User] Retrieve currency, processed_at, course_id for every department.

[Assistant] SELECT currency, processed_at, course_id FROM education.departments;

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

[Assistant] SELECT currency, processed_at, course_id FROM education.departments ORDER BY processed_at DESC;

[User] Restrict the output to 10 items.

[Assistant] SELECT currency, processed_at, course_id FROM education.departments ORDER BY processed_at DESC LIMIT 10;


[User] List all departments.

[Assistant] SELECT * FROM education.departments;

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

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

[User] Tally up departments by user_id.

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


[User] Show me course_id, amount, currency for all departments.

[Assistant] SELECT course_id, amount, currency FROM education.departments;

[User] Retrieve departments where processed_at > '2023-01-01'.

[Assistant] SELECT course_id, amount, currency FROM education.departments WHERE processed_at > '2023-01-01';

[User] Can you order these by processed_at ascending?

[Assistant] SELECT course_id, amount, currency FROM education.departments WHERE processed_at > '2023-01-01' ORDER BY processed_at ASC;


[User] Show me user_id, department_id, payment_id for all enrollments.

[Assistant] SELECT user_id, department_id, payment_id FROM education.enrollments;

[User] Find enrollments where reconciliation_status LIKE 'A%'.

[Assistant] SELECT user_id, department_id, payment_id FROM education.enrollments WHERE reconciliation_status LIKE 'A%';

[User] Tally up enrollments by reconciliation_status.

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


[User] Retrieve all departments.

[Assistant] SELECT * FROM education.departments;

[User] Get all departments created yesterday.

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

[User] Can you order these by user_id ascending?

[Assistant] SELECT * FROM education.departments WHERE processed_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY user_id ASC;


[User] Get created_at, reconciliation_status, payment_id from all enrollments.

[Assistant] SELECT created_at, reconciliation_status, payment_id FROM education.enrollments;

[User] Find enrollments where customer_id LIKE 'A%'.

[Assistant] SELECT created_at, reconciliation_status, payment_id FROM education.enrollments WHERE customer_id LIKE 'A%';

[User] Return just 5 rows.

[Assistant] SELECT created_at, reconciliation_status, payment_id FROM education.enrollments WHERE customer_id LIKE 'A%' LIMIT 5;


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.billing (
  order_id varchar PRIMARY KEY -- unique identifier,
  completed_at date,
  amount bigint,
  buyer_id character varying(128) NOT NULL -- identifier for buyer,
  card_type varchar,
  user_id text NOT NULL,
  payment_method character varying(64) NOT NULL,
  doctor_id integer NOT NULL -- reference to doctors.payment_id,
  FOREIGN KEY (doctor_id) REFERENCES doctors(payment_id)
)

CREATE TABLE healthcare.appointments (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  published_at date,
  tags character varying(128) NOT NULL,
  rating text,
  categories char,
  body varchar NOT NULL,
  score char NOT NULL,
  thumbnail varchar NOT NULL,
  attachment_url character varying(128) NOT NULL,
  billin_id text NOT NULL -- reference to billing.order_id,
  FOREIGN KEY (billin_id) REFERENCES billing(order_id)
)

CREATE TABLE healthcare.doctors (
  payment_id integer PRIMARY KEY -- unique identifier,
  completed_at date,
  processed_at date,
  total smallint,
  quantity char,
  approval_status character varying(256),
  product_id text -- identifier for product,
  seller_id character varying(64) -- identifier for seller,
  payment_method character varying(256),
  appointment_id text -- reference to appointments.id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(id)
)

[User] Show me doctor_id, user_id, card_type for all billing.

[Assistant] SELECT doctor_id, user_id, card_type FROM healthcare.billing;

[User] Find billing where amount > 48.

[Assistant] SELECT doctor_id, user_id, card_type FROM healthcare.billing WHERE amount > 48;

[User] Calculate sum of completed_at for each user_id in billing.

[Assistant] SELECT user_id, SUM(completed_at) AS sum_completed_at FROM healthcare.billing GROUP BY user_id;


[User] Retrieve all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Find billing where completed_at > '2023-01-01'.

[Assistant] SELECT * FROM healthcare.billing WHERE completed_at > '2023-01-01';

[User] Order the output by card_type descending.

[Assistant] SELECT * FROM healthcare.billing WHERE completed_at > '2023-01-01' ORDER BY card_type DESC;


[User] List attachment_url, rating, thumbnail from appointments.

[Assistant] SELECT attachment_url, rating, thumbnail FROM healthcare.appointments;

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

[Assistant] SELECT attachment_url, rating, thumbnail FROM healthcare.appointments WHERE published_at > '2023-12-01';

[User] Limit the results to 100 rows.

[Assistant] SELECT attachment_url, rating, thumbnail FROM healthcare.appointments WHERE published_at > '2023-12-01' LIMIT 100;


[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Find appointments where categories LIKE 'A%'.

[Assistant] SELECT * FROM healthcare.appointments WHERE categories LIKE 'A%';

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

[Assistant] SELECT * FROM healthcare.appointments WHERE categories LIKE 'A%' ORDER BY thumbnail ASC;


[User] Get all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

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

[Assistant] SELECT * FROM healthcare.appointments ORDER BY categories ASC;

[User] Only show the top 15 results.

[Assistant] SELECT * FROM healthcare.appointments ORDER BY categories ASC LIMIT 15;


[User] Retrieve all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Get total, appointment_id, updated_at, tags by joining doctors with appointments.

[Assistant] SELECT *, appointments.updated_at, appointments.tags FROM healthcare.doctors JOIN healthcare.appointments ON doctors.appointment_id = appointments.id;

[User] Show me count of product_id grouped by quantity for doctors.

[Assistant] SELECT quantity, COUNT(product_id) AS count_product_id FROM healthcare.doctors GROUP BY quantity;


[User] List appointment_id, approval_status, completed_at from doctors.

[Assistant] SELECT appointment_id, approval_status, completed_at FROM healthcare.doctors;

[User] Get doctors that match completed_at > '2023-01-01'.

[Assistant] SELECT appointment_id, approval_status, completed_at FROM healthcare.doctors WHERE completed_at > '2023-01-01';

[User] What is the sum completed_at for each approval_status in doctors?

[Assistant] SELECT approval_status, SUM(completed_at) AS sum_completed_at FROM healthcare.doctors GROUP BY approval_status;


[User] Display all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Can you order these by payment_method descending?

[Assistant] SELECT * FROM healthcare.billing ORDER BY payment_method DESC;

[User] Show me max of completed_at grouped by card_type for billing.

[Assistant] SELECT card_type, MAX(completed_at) AS max_completed_at FROM healthcare.billing GROUP BY card_type;


[User] What are the buyer_id, user_id, amount of each billing?

[Assistant] SELECT buyer_id, user_id, amount FROM healthcare.billing;

[User] Show the results sorted by buyer_id descending.

[Assistant] SELECT buyer_id, user_id, amount FROM healthcare.billing ORDER BY buyer_id DESC;

[User] What is the min amount for each card_type in billing?

[Assistant] SELECT card_type, MIN(amount) AS min_amount FROM healthcare.billing GROUP BY card_type;


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 (
  venue_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at timestamp without time zone,
  location_lon character varying(128),
  parking_available varchar NOT NULL,
  type character varying(64) NOT NULL,
  name character varying(128),
  state character varying(128) NOT NULL,
  student_id text -- reference to students.customer_id,
  FOREIGN KEY (student_id) REFERENCES students(customer_id)
)

CREATE TABLE education.enrollments (
  order_id character varying(64) NOT NULL -- unique identifier,
  cancelled_at date,
  delivery_status character varying(128),
  seller_id character varying(64) NOT NULL -- identifier for seller,
  payment_status varchar,
  exchange_rate varchar,
  buyer_id varchar NOT NULL,
  status char,
  department_id text -- reference to departments.venue_id,
  FOREIGN KEY (department_id) REFERENCES departments(venue_id)
)

CREATE TABLE education.students (
  customer_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  address character varying(64) NOT NULL,
  timezone varchar NOT NULL,
  full_name character varying(128),
  last_login timestamp,
  account_status char,
  nationality text NOT NULL,
  department_id text NOT NULL -- reference to departments.venue_id,
  FOREIGN KEY (department_id) REFERENCES departments(venue_id)
)

[User] Get state, created_at, type from all departments.

[Assistant] SELECT state, created_at, type FROM education.departments;

[User] Find departments where location_lon LIKE 'A%'.

[Assistant] SELECT state, created_at, type FROM education.departments WHERE location_lon LIKE 'A%';

[User] Show the results sorted by parking_available ascending.

[Assistant] SELECT state, created_at, type FROM education.departments WHERE location_lon LIKE 'A%' ORDER BY parking_available ASC;


[User] Display all students.

[Assistant] SELECT * FROM education.students;

[User] Find students where address LIKE 'A%'.

[Assistant] SELECT * FROM education.students WHERE address LIKE 'A%';

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

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


[User] Retrieve student_id, location_lon, type for every department.

[Assistant] SELECT student_id, location_lon, type FROM education.departments;

[User] Show the results sorted by student_id ascending.

[Assistant] SELECT student_id, location_lon, type FROM education.departments ORDER BY student_id ASC;

[User] Order the output by created_at descending.

[Assistant] SELECT student_id, location_lon, type FROM education.departments ORDER BY created_at DESC;


[User] What are the state, name, updated_at of each department?

[Assistant] SELECT state, name, updated_at FROM education.departments;

[User] Sort the results by parking_available ascending.

[Assistant] SELECT state, name, updated_at FROM education.departments ORDER BY parking_available ASC;

[User] Limit the results to 5 rows.

[Assistant] SELECT state, name, updated_at FROM education.departments ORDER BY parking_available ASC LIMIT 5;


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.accounts (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  exchange_rate char NOT NULL,
  category char,
  verification_status character varying(256) NOT NULL,
  notes text NOT NULL,
  user_id text NOT NULL -- reference to users.user_id,
  FOREIGN KEY (user_id) REFERENCES users(user_id)
)

CREATE TABLE banking.users (
  user_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  phone character varying(256),
  email char NOT NULL,
  bio character varying(64),
  is_active boolean,
  last_login timestamp without time zone,
  account_status text
)

[User] What are the category, exchange_rate, processed_at of each account?

[Assistant] SELECT category, exchange_rate, processed_at FROM banking.accounts;

[User] Show me accounts that were from 2023.

[Assistant] SELECT category, exchange_rate, processed_at FROM banking.accounts WHERE processed_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Order the output by notes ascending.

[Assistant] SELECT category, exchange_rate, processed_at FROM banking.accounts WHERE processed_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY notes ASC;


[User] Show me processed_at, verification_status, exchange_rate for all accounts.

[Assistant] SELECT processed_at, verification_status, exchange_rate FROM banking.accounts;

[User] List accounts that have notes LIKE 'A%'.

[Assistant] SELECT processed_at, verification_status, exchange_rate FROM banking.accounts WHERE notes LIKE 'A%';

[User] Calculate sum of user_id for each verification_status in accounts.

[Assistant] SELECT verification_status, SUM(user_id) AS sum_user_id FROM banking.accounts GROUP BY verification_status;


[User] List all accounts.

[Assistant] SELECT * FROM banking.accounts;

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

[Assistant] SELECT * FROM banking.accounts WHERE exchange_rate LIKE 'A%';

[User] How many accounts are there per exchange_rate?

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


[User] List user_id, processed_at, exchange_rate from accounts.

[Assistant] SELECT user_id, processed_at, exchange_rate FROM banking.accounts;

[User] Get all accounts from last week.

[Assistant] SELECT user_id, processed_at, exchange_rate FROM banking.accounts WHERE processed_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Return just 10 rows.

[Assistant] SELECT user_id, processed_at, exchange_rate FROM banking.accounts WHERE processed_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 10;


[User] What are the category, verification_status, exchange_rate of each account?

[Assistant] SELECT category, verification_status, exchange_rate FROM banking.accounts;

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

[Assistant] SELECT category, verification_status, exchange_rate FROM banking.accounts ORDER BY exchange_rate DESC;

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

[Assistant] SELECT category, verification_status, exchange_rate FROM banking.accounts ORDER BY notes DESC;


[User] Retrieve user_id, notes, verification_status for every account.

[Assistant] SELECT user_id, notes, verification_status FROM banking.accounts;

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

[Assistant] SELECT user_id, notes, verification_status FROM banking.accounts WHERE processed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

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

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


[User] Get all accounts.

[Assistant] SELECT * FROM banking.accounts;

[User] Show the results sorted by notes descending.

[Assistant] SELECT * FROM banking.accounts ORDER BY notes DESC;

[User] Get min of exchange_rate by processed_at from accounts.

[Assistant] SELECT processed_at, MIN(exchange_rate) AS min_exchange_rate FROM banking.accounts GROUP BY processed_at;


[User] Retrieve exchange_rate, category, user_id for every account.

[Assistant] SELECT exchange_rate, category, user_id FROM banking.accounts;

[User] Get accounts that match processed_at > '2023-01-01'.

[Assistant] SELECT exchange_rate, category, user_id FROM banking.accounts WHERE processed_at > '2023-01-01';

[User] Show the results sorted by processed_at ascending.

[Assistant] SELECT exchange_rate, category, user_id FROM banking.accounts WHERE processed_at > '2023-01-01' ORDER BY processed_at ASC;


[User] Display all accounts.

[Assistant] SELECT * FROM banking.accounts;

[User] Show me notes, processed_at, account_status, phone from accounts and their related users.

[Assistant] SELECT *, users.account_status, users.phone FROM banking.accounts JOIN banking.users ON accounts.user_id = users.user_id;

[User] Only show the top 5 results.

[Assistant] SELECT *, users.account_status, users.phone FROM banking.accounts JOIN banking.users ON accounts.user_id = users.user_id LIMIT 5;


[User] Retrieve all accounts.

[Assistant] SELECT * FROM banking.accounts;

[User] Find accounts from 2023.

[Assistant] SELECT * FROM banking.accounts WHERE processed_at BETWEEN '2023-01-01' AND '2023-12-31';

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

[Assistant] SELECT * FROM banking.accounts WHERE processed_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY verification_status 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 e-commerce.inventory (
  id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  thumbnail_url text NOT NULL,
  currency character varying(64),
  stock_level varchar NOT NULL,
  media_url char,
  subcategory character varying(128),
  order_id text -- reference to orders.id,
  FOREIGN KEY (order_id) REFERENCES orders(id)
)

CREATE TABLE e-commerce.orders (
  id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  completed_at timestamp without time zone,
  payment_status character varying(256) NOT NULL,
  fee text NOT NULL,
  card_type text,
  product_id character varying(64) NOT NULL,
  status character varying(128),
  payment_method text
)

CREATE TABLE e-commerce.reviews (
  comment_id character varying(64) NOT NULL -- unique identifier,
  edited_at timestamp without time zone,
  visibility character varying(64),
  description text,
  author_id character varying(128) NOT NULL -- identifier for author,
  tags character varying(128) NOT NULL,
  image_url text,
  rating text NOT NULL
)

CREATE TABLE e-commerce.users (
  id character varying(64) NOT NULL -- unique identifier,
  last_active timestamp,
  address text,
  email varchar NOT NULL,
  status character varying(256),
  inventor_id text NOT NULL -- reference to inventory.id,
  FOREIGN KEY (inventor_id) REFERENCES inventory(id)
)

[User] Show me media_url, subcategory, currency for all inventory.

[Assistant] SELECT media_url, subcategory, currency FROM e-commerce.inventory;

[User] List inventory that have currency LIKE 'A%'.

[Assistant] SELECT media_url, subcategory, currency FROM e-commerce.inventory WHERE currency LIKE 'A%';

[User] Count the number of inventory in each stock_level category.

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


[User] Retrieve all inventory.

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

[User] Get all inventory from last week.

[Assistant] SELECT * FROM e-commerce.inventory WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Sort the results by created_at ascending.

[Assistant] SELECT * FROM e-commerce.inventory WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY created_at ASC;


[User] Get all users.

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

[User] What status, inventor_id, created_at, subcategory do we have for users and their associated inventory?

[Assistant] SELECT *, inventory.created_at, inventory.subcategory FROM e-commerce.users JOIN e-commerce.inventory ON users.inventor_id = inventory.id;

[User] Restrict the output to 20 items.

[Assistant] SELECT *, inventory.created_at, inventory.subcategory FROM e-commerce.users JOIN e-commerce.inventory ON users.inventor_id = inventory.id LIMIT 20;


[User] List inventor_id, last_active, address from users.

[Assistant] SELECT inventor_id, last_active, address FROM e-commerce.users;

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

[Assistant] SELECT inventor_id, last_active, address FROM e-commerce.users WHERE last_active >= CURRENT_DATE - INTERVAL '7 days';

[User] Can you order these by last_active ascending?

[Assistant] SELECT inventor_id, last_active, address FROM e-commerce.users WHERE last_active >= CURRENT_DATE - INTERVAL '7 days' ORDER BY last_active ASC;


[User] Retrieve email, address, id for every user.

[Assistant] SELECT email, address, id FROM e-commerce.users;

[User] Show me users that were from 2023.

[Assistant] SELECT email, address, id FROM e-commerce.users WHERE last_active BETWEEN '2023-01-01' AND '2023-12-31';

[User] Can you order these by id descending?

[Assistant] SELECT email, address, id FROM e-commerce.users WHERE last_active BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY id DESC;


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

[Assistant] SELECT status, address, last_active FROM e-commerce.users;

[User] Order the output by last_active ascending.

[Assistant] SELECT status, address, last_active FROM e-commerce.users ORDER BY last_active ASC;

[User] Group users by address and show the average of email.

[Assistant] SELECT address, AVERAGE(email) AS average_email FROM e-commerce.users GROUP BY address;


[User] Get all inventory.

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

[User] Retrieve subcategory, order_id, created_at, card_type showing the relationship between inventory and orders.

[Assistant] SELECT *, orders.created_at, orders.card_type FROM e-commerce.inventory JOIN e-commerce.orders ON inventory.order_id = orders.id;

[User] Get max of media_url by subcategory from inventory.

[Assistant] SELECT subcategory, MAX(media_url) AS max_media_url FROM e-commerce.inventory GROUP BY subcategory;


[User] Get last_active, id, address from all users.

[Assistant] SELECT last_active, id, address FROM e-commerce.users;

[User] Retrieve id, last_active, stock_level, order_id showing the relationship between users and inventory.

[Assistant] SELECT last_active, id, address, inventory.stock_level, inventory.order_id FROM e-commerce.users JOIN e-commerce.inventory ON users.inventor_id = inventory.id;

[User] Group users by id and show the min of inventor_id.

[Assistant] SELECT id, MIN(inventor_id) AS min_inventor_id FROM e-commerce.users GROUP BY id;


[User] Display all inventory.

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

[User] Find inventory between January and March.

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

[User] Get count of created_at by subcategory from inventory.

[Assistant] SELECT subcategory, COUNT(created_at) AS count_created_at FROM e-commerce.inventory GROUP BY subcategory;


[User] Display all users.

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

[User] Retrieve users where status LIKE 'A%'.

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

[User] Show the results sorted by id ascending.

[Assistant] SELECT * FROM e-commerce.users WHERE status LIKE 'A%' ORDER BY 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 finance.transactions (
  payment_id character varying(64) NOT NULL -- unique identifier,
  cancelled_at date,
  updated_at timestamp,
  card_type text NOT NULL,
  tax decimal NOT NULL,
  exchange_rate char,
  customer_id character varying(128) -- identifier for customer,
  product_id char NOT NULL
)

CREATE TABLE finance.customers (
  user_id varchar PRIMARY KEY -- unique identifier,
  joined_at date,
  is_verified bit NOT NULL -- indicates if verified is true,
  profile_picture_url char NOT NULL,
  nationality char NOT NULL
)

CREATE TABLE finance.audits (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  payment_date timestamp,
  payee_id character varying(128) -- identifier for payee,
  status text NOT NULL,
  reference_number varchar NOT NULL,
  notes character varying(128) NOT NULL,
  amount smallint,
  customer_id character varying(128) NOT NULL
)

[User] Show me customer_id, notes, amount for all audits.

[Assistant] SELECT customer_id, notes, amount FROM finance.audits;

[User] List audits that have payment_date > '2023-01-01'.

[Assistant] SELECT customer_id, notes, amount FROM finance.audits WHERE payment_date > '2023-01-01';

[User] Get the distribution of audits across different invoice_id values.

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


[User] Display all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Sort the results by customer_id ascending.

[Assistant] SELECT * FROM finance.audits ORDER BY customer_id ASC;

[User] Limit the results to 5 rows.

[Assistant] SELECT * FROM finance.audits ORDER BY customer_id ASC LIMIT 5;


[User] Show me reference_number, payment_date, amount for all audits.

[Assistant] SELECT reference_number, payment_date, amount FROM finance.audits;

[User] Find audits created yesterday.

[Assistant] SELECT reference_number, payment_date, amount FROM finance.audits WHERE payment_date = CURRENT_DATE - INTERVAL '1 day';

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

[Assistant] SELECT reference_number, payment_date, amount FROM finance.audits WHERE payment_date = CURRENT_DATE - INTERVAL '1 day' ORDER BY invoice_id ASC;


[User] What are the payment_date, customer_id, invoice_id of each audit?

[Assistant] SELECT payment_date, customer_id, invoice_id FROM finance.audits;

[User] Retrieve audits where payment_date > '2023-01-01'.

[Assistant] SELECT payment_date, customer_id, invoice_id FROM finance.audits WHERE payment_date > '2023-01-01';

[User] Can you order these by payment_date descending?

[Assistant] SELECT payment_date, customer_id, invoice_id FROM finance.audits WHERE payment_date > '2023-01-01' ORDER BY payment_date DESC;


[User] List profile_picture_url, nationality, joined_at from customers.

[Assistant] SELECT profile_picture_url, nationality, joined_at FROM finance.customers;

[User] Find customers older than 6 months.

[Assistant] SELECT profile_picture_url, nationality, joined_at FROM finance.customers WHERE joined_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Return just 25 rows.

[Assistant] SELECT profile_picture_url, nationality, joined_at FROM finance.customers WHERE joined_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 25;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Get customers that match nationality LIKE 'A%'.

[Assistant] SELECT * FROM finance.customers WHERE nationality LIKE 'A%';

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

[Assistant] SELECT nationality, SUM(joined_at) AS sum_joined_at FROM finance.customers GROUP BY nationality;


[User] Show me all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Find audits where status LIKE 'A%'.

[Assistant] SELECT * FROM finance.audits WHERE status LIKE 'A%';

[User] Limit the results to 15 rows.

[Assistant] SELECT * FROM finance.audits WHERE status LIKE 'A%' LIMIT 15;


[User] Retrieve all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Get audits that match reference_number LIKE 'A%'.

[Assistant] SELECT * FROM finance.audits WHERE reference_number LIKE 'A%';

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

[Assistant] SELECT * FROM finance.audits WHERE reference_number LIKE 'A%' ORDER BY reference_number DESC;


[User] Show me all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Can you order these by customer_id descending?

[Assistant] SELECT * FROM finance.audits ORDER BY customer_id DESC;

[User] Only show the top 100 results.

[Assistant] SELECT * FROM finance.audits ORDER BY customer_id DESC LIMIT 100;


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Can you order these by tax descending?

[Assistant] SELECT * FROM finance.transactions ORDER BY tax DESC;

[User] Calculate average of product_id for each cancelled_at in transactions.

[Assistant] SELECT cancelled_at, AVERAGE(product_id) AS average_product_id FROM finance.transactions GROUP BY cancelled_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 socialmedia.comments (
  message_id character varying(64) NOT NULL -- unique identifier,
  edited_at timestamp,
  published_at timestamp,
  body text,
  attachment_url varchar NOT NULL,
  image_url character varying(64) NOT NULL
)

CREATE TABLE socialmedia.messages (
  content_id text PRIMARY KEY -- unique identifier,
  edited_at timestamp without time zone,
  tags character varying(64),
  author_id varchar -- identifier for author,
  score char,
  format character varying(64),
  visibility char,
  rating text NOT NULL,
  parent_id text NOT NULL -- identifier for parent
)

[User] Show me edited_at, attachment_url, message_id for all comments.

[Assistant] SELECT edited_at, attachment_url, message_id FROM socialmedia.comments;

[User] Can you order these by published_at ascending?

[Assistant] SELECT edited_at, attachment_url, message_id FROM socialmedia.comments ORDER BY published_at ASC;

[User] Get sum of published_at by body from comments.

[Assistant] SELECT body, SUM(published_at) AS sum_published_at FROM socialmedia.comments GROUP BY body;


[User] Show me all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Find comments where body LIKE 'A%'.

[Assistant] SELECT * FROM socialmedia.comments WHERE body LIKE 'A%';

[User] How many comments are there per message_id?

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


[User] List parent_id, format, author_id from messages.

[Assistant] SELECT parent_id, format, author_id FROM socialmedia.messages;

[User] Show the results sorted by rating ascending.

[Assistant] SELECT parent_id, format, author_id FROM socialmedia.messages ORDER BY rating ASC;

[User] Tally up messages by author_id.

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


[User] Show me score, rating, edited_at for all messages.

[Assistant] SELECT score, rating, edited_at FROM socialmedia.messages;

[User] List messages that have rating LIKE 'A%'.

[Assistant] SELECT score, rating, edited_at FROM socialmedia.messages WHERE rating LIKE 'A%';

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

[Assistant] SELECT score, rating, edited_at FROM socialmedia.messages WHERE rating LIKE 'A%' ORDER BY format DESC;


[User] Get all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

[Assistant] SELECT * FROM socialmedia.comments WHERE edited_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Calculate min of image_url for each body in comments.

[Assistant] SELECT body, MIN(image_url) AS min_image_url FROM socialmedia.comments GROUP BY body;


[User] Retrieve all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Order the output by rating ascending.

[Assistant] SELECT * FROM socialmedia.messages ORDER BY rating ASC;

[User] Show me the count of messages grouped by format.

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


[User] Display all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Show the results sorted by message_id ascending.

[Assistant] SELECT * FROM socialmedia.comments ORDER BY message_id ASC;

[User] Show only 25 records.

[Assistant] SELECT * FROM socialmedia.comments ORDER BY message_id ASC LIMIT 25;


[User] What are the format, score, tags of each message?

[Assistant] SELECT format, score, tags FROM socialmedia.messages;

[User] List messages that have visibility LIKE 'A%'.

[Assistant] SELECT format, score, tags FROM socialmedia.messages WHERE visibility LIKE 'A%';

[User] Show me the count of messages grouped by visibility.

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


[User] Show me rating, edited_at, format for all messages.

[Assistant] SELECT rating, edited_at, format FROM socialmedia.messages;

[User] Get messages that match tags LIKE 'A%'.

[Assistant] SELECT rating, edited_at, format FROM socialmedia.messages WHERE tags LIKE 'A%';

[User] Group messages by edited_at and show the count of rating.

[Assistant] SELECT edited_at, COUNT(rating) AS count_rating FROM socialmedia.messages GROUP BY edited_at;


[User] What are the tags, visibility, score of each message?

[Assistant] SELECT tags, visibility, score FROM socialmedia.messages;

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

[Assistant] SELECT tags, visibility, score FROM socialmedia.messages WHERE edited_at > '2023-12-01';

[User] How many messages are there per visibility?

[Assistant] SELECT visibility, COUNT(*) AS count FROM socialmedia.messages GROUP BY visibility 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 healthcare.departments (
  comment_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at date,
  message character varying(128) NOT NULL,
  tags char,
  text character varying(256),
  image_url character varying(64),
  subject char NOT NULL
)

CREATE TABLE healthcare.patients (
  user_id character varying(64) NOT NULL -- unique identifier,
  last_active date,
  timezone varchar,
  status character varying(256),
  account_status character varying(256) NOT NULL,
  nationality character varying(64) NOT NULL,
  first_name varchar,
  country text NOT NULL
)

CREATE TABLE healthcare.billing (
  id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  location_lon char NOT NULL,
  zip_code character varying(256),
  address_line1 varchar,
  operating_hours varchar NOT NULL
)

[User] List all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Sort the results by zip_code descending.

[Assistant] SELECT * FROM healthcare.billing ORDER BY zip_code DESC;

[User] Return just 100 rows.

[Assistant] SELECT * FROM healthcare.billing ORDER BY zip_code DESC LIMIT 100;


[User] Retrieve last_active, nationality, timezone for every patient.

[Assistant] SELECT last_active, nationality, timezone FROM healthcare.patients;

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

[Assistant] SELECT last_active, nationality, timezone FROM healthcare.patients WHERE last_active BETWEEN '2023-01-01' AND '2023-03-31';

[User] Return just 15 rows.

[Assistant] SELECT last_active, nationality, timezone FROM healthcare.patients WHERE last_active BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 15;


[User] Get text, created_at, updated_at from all departments.

[Assistant] SELECT text, created_at, updated_at FROM healthcare.departments;

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

[Assistant] SELECT text, created_at, updated_at FROM healthcare.departments WHERE text LIKE 'A%';

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

[Assistant] SELECT text, created_at, updated_at FROM healthcare.departments WHERE text LIKE 'A%' ORDER BY updated_at DESC;


[User] Retrieve tags, updated_at, subject for every department.

[Assistant] SELECT tags, updated_at, subject FROM healthcare.departments;

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

[Assistant] SELECT tags, updated_at, subject FROM healthcare.departments WHERE created_at > '2023-01-01';

[User] Calculate count of message for each subject in departments.

[Assistant] SELECT subject, COUNT(message) AS count_message FROM healthcare.departments GROUP BY subject;


[User] Get created_at, location_lon, id from all billing.

[Assistant] SELECT created_at, location_lon, id FROM healthcare.billing;

[User] Show me billing that were from last week.

[Assistant] SELECT created_at, location_lon, id FROM healthcare.billing WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Calculate count of location_lon for each id in billing.

[Assistant] SELECT id, COUNT(location_lon) AS count_location_lon FROM healthcare.billing GROUP BY id;


[User] Retrieve subject, text, updated_at for every department.

[Assistant] SELECT subject, text, updated_at FROM healthcare.departments;

[User] Can you order these by image_url ascending?

[Assistant] SELECT subject, text, updated_at FROM healthcare.departments ORDER BY image_url ASC;

[User] Restrict the output to 25 items.

[Assistant] SELECT subject, text, updated_at FROM healthcare.departments ORDER BY image_url ASC LIMIT 25;


[User] Get all departments.

[Assistant] SELECT * FROM healthcare.departments;

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

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

[User] Calculate count of tags for each image_url in departments.

[Assistant] SELECT image_url, COUNT(tags) AS count_tags FROM healthcare.departments GROUP BY image_url;


[User] Get nationality, status, country from all patients.

[Assistant] SELECT nationality, status, country FROM healthcare.patients;

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

[Assistant] SELECT nationality, status, country FROM healthcare.patients WHERE last_active > '2023-12-01';

[User] Show the results sorted by account_status descending.

[Assistant] SELECT nationality, status, country FROM healthcare.patients WHERE last_active > '2023-12-01' ORDER BY account_status DESC;


[User] What are the first_name, country, account_status of each patient?

[Assistant] SELECT first_name, country, account_status FROM healthcare.patients;

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

[Assistant] SELECT first_name, country, account_status FROM healthcare.patients WHERE last_active BETWEEN '2023-01-01' AND '2023-03-31';

[User] Group patients by account_status and show the average of status.

[Assistant] SELECT account_status, AVERAGE(status) AS average_status FROM healthcare.patients GROUP BY account_status;


[User] Display all patients.

[Assistant] SELECT * FROM healthcare.patients;

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

[Assistant] SELECT * FROM healthcare.patients WHERE last_active >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Can you order these by first_name descending?

[Assistant] SELECT * FROM healthcare.patients WHERE last_active >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY first_name 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 healthcare.patients (
  id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  status varchar,
  bio char,
  website varchar,
  is_active boolean -- indicates if active is true,
  appointment_id text -- reference to appointments.id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(id)
)

CREATE TABLE healthcare.appointments (
  id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  available varchar NOT NULL,
  brand text,
  video_url character varying(128) -- identifier for video_url,
  reserved character varying(64) NOT NULL,
  manufacturer character varying(64),
  patient_id text NOT NULL -- reference to patients.id,
  FOREIGN KEY (patient_id) REFERENCES patients(id)
)

[User] List all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Sort the results by available descending.

[Assistant] SELECT * FROM healthcare.appointments ORDER BY available DESC;

[User] Show me the count of appointments grouped by available.

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


[User] Show me all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Show the results sorted by joined_at descending.

[Assistant] SELECT * FROM healthcare.patients ORDER BY joined_at DESC;

[User] Get the distribution of patients across different appointment_id values.

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


[User] Retrieve brand, manufacturer, patient_id for every appointment.

[Assistant] SELECT brand, manufacturer, patient_id FROM healthcare.appointments;

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

[Assistant] SELECT brand, manufacturer, patient_id FROM healthcare.appointments ORDER BY brand ASC;

[User] Restrict the output to 100 items.

[Assistant] SELECT brand, manufacturer, patient_id FROM healthcare.appointments ORDER BY brand ASC LIMIT 100;


[User] Get all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Find patients from 2023.

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

[User] Restrict the output to 10 items.

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


[User] List all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Order the output by created_at descending.

[Assistant] SELECT * FROM healthcare.appointments ORDER BY created_at DESC;

[User] Get the distribution of appointments across different available values.

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


[User] Show me all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Show me patients with bio LIKE 'A%'.

[Assistant] SELECT * FROM healthcare.patients WHERE bio LIKE 'A%';

[User] Restrict the output to 25 items.

[Assistant] SELECT * FROM healthcare.patients WHERE bio LIKE 'A%' LIMIT 25;


[User] Display all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] List status, appointment_id, created_at, reserved for each patient along with their appointment information.

[Assistant] SELECT *, appointments.created_at, appointments.reserved FROM healthcare.patients JOIN healthcare.appointments ON patients.appointment_id = appointments.id;

[User] Get the distribution of patients across different status values.

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


[User] What are the brand, patient_id, reserved of each appointment?

[Assistant] SELECT brand, patient_id, reserved FROM healthcare.appointments;

[User] Show me appointments with patient_id LIKE 'A%'.

[Assistant] SELECT brand, patient_id, reserved FROM healthcare.appointments WHERE patient_id LIKE 'A%';

[User] Show me average of video_url grouped by video_url for appointments.

[Assistant] SELECT video_url, AVERAGE(video_url) AS average_video_url FROM healthcare.appointments GROUP BY video_url;


[User] Show me available, patient_id, video_url for all appointments.

[Assistant] SELECT available, patient_id, video_url FROM healthcare.appointments;

[User] List brand, available, is_active, status for each appointment along with their patient information.

[Assistant] SELECT available, patient_id, video_url, patients.is_active, patients.status FROM healthcare.appointments JOIN healthcare.patients ON appointments.patient_id = patients.id;

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

[Assistant] SELECT available, patient_id, video_url, patients.is_active, patients.status FROM healthcare.appointments JOIN healthcare.patients ON appointments.patient_id = patients.id ORDER BY patient_id ASC;


[User] What are the is_active, appointment_id, status of each patient?

[Assistant] SELECT is_active, appointment_id, status FROM healthcare.patients;

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

[Assistant] SELECT is_active, appointment_id, status FROM healthcare.patients WHERE joined_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Group patients by bio and show the count of status.

[Assistant] SELECT bio, COUNT(status) AS count_status FROM healthcare.patients GROUP BY bio;


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 (
  id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  website character varying(64),
  profile_picture_url char,
  status character varying(256),
  country character varying(128),
  password_hash character varying(128),
  grade_id integer NOT NULL -- reference to grades.employee_id,
  FOREIGN KEY (grade_id) REFERENCES grades(employee_id)
)

CREATE TABLE education.assignments (
  id text PRIMARY KEY -- unique identifier,
  expires_at timestamp,
  msrp character varying(64),
  backorder character varying(256),
  manufacturer character varying(256),
  tax_rate character varying(128),
  stock_level character varying(256),
  subcategory char
)

CREATE TABLE education.grades (
  employee_id integer PRIMARY KEY -- unique identifier,
  last_active date,
  created_at date,
  avatar character varying(256) NOT NULL,
  membership_level character varying(128) NOT NULL,
  status varchar NOT NULL,
  address character varying(128) NOT NULL,
  city char
)

[User] List all students.

[Assistant] SELECT * FROM education.students;

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

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

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

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


[User] What are the status, id, password_hash of each student?

[Assistant] SELECT status, id, password_hash FROM education.students;

[User] What password_hash, profile_picture_url, city, membership_level do we have for students and their associated grades?

[Assistant] SELECT status, id, password_hash, grades.city, grades.membership_level FROM education.students JOIN education.grades ON students.grade_id = grades.employee_id;

[User] How many students are there per grade_id?

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


[User] Display all students.

[Assistant] SELECT * FROM education.students;

[User] Order the output by profile_picture_url descending.

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

[User] Limit the results to 100 rows.

[Assistant] SELECT * FROM education.students ORDER BY profile_picture_url DESC LIMIT 100;


[User] Get all students.

[Assistant] SELECT * FROM education.students;

[User] Find students created yesterday.

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

[User] Get average of id by website from students.

[Assistant] SELECT website, AVERAGE(id) AS average_id FROM education.students GROUP BY website;


[User] Get all students.

[Assistant] SELECT * FROM education.students;

[User] Can you order these by grade_id ascending?

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

[User] Calculate average of country for each website in students.

[Assistant] SELECT website, AVERAGE(country) AS average_country FROM education.students GROUP BY website;


[User] Retrieve profile_picture_url, country, grade_id for every student.

[Assistant] SELECT profile_picture_url, country, grade_id FROM education.students;

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

[Assistant] SELECT profile_picture_url, country, grade_id FROM education.students WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] What is the sum website for each password_hash in students?

[Assistant] SELECT password_hash, SUM(website) AS sum_website FROM education.students GROUP BY password_hash;


[User] List profile_picture_url, status, password_hash from students.

[Assistant] SELECT profile_picture_url, status, password_hash FROM education.students;

[User] List students that have password_hash LIKE 'A%'.

[Assistant] SELECT profile_picture_url, status, password_hash FROM education.students WHERE password_hash LIKE 'A%';

[User] How many students are there per id?

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


[User] Show me created_at, status, country for all students.

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

[User] Retrieve id, grade_id, last_active, membership_level showing the relationship between students and grades.

[Assistant] SELECT created_at, status, country, grades.last_active, grades.membership_level FROM education.students JOIN education.grades ON students.grade_id = grades.employee_id;

[User] What is the count id for each country in students?

[Assistant] SELECT country, COUNT(id) AS count_id FROM education.students GROUP BY country;


[User] List all students.

[Assistant] SELECT * FROM education.students;

[User] Find students where country LIKE 'A%'.

[Assistant] SELECT * FROM education.students WHERE country LIKE 'A%';

[User] Show me count of grade_id grouped by id for students.

[Assistant] SELECT id, COUNT(grade_id) AS count_grade_id FROM education.students GROUP BY id;


[User] Retrieve country, password_hash, profile_picture_url for every student.

[Assistant] SELECT country, password_hash, profile_picture_url FROM education.students;

[User] Retrieve students where created_at > '2023-01-01'.

[Assistant] SELECT country, password_hash, profile_picture_url FROM education.students WHERE created_at > '2023-01-01';

[User] Get count of password_hash by status from students.

[Assistant] SELECT status, COUNT(password_hash) AS count_password_hash FROM education.students GROUP BY 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 healthcare.doctors (
  sku character varying(64) NOT NULL -- unique identifier,
  expires_at date,
  category char NOT NULL,
  media_url char,
  name character varying(256),
  currency text NOT NULL,
  brand char,
  available character varying(64),
  prescription_id integer NOT NULL -- reference to prescriptions.transaction_id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(transaction_id)
)

CREATE TABLE healthcare.prescriptions (
  transaction_id integer PRIMARY KEY -- unique identifier,
  traded_at timestamp,
  cancelled_at timestamp,
  price numeric,
  delivery_status character varying(64) NOT NULL,
  approval_status character varying(256)
)

CREATE TABLE healthcare.patients (
  person_id character varying(64) NOT NULL -- unique identifier,
  last_active timestamp,
  age character varying(256) NOT NULL,
  account_status character varying(64),
  birth_date timestamp NOT NULL,
  zip_code character varying(128),
  api_key character varying(128)
)

CREATE TABLE healthcare.appointments (
  post_id character varying(64) NOT NULL -- unique identifier,
  edited_at timestamp,
  published_at timestamp without time zone,
  media_url character varying(128),
  subject character varying(128),
  format char,
  rating char,
  body text,
  prescription_id integer -- reference to prescriptions.transaction_id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(transaction_id)
)

[User] Get media_url, expires_at, available from all doctors.

[Assistant] SELECT media_url, expires_at, available FROM healthcare.doctors;

[User] Get doctors that match media_url LIKE 'A%'.

[Assistant] SELECT media_url, expires_at, available FROM healthcare.doctors WHERE media_url LIKE 'A%';

[User] Order the output by brand descending.

[Assistant] SELECT media_url, expires_at, available FROM healthcare.doctors WHERE media_url LIKE 'A%' ORDER BY brand DESC;


[User] List name, available, media_url from doctors.

[Assistant] SELECT name, available, media_url FROM healthcare.doctors;

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

[Assistant] SELECT name, available, media_url FROM healthcare.doctors WHERE expires_at > '2023-12-01';

[User] Sort the results by brand ascending.

[Assistant] SELECT name, available, media_url FROM healthcare.doctors WHERE expires_at > '2023-12-01' ORDER BY brand ASC;


[User] Get sku, currency, prescription_id from all doctors.

[Assistant] SELECT sku, currency, prescription_id FROM healthcare.doctors;

[User] Show me doctors with prescription_id > 16.

[Assistant] SELECT sku, currency, prescription_id FROM healthcare.doctors WHERE prescription_id > 16;

[User] Only show the top 20 results.

[Assistant] SELECT sku, currency, prescription_id FROM healthcare.doctors WHERE prescription_id > 16 LIMIT 20;


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Get all doctors from 2023.

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

[User] Can you order these by brand ascending?

[Assistant] SELECT * FROM healthcare.doctors WHERE expires_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY brand ASC;


[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Get all appointments older than 6 months.

[Assistant] SELECT * FROM healthcare.appointments WHERE edited_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Get the distribution of appointments across different media_url values.

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


[User] Show me all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] List appointments that have media_url LIKE 'A%'.

[Assistant] SELECT * FROM healthcare.appointments WHERE media_url LIKE 'A%';

[User] Calculate sum of post_id for each format in appointments.

[Assistant] SELECT format, SUM(post_id) AS sum_post_id FROM healthcare.appointments GROUP BY format;


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 humanresources.comments (
  post_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  description character varying(128),
  image_url character varying(128),
  user_id varchar -- identifier for user,
  reply_to_id text,
  shares text,
  likes character varying(64) NOT NULL,
  content character varying(256) NOT NULL
)

CREATE TABLE humanresources.orders (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  status character varying(128),
  currency char NOT NULL,
  exchange_rate varchar NOT NULL
)

CREATE TABLE humanresources.branches (
  location_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  category varchar,
  capacity char,
  latitude varchar,
  parking_available character varying(128)
)

[User] Display all branches.

[Assistant] SELECT * FROM humanresources.branches;

[User] Retrieve branches where created_at > '2023-01-01'.

[Assistant] SELECT * FROM humanresources.branches WHERE created_at > '2023-01-01';

[User] Show me average of created_at grouped by category for branches.

[Assistant] SELECT category, AVERAGE(created_at) AS average_created_at FROM humanresources.branches GROUP BY category;


[User] What are the currency, created_at, invoice_id of each order?

[Assistant] SELECT currency, created_at, invoice_id FROM humanresources.orders;

[User] Get orders that match status LIKE 'A%'.

[Assistant] SELECT currency, created_at, invoice_id FROM humanresources.orders WHERE status LIKE 'A%';

[User] What is the count status for each exchange_rate in orders?

[Assistant] SELECT exchange_rate, COUNT(status) AS count_status FROM humanresources.orders GROUP BY exchange_rate;


[User] What are the status, exchange_rate, invoice_id of each order?

[Assistant] SELECT status, exchange_rate, invoice_id FROM humanresources.orders;

[User] Find orders where invoice_id LIKE 'A%'.

[Assistant] SELECT status, exchange_rate, invoice_id FROM humanresources.orders WHERE invoice_id LIKE 'A%';

[User] Sort the results by created_at ascending.

[Assistant] SELECT status, exchange_rate, invoice_id FROM humanresources.orders WHERE invoice_id LIKE 'A%' ORDER BY created_at ASC;


[User] What are the user_id, content, image_url of each comment?

[Assistant] SELECT user_id, content, image_url FROM humanresources.comments;

[User] Show me comments that were older than 6 months.

[Assistant] SELECT user_id, content, image_url FROM humanresources.comments WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Only show the top 20 results.

[Assistant] SELECT user_id, content, image_url FROM humanresources.comments WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 20;


[User] List all branches.

[Assistant] SELECT * FROM humanresources.branches;

[User] List branches with dates modified within the last hour.

[Assistant] SELECT * FROM humanresources.branches WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Only show the top 10 results.

[Assistant] SELECT * FROM humanresources.branches WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 10;


[User] List all branches.

[Assistant] SELECT * FROM humanresources.branches;

[User] Find branches modified within the last hour.

[Assistant] SELECT * FROM humanresources.branches WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Show the results sorted by created_at ascending.

[Assistant] SELECT * FROM humanresources.branches WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY created_at ASC;


[User] List parking_available, capacity, latitude from branches.

[Assistant] SELECT parking_available, capacity, latitude FROM humanresources.branches;

[User] Retrieve branches where created_at > '2023-01-01'.

[Assistant] SELECT parking_available, capacity, latitude FROM humanresources.branches WHERE created_at > '2023-01-01';

[User] Can you order these by latitude ascending?

[Assistant] SELECT parking_available, capacity, latitude FROM humanresources.branches WHERE created_at > '2023-01-01' ORDER BY latitude ASC;


[User] List all orders.

[Assistant] SELECT * FROM humanresources.orders;

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

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

[User] What is the average status for each invoice_id in orders?

[Assistant] SELECT invoice_id, AVERAGE(status) AS average_status FROM humanresources.orders GROUP BY invoice_id;


[User] List exchange_rate, status, invoice_id from orders.

[Assistant] SELECT exchange_rate, status, invoice_id FROM humanresources.orders;

[User] Get orders that match exchange_rate LIKE 'A%'.

[Assistant] SELECT exchange_rate, status, invoice_id FROM humanresources.orders WHERE exchange_rate LIKE 'A%';

[User] Order the output by status ascending.

[Assistant] SELECT exchange_rate, status, invoice_id FROM humanresources.orders WHERE exchange_rate LIKE 'A%' ORDER BY status ASC;


[User] Retrieve user_id, image_url, updated_at for every comment.

[Assistant] SELECT user_id, image_url, updated_at FROM humanresources.comments;

[User] Get comments that match user_id LIKE 'A%'.

[Assistant] SELECT user_id, image_url, updated_at FROM humanresources.comments WHERE user_id LIKE 'A%';

[User] Calculate average of reply_to_id for each description in comments.

[Assistant] SELECT description, AVERAGE(reply_to_id) AS average_reply_to_id FROM humanresources.comments GROUP BY description;


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 (
  person_id character varying(64) NOT NULL -- unique identifier,
  last_active timestamp without time zone,
  created_at date,
  nationality character varying(64) NOT NULL,
  status character varying(128) NOT NULL,
  state character varying(256),
  timezone character varying(64) NOT NULL,
  api_key varchar NOT NULL,
  first_name character varying(128),
  inventor_id text NOT NULL -- reference to inventory.item_id,
  FOREIGN KEY (inventor_id) REFERENCES inventory(item_id)
)

CREATE TABLE e-commerce.categories (
  order_id integer PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  price numeric,
  amount integer
)

CREATE TABLE e-commerce.orders (
  payment_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  completed_at date,
  user_id varchar NOT NULL,
  exchange_rate varchar,
  payment_method character varying(128),
  categorie_id integer NOT NULL -- reference to categories.order_id,
  FOREIGN KEY (categorie_id) REFERENCES categories(order_id)
)

CREATE TABLE e-commerce.inventory (
  item_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  expires_at date,
  price decimal,
  backorder char,
  currency character varying(64) NOT NULL,
  name varchar,
  image_url character varying(128),
  discount numeric(38,14),
  categorie_id integer NOT NULL -- reference to categories.order_id,
  FOREIGN KEY (categorie_id) REFERENCES categories(order_id)
)

[User] Display all users.

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

[User] Order the output by status ascending.

[Assistant] SELECT * FROM e-commerce.users ORDER BY status ASC;

[User] Show me average of nationality grouped by person_id for users.

[Assistant] SELECT person_id, AVERAGE(nationality) AS average_nationality FROM e-commerce.users GROUP BY person_id;


[User] Get all orders.

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

[User] Show me orders that were older than 6 months.

[Assistant] SELECT * FROM e-commerce.orders WHERE completed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Show the results sorted by payment_id descending.

[Assistant] SELECT * FROM e-commerce.orders WHERE completed_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY payment_id DESC;


[User] What are the currency, expires_at, name of each inventory?

[Assistant] SELECT currency, expires_at, name FROM e-commerce.inventory;

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

[Assistant] SELECT currency, expires_at, name FROM e-commerce.inventory ORDER BY image_url ASC;

[User] Tally up inventory by name.

[Assistant] SELECT name, COUNT(*) AS count FROM e-commerce.inventory GROUP BY name 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.teachers (
  account_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at date,
  customer_id character varying(64) NOT NULL,
  payer_id char,
  currency char,
  debit varchar,
  amount numeric(38,14),
  verification_status character varying(64),
  grade_id integer NOT NULL -- reference to grades.venue_id,
  FOREIGN KEY (grade_id) REFERENCES grades(venue_id)
)

CREATE TABLE education.courses (
  user_id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  created_at date,
  last_login date,
  bio text,
  membership_level character varying(64) NOT NULL,
  salt character varying(256)
)

CREATE TABLE education.grades (
  venue_id integer PRIMARY KEY -- unique identifier,
  last_inspected timestamp without time zone,
  operating_hours char,
  latitude varchar,
  accessibility char,
  address_line1 character varying(64),
  name character varying(256)
)

[User] Get created_at, debit, verification_status from all teachers.

[Assistant] SELECT created_at, debit, verification_status FROM education.teachers;

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

[Assistant] SELECT created_at, debit, verification_status FROM education.teachers WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Limit the results to 5 rows.

[Assistant] SELECT created_at, debit, verification_status FROM education.teachers WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 5;


[User] List all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] Show the results sorted by currency descending.

[Assistant] SELECT * FROM education.teachers ORDER BY currency DESC;

[User] Show the results sorted by grade_id ascending.

[Assistant] SELECT * FROM education.teachers ORDER BY grade_id ASC;


[User] Retrieve all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] Get grade_id, debit, name, operating_hours by joining teachers with grades.

[Assistant] SELECT *, grades.name, grades.operating_hours FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.venue_id;

[User] Show the results sorted by customer_id descending.

[Assistant] SELECT *, grades.name, grades.operating_hours FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.venue_id ORDER BY customer_id DESC;


[User] Show me grade_id, amount, customer_id for all teachers.

[Assistant] SELECT grade_id, amount, customer_id FROM education.teachers;

[User] Can you order these by payer_id ascending?

[Assistant] SELECT grade_id, amount, customer_id FROM education.teachers ORDER BY payer_id ASC;

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

[Assistant] SELECT grade_id, amount, customer_id FROM education.teachers ORDER BY grade_id ASC;


[User] What are the grade_id, currency, verification_status of each teacher?

[Assistant] SELECT grade_id, currency, verification_status FROM education.teachers;

[User] Get amount, updated_at, name, last_inspected by joining teachers with grades.

[Assistant] SELECT grade_id, currency, verification_status, grades.name, grades.last_inspected FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.venue_id;

[User] Group teachers by payer_id and show the sum of currency.

[Assistant] SELECT payer_id, SUM(currency) AS sum_currency FROM education.teachers GROUP BY payer_id;


[User] What are the amount, debit, created_at of each teacher?

[Assistant] SELECT amount, debit, created_at FROM education.teachers;

[User] What verification_status, payer_id, name, address_line1 do we have for teachers and their associated grades?

[Assistant] SELECT amount, debit, created_at, grades.name, grades.address_line1 FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.venue_id;

[User] Only show the top 5 results.

[Assistant] SELECT amount, debit, created_at, grades.name, grades.address_line1 FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.venue_id LIMIT 5;


[User] Retrieve debit, currency, grade_id for every teacher.

[Assistant] SELECT debit, currency, grade_id FROM education.teachers;

[User] Can you order these by verification_status ascending?

[Assistant] SELECT debit, currency, grade_id FROM education.teachers ORDER BY verification_status ASC;

[User] Sort the results by created_at ascending.

[Assistant] SELECT debit, currency, grade_id FROM education.teachers ORDER BY created_at ASC;


[User] List all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] Retrieve verification_status, payer_id, operating_hours, latitude showing the relationship between teachers and grades.

[Assistant] SELECT *, grades.operating_hours, grades.latitude FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.venue_id;

[User] Sort the results by updated_at ascending.

[Assistant] SELECT *, grades.operating_hours, grades.latitude FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.venue_id ORDER BY updated_at ASC;


[User] What are the verification_status, updated_at, customer_id of each teacher?

[Assistant] SELECT verification_status, updated_at, customer_id FROM education.teachers;

[User] Get teachers that match amount > 4.

[Assistant] SELECT verification_status, updated_at, customer_id FROM education.teachers WHERE amount > 4;

[User] Return just 10 rows.

[Assistant] SELECT verification_status, updated_at, customer_id FROM education.teachers WHERE amount > 4 LIMIT 10;


[User] Show me verification_status, created_at, updated_at for all teachers.

[Assistant] SELECT verification_status, created_at, updated_at FROM education.teachers;

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

[Assistant] SELECT verification_status, created_at, updated_at FROM education.teachers WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Can you order these by grade_id descending?

[Assistant] SELECT verification_status, created_at, updated_at FROM education.teachers WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY grade_id 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.metadata (
  payment_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  status text,
  payment_status char NOT NULL,
  amount numeric,
  seller_id text NOT NULL -- identifier for seller,
  subtotal numeric(38,14),
  card_type character varying(256),
  wallet_id text -- reference to wallets.payment_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(payment_id)
)

CREATE TABLE tradingplatform.wallets (
  payment_id varchar PRIMARY KEY -- unique identifier,
  processed_at date,
  created_at timestamp,
  currency character varying(64) NOT NULL,
  status character varying(128),
  metadat_id integer -- reference to metadata.payment_id,
  FOREIGN KEY (metadat_id) REFERENCES metadata(payment_id)
)

[User] Show me card_type, wallet_id, amount for all metadata.

[Assistant] SELECT card_type, wallet_id, amount FROM tradingplatform.metadata;

[User] Sort the results by card_type ascending.

[Assistant] SELECT card_type, wallet_id, amount FROM tradingplatform.metadata ORDER BY card_type ASC;

[User] Limit the results to 25 rows.

[Assistant] SELECT card_type, wallet_id, amount FROM tradingplatform.metadata ORDER BY card_type ASC LIMIT 25;


[User] Get all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Can you order these by created_at ascending?

[Assistant] SELECT * FROM tradingplatform.wallets ORDER BY created_at ASC;

[User] Calculate sum of status for each created_at in wallets.

[Assistant] SELECT created_at, SUM(status) AS sum_status FROM tradingplatform.wallets GROUP BY created_at;


[User] Show me all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Find metadata where status LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.metadata WHERE status LIKE 'A%';

[User] How many metadata are there per amount?

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


[User] Show me all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Can you order these by status ascending?

[Assistant] SELECT * FROM tradingplatform.metadata ORDER BY status ASC;

[User] Show me the count of metadata grouped by wallet_id.

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


[User] Retrieve all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

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

[Assistant] SELECT * FROM tradingplatform.wallets WHERE processed_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM tradingplatform.wallets WHERE processed_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 10;


[User] Get all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Sort the results by wallet_id descending.

[Assistant] SELECT * FROM tradingplatform.metadata ORDER BY wallet_id DESC;

[User] Can you order these by amount ascending?

[Assistant] SELECT * FROM tradingplatform.metadata ORDER BY amount ASC;


[User] Display all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Show me wallets that were older than 6 months.

[Assistant] SELECT * FROM tradingplatform.wallets WHERE processed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] What is the max currency for each status in wallets?

[Assistant] SELECT status, MAX(currency) AS max_currency FROM tradingplatform.wallets GROUP BY status;


[User] Get all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] List seller_id, created_at, currency, status for each metadata along with their wallet information.

[Assistant] SELECT *, wallets.currency, wallets.status FROM tradingplatform.metadata JOIN tradingplatform.wallets ON metadata.wallet_id = wallets.payment_id;

[User] Calculate count of wallet_id for each wallet_id in metadata.

[Assistant] SELECT wallet_id, COUNT(wallet_id) AS count_wallet_id FROM tradingplatform.metadata GROUP BY wallet_id;


[User] Show me payment_status, card_type, created_at for all metadata.

[Assistant] SELECT payment_status, card_type, created_at FROM tradingplatform.metadata;

[User] What amount, payment_status, processed_at, created_at do we have for metadata and their associated wallets?

[Assistant] SELECT payment_status, card_type, created_at, wallets.processed_at, wallets.created_at FROM tradingplatform.metadata JOIN tradingplatform.wallets ON metadata.wallet_id = wallets.payment_id;

[User] Order the output by wallet_id descending.

[Assistant] SELECT payment_status, card_type, created_at, wallets.processed_at, wallets.created_at FROM tradingplatform.metadata JOIN tradingplatform.wallets ON metadata.wallet_id = wallets.payment_id ORDER BY wallet_id DESC;


[User] What are the processed_at, status, currency of each wallet?

[Assistant] SELECT processed_at, status, currency FROM tradingplatform.wallets;

[User] Retrieve metadat_id, status, payment_status, card_type showing the relationship between wallets and metadata.

[Assistant] SELECT processed_at, status, currency, metadata.payment_status, metadata.card_type FROM tradingplatform.wallets JOIN tradingplatform.metadata ON wallets.metadat_id = metadata.payment_id;

[User] Can you order these by created_at descending?

[Assistant] SELECT processed_at, status, currency, metadata.payment_status, metadata.card_type FROM tradingplatform.wallets JOIN tradingplatform.metadata ON wallets.metadat_id = metadata.payment_id ORDER BY created_at 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 travel.transactions (
  payment_id character varying(64) NOT NULL -- unique identifier,
  traded_at timestamp,
  created_at date,
  delivery_status character varying(64),
  status character varying(64),
  product_id character varying(64) -- identifier for product,
  amount smallint,
  currency character varying(256) NOT NULL,
  student_id text -- reference to students.customer_id,
  FOREIGN KEY (student_id) REFERENCES students(customer_id)
)

CREATE TABLE travel.students (
  customer_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  last_active timestamp,
  language text,
  first_name character varying(256),
  nationality character varying(64) NOT NULL,
  password_hash text,
  is_verified boolean,
  full_name text,
  is_active bit,
  venue_id text -- reference to venues.location_id,
  FOREIGN KEY (venue_id) REFERENCES venues(location_id)
)

CREATE TABLE travel.venues (
  location_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  last_inspected timestamp,
  street char,
  address_line2 character varying(128),
  name character varying(128),
  parking_available character varying(256) NOT NULL,
  accessibility text
)

[User] Show me traded_at, delivery_status, currency for all transactions.

[Assistant] SELECT traded_at, delivery_status, currency FROM travel.transactions;

[User] Can you order these by payment_id ascending?

[Assistant] SELECT traded_at, delivery_status, currency FROM travel.transactions ORDER BY payment_id ASC;

[User] Count the number of transactions in each amount category.

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


[User] List all students.

[Assistant] SELECT * FROM travel.students;

[User] Get is_active, created_at, accessibility, street by joining students with venues.

[Assistant] SELECT *, venues.accessibility, venues.street FROM travel.students JOIN travel.venues ON students.venue_id = venues.location_id;

[User] How many students are there per nationality?

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


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

[Assistant] SELECT first_name, is_verified, created_at FROM travel.students;

[User] Retrieve full_name, first_name, street, parking_available showing the relationship between students and venues.

[Assistant] SELECT first_name, is_verified, created_at, venues.street, venues.parking_available FROM travel.students JOIN travel.venues ON students.venue_id = venues.location_id;

[User] Show me max of last_active grouped by venue_id for students.

[Assistant] SELECT venue_id, MAX(last_active) AS max_last_active FROM travel.students GROUP BY venue_id;


[User] List venue_id, is_verified, password_hash from students.

[Assistant] SELECT venue_id, is_verified, password_hash FROM travel.students;

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

[Assistant] SELECT venue_id, is_verified, password_hash FROM travel.students WHERE last_active BETWEEN '2023-01-01' AND '2023-03-31';

[User] Show only 50 records.

[Assistant] SELECT venue_id, is_verified, password_hash FROM travel.students WHERE last_active BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 50;


[User] Retrieve status, product_id, currency for every transaction.

[Assistant] SELECT status, product_id, currency FROM travel.transactions;

[User] Find transactions between January and March.

[Assistant] SELECT status, product_id, currency FROM travel.transactions WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Group transactions by delivery_status and show the min of traded_at.

[Assistant] SELECT delivery_status, MIN(traded_at) AS min_traded_at FROM travel.transactions GROUP BY delivery_status;


[User] Display all transactions.

[Assistant] SELECT * FROM travel.transactions;

[User] Find transactions from last week.

[Assistant] SELECT * FROM travel.transactions WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

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

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


[User] What are the is_active, full_name, created_at of each student?

[Assistant] SELECT is_active, full_name, created_at FROM travel.students;

[User] List students with dates from last week.

[Assistant] SELECT is_active, full_name, created_at FROM travel.students WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Restrict the output to 10 items.

[Assistant] SELECT is_active, full_name, created_at FROM travel.students WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 10;


[User] Show me all students.

[Assistant] SELECT * FROM travel.students;

[User] Retrieve is_active, first_name, last_inspected, accessibility showing the relationship between students and venues.

[Assistant] SELECT *, venues.last_inspected, venues.accessibility FROM travel.students JOIN travel.venues ON students.venue_id = venues.location_id;

[User] Show me count of full_name grouped by is_active for students.

[Assistant] SELECT is_active, COUNT(full_name) AS count_full_name FROM travel.students GROUP BY is_active;


[User] Get student_id, delivery_status, currency from all transactions.

[Assistant] SELECT student_id, delivery_status, currency FROM travel.transactions;

[User] Order the output by student_id ascending.

[Assistant] SELECT student_id, delivery_status, currency FROM travel.transactions ORDER BY student_id ASC;

[User] What is the average delivery_status for each delivery_status in transactions?

[Assistant] SELECT delivery_status, AVERAGE(delivery_status) AS average_delivery_status FROM travel.transactions GROUP BY delivery_status;


[User] Retrieve payment_id, traded_at, amount for every transaction.

[Assistant] SELECT payment_id, traded_at, amount FROM travel.transactions;

[User] Get transactions that match status LIKE 'A%'.

[Assistant] SELECT payment_id, traded_at, amount FROM travel.transactions WHERE status LIKE 'A%';

[User] Calculate count of student_id for each payment_id in transactions.

[Assistant] SELECT payment_id, COUNT(student_id) AS count_student_id FROM travel.transactions 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 tradingplatform.assets (
  item_id character varying(64) NOT NULL -- unique identifier,
  published_at date,
  discount numeric NOT NULL,
  thumbnail_url character varying(128),
  description character varying(64) NOT NULL,
  popularity_score character varying(128),
  category text,
  metadat_id text NOT NULL -- reference to metadata.invoice_id,
  FOREIGN KEY (metadat_id) REFERENCES metadata(invoice_id)
)

CREATE TABLE tradingplatform.metadata (
  invoice_id text PRIMARY KEY -- unique identifier,
  processed_at date,
  updated_at timestamp,
  currency character varying(64),
  payee_id varchar NOT NULL -- identifier for payee,
  payer_id character varying(64),
  category character varying(64) NOT NULL,
  notes varchar
)

[User] List thumbnail_url, category, popularity_score from assets.

[Assistant] SELECT thumbnail_url, category, popularity_score FROM tradingplatform.assets;

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

[Assistant] SELECT thumbnail_url, category, popularity_score FROM tradingplatform.assets WHERE thumbnail_url LIKE 'A%';

[User] Get sum of thumbnail_url by popularity_score from assets.

[Assistant] SELECT popularity_score, SUM(thumbnail_url) AS sum_thumbnail_url FROM tradingplatform.assets GROUP BY popularity_score;


[User] What are the published_at, thumbnail_url, popularity_score of each asset?

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

[User] List published_at, description, payer_id, currency for each asset along with their metadata information.

[Assistant] SELECT published_at, thumbnail_url, popularity_score, metadata.payer_id, metadata.currency FROM tradingplatform.assets JOIN tradingplatform.metadata ON assets.metadat_id = metadata.invoice_id;

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

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


[User] Show me all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Can you order these by description ascending?

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

[User] Group assets by popularity_score and show the max of item_id.

[Assistant] SELECT popularity_score, MAX(item_id) AS max_item_id FROM tradingplatform.assets GROUP BY popularity_score;


[User] Retrieve all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Retrieve metadat_id, thumbnail_url, updated_at, payee_id showing the relationship between assets and metadata.

[Assistant] SELECT *, metadata.updated_at, metadata.payee_id FROM tradingplatform.assets JOIN tradingplatform.metadata ON assets.metadat_id = metadata.invoice_id;

[User] Order the output by category descending.

[Assistant] SELECT *, metadata.updated_at, metadata.payee_id FROM tradingplatform.assets JOIN tradingplatform.metadata ON assets.metadat_id = metadata.invoice_id ORDER BY category DESC;


[User] Show me all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

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

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

[User] Limit the results to 10 rows.

[Assistant] SELECT * FROM tradingplatform.assets WHERE published_at > '2023-12-01' LIMIT 10;


[User] Retrieve all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Get all assets between January and March.

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

[User] Show me average of metadat_id grouped by description for assets.

[Assistant] SELECT description, AVERAGE(metadat_id) AS average_metadat_id FROM tradingplatform.assets GROUP BY description;


[User] Display all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

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

[Assistant] SELECT * FROM tradingplatform.assets ORDER BY description DESC;

[User] How many assets are there per metadat_id?

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


[User] Retrieve all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] What popularity_score, published_at, currency, payee_id do we have for assets and their associated metadata?

[Assistant] SELECT *, metadata.currency, metadata.payee_id FROM tradingplatform.assets JOIN tradingplatform.metadata ON assets.metadat_id = metadata.invoice_id;

[User] Show the results sorted by discount ascending.

[Assistant] SELECT *, metadata.currency, metadata.payee_id FROM tradingplatform.assets JOIN tradingplatform.metadata ON assets.metadat_id = metadata.invoice_id ORDER BY discount ASC;


[User] List all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] What description, category, currency, notes do we have for assets and their associated metadata?

[Assistant] SELECT *, metadata.currency, metadata.notes FROM tradingplatform.assets JOIN tradingplatform.metadata ON assets.metadat_id = metadata.invoice_id;

[User] Show me the count of assets grouped by discount.

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


[User] List all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Show the results sorted by thumbnail_url ascending.

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

[User] Calculate sum of metadat_id for each item_id in assets.

[Assistant] SELECT item_id, SUM(metadat_id) AS sum_metadat_id FROM tradingplatform.assets GROUP BY item_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 socialmedia.users (
  user_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  last_active timestamp,
  country character varying(256) NOT NULL,
  salt text NOT NULL,
  website text NOT NULL
)

CREATE TABLE socialmedia.followers (
  id character varying(64) NOT NULL -- unique identifier,
  published_at date,
  expires_at timestamp without time zone,
  price smallint,
  name text NOT NULL,
  subcategory character varying(64),
  backorder varchar NOT NULL,
  thumbnail_url character varying(128),
  user_id text NOT NULL -- reference to users.user_id,
  FOREIGN KEY (user_id) REFERENCES users(user_id)
)

CREATE TABLE socialmedia.groups (
  user_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  last_name text,
  phone character varying(128),
  state varchar
)

[User] Retrieve id, user_id, name for every follower.

[Assistant] SELECT id, user_id, name FROM socialmedia.followers;

[User] Show the results sorted by backorder descending.

[Assistant] SELECT id, user_id, name FROM socialmedia.followers ORDER BY backorder DESC;

[User] Get sum of backorder by name from followers.

[Assistant] SELECT name, SUM(backorder) AS sum_backorder FROM socialmedia.followers GROUP BY name;


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show me backorder, published_at, created_at, website from followers and their related users.

[Assistant] SELECT *, users.created_at, users.website FROM socialmedia.followers JOIN socialmedia.users ON followers.user_id = users.user_id;

[User] How many followers are there per backorder?

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


[User] Get id, subcategory, backorder from all followers.

[Assistant] SELECT id, subcategory, backorder FROM socialmedia.followers;

[User] Find followers where expires_at > '2023-01-01'.

[Assistant] SELECT id, subcategory, backorder FROM socialmedia.followers WHERE expires_at > '2023-01-01';

[User] Restrict the output to 100 items.

[Assistant] SELECT id, subcategory, backorder FROM socialmedia.followers WHERE expires_at > '2023-01-01' LIMIT 100;


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] List name, backorder, created_at, website for each follower along with their user information.

[Assistant] SELECT *, users.created_at, users.website FROM socialmedia.followers JOIN socialmedia.users ON followers.user_id = users.user_id;

[User] Show the results sorted by price ascending.

[Assistant] SELECT *, users.created_at, users.website FROM socialmedia.followers JOIN socialmedia.users ON followers.user_id = users.user_id ORDER BY price ASC;


[User] What are the user_id, subcategory, price of each follower?

[Assistant] SELECT user_id, subcategory, price FROM socialmedia.followers;

[User] Order the output by user_id ascending.

[Assistant] SELECT user_id, subcategory, price FROM socialmedia.followers ORDER BY user_id ASC;

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

[Assistant] SELECT user_id, subcategory, price FROM socialmedia.followers ORDER BY name DESC;


[User] Show me all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Get followers that match backorder LIKE 'A%'.

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

[User] Restrict the output to 100 items.

[Assistant] SELECT * FROM socialmedia.followers WHERE backorder LIKE 'A%' LIMIT 100;


[User] Display all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] What id, backorder, last_active, salt do we have for followers and their associated users?

[Assistant] SELECT *, users.last_active, users.salt FROM socialmedia.followers JOIN socialmedia.users ON followers.user_id = users.user_id;

[User] Get max of published_at by price from followers.

[Assistant] SELECT price, MAX(published_at) AS max_published_at FROM socialmedia.followers GROUP BY price;


[User] List subcategory, user_id, price from followers.

[Assistant] SELECT subcategory, user_id, price FROM socialmedia.followers;

[User] List followers that have user_id LIKE 'A%'.

[Assistant] SELECT subcategory, user_id, price FROM socialmedia.followers WHERE user_id LIKE 'A%';

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

[Assistant] SELECT subcategory, user_id, price FROM socialmedia.followers WHERE user_id LIKE 'A%' ORDER BY expires_at DESC;


[User] Get price, expires_at, published_at from all followers.

[Assistant] SELECT price, expires_at, published_at FROM socialmedia.followers;

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

[Assistant] SELECT price, expires_at, published_at FROM socialmedia.followers WHERE expires_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Group followers by expires_at and show the sum of id.

[Assistant] SELECT expires_at, SUM(id) AS sum_id FROM socialmedia.followers GROUP BY expires_at;


[User] List expires_at, price, subcategory from followers.

[Assistant] SELECT expires_at, price, subcategory FROM socialmedia.followers;

[User] Show me followers with thumbnail_url LIKE 'A%'.

[Assistant] SELECT expires_at, price, subcategory FROM socialmedia.followers WHERE thumbnail_url LIKE 'A%';

[User] Get the distribution of followers across different id values.

[Assistant] SELECT id, COUNT(*) AS count FROM socialmedia.followers GROUP BY id 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 travel.students (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  website char,
  birth_date timestamp NOT NULL,
  is_active boolean,
  bio text,
  last_login timestamp without time zone,
  purchase_id text NOT NULL -- reference to purchases.id,
  FOREIGN KEY (purchase_id) REFERENCES purchases(id)
)

CREATE TABLE travel.locations (
  address_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  last_inspected timestamp,
  operating_hours character varying(64),
  address_line2 character varying(256),
  state text NOT NULL,
  capacity char,
  category text,
  accessibility varchar NOT NULL,
  student_id text -- reference to students.id,
  purchase_id text NOT NULL -- reference to purchases.id,
  FOREIGN KEY (student_id) REFERENCES students(id),
  FOREIGN KEY (purchase_id) REFERENCES purchases(id)
)

CREATE TABLE travel.purchases (
  id varchar PRIMARY KEY -- unique identifier,
  cancelled_at date,
  delivery_status varchar,
  quantity character varying(64),
  user_id char -- identifier for user,
  fee character varying(128),
  currency character varying(128)
)

[User] Display all locations.

[Assistant] SELECT * FROM travel.locations;

[User] Sort the results by category ascending.

[Assistant] SELECT * FROM travel.locations ORDER BY category ASC;

[User] Limit the results to 20 rows.

[Assistant] SELECT * FROM travel.locations ORDER BY category ASC LIMIT 20;


[User] Get address_line2, purchase_id, address_id from all locations.

[Assistant] SELECT address_line2, purchase_id, address_id FROM travel.locations;

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

[Assistant] SELECT address_line2, purchase_id, address_id FROM travel.locations WHERE last_inspected >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Show me min of last_inspected grouped by state for locations.

[Assistant] SELECT state, MIN(last_inspected) AS min_last_inspected FROM travel.locations GROUP BY state;