[User] Show me seller_id, audit_id, subtotal for all payments.

[Assistant] SELECT seller_id, audit_id, subtotal FROM finance.payments;

[User] Can you order these by invoice_id ascending?

[Assistant] SELECT seller_id, audit_id, subtotal FROM finance.payments ORDER BY invoice_id ASC;

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

[Assistant] SELECT seller_id, audit_id, subtotal FROM finance.payments ORDER BY subtotal 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.audits (
  account_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  exchange_rate text NOT NULL,
  approval_status char NOT NULL,
  category character varying(256) NOT NULL,
  notes character varying(64),
  customer_id text -- reference to customers.user_id,
  FOREIGN KEY (customer_id) REFERENCES customers(user_id)
)

CREATE TABLE finance.customers (
  user_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  joined_at timestamp,
  account_status character varying(128) NOT NULL,
  bio character varying(64) NOT NULL,
  status character varying(128)
)

CREATE TABLE finance.payments (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  completed_at date,
  price smallint,
  tax integer,
  seller_id varchar,
  subtotal integer NOT NULL,
  buyer_id varchar -- identifier for buyer,
  account_id text -- identifier for account,
  fee character varying(128),
  audit_id text NOT NULL -- reference to audits.account_id,
  customer_id text NOT NULL -- reference to customers.user_id,
  FOREIGN KEY (audit_id) REFERENCES audits(account_id),
  FOREIGN KEY (customer_id) REFERENCES customers(user_id)
)

[User] List subtotal, completed_at, buyer_id from payments.

[Assistant] SELECT subtotal, completed_at, buyer_id FROM finance.payments;

[User] Get tax, subtotal, processed_at, category by joining payments with audits.

[Assistant] SELECT subtotal, completed_at, buyer_id, audits.processed_at, audits.category FROM finance.payments JOIN finance.audits ON payments.audit_id = audits.account_id;

[User] Show only 25 records.

[Assistant] SELECT subtotal, completed_at, buyer_id, audits.processed_at, audits.category FROM finance.payments JOIN finance.audits ON payments.audit_id = audits.account_id LIMIT 25;


[User] Get all payments.

[Assistant] SELECT * FROM finance.payments;

[User] What fee, invoice_id, exchange_rate, approval_status do we have for payments and their associated audits?

[Assistant] SELECT *, audits.exchange_rate, audits.approval_status FROM finance.payments JOIN finance.audits ON payments.audit_id = audits.account_id;

[User] Only show the top 5 results.

[Assistant] SELECT *, audits.exchange_rate, audits.approval_status FROM finance.payments JOIN finance.audits ON payments.audit_id = audits.account_id LIMIT 5;


[User] Show me all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Order the output by approval_status descending.

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

[User] Restrict the output to 20 items.

[Assistant] SELECT * FROM finance.audits ORDER BY approval_status DESC LIMIT 20;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.doctors (
  account_id varchar PRIMARY KEY -- unique identifier,
  payment_date date,
  verification_status text,
  reconciliation_status char,
  approval_status varchar,
  reference_number text,
  description text,
  exchange_rate character varying(128) NOT NULL,
  billin_id integer -- reference to billing.id,
  FOREIGN KEY (billin_id) REFERENCES billing(id)
)

CREATE TABLE healthcare.patients (
  employee_id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  last_name character varying(256),
  password_hash character varying(128) NOT NULL,
  is_active boolean -- indicates if active is true,
  billin_id integer -- reference to billing.id,
  FOREIGN KEY (billin_id) REFERENCES billing(id)
)

CREATE TABLE healthcare.billing (
  id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  content character varying(256),
  format character varying(64),
  subject character varying(64),
  thumbnail character varying(128),
  shares character varying(256) NOT NULL
)

[User] What are the billin_id, exchange_rate, reference_number of each doctor?

[Assistant] SELECT billin_id, exchange_rate, reference_number FROM healthcare.doctors;

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

[Assistant] SELECT billin_id, exchange_rate, reference_number FROM healthcare.doctors WHERE payment_date >= CURRENT_DATE - INTERVAL '30 days';

[User] Return just 25 rows.

[Assistant] SELECT billin_id, exchange_rate, reference_number FROM healthcare.doctors WHERE payment_date >= CURRENT_DATE - INTERVAL '30 days' LIMIT 25;


[User] Show me approval_status, verification_status, reference_number for all doctors.

[Assistant] SELECT approval_status, verification_status, reference_number FROM healthcare.doctors;

[User] Show me doctors with verification_status LIKE 'A%'.

[Assistant] SELECT approval_status, verification_status, reference_number FROM healthcare.doctors WHERE verification_status LIKE 'A%';

[User] Order the output by approval_status ascending.

[Assistant] SELECT approval_status, verification_status, reference_number FROM healthcare.doctors WHERE verification_status LIKE 'A%' ORDER BY approval_status ASC;


[User] What are the last_name, password_hash, billin_id of each patient?

[Assistant] SELECT last_name, password_hash, billin_id FROM healthcare.patients;

[User] Retrieve patients where billin_id > 20.

[Assistant] SELECT last_name, password_hash, billin_id FROM healthcare.patients WHERE billin_id > 20;

[User] Show only 10 records.

[Assistant] SELECT last_name, password_hash, billin_id FROM healthcare.patients WHERE billin_id > 20 LIMIT 10;


[User] List approval_status, verification_status, reconciliation_status from doctors.

[Assistant] SELECT approval_status, verification_status, reconciliation_status FROM healthcare.doctors;

[User] Find doctors older than 6 months.

[Assistant] SELECT approval_status, verification_status, reconciliation_status FROM healthcare.doctors WHERE payment_date <= CURRENT_DATE - INTERVAL '6 months';

[User] Show only 50 records.

[Assistant] SELECT approval_status, verification_status, reconciliation_status FROM healthcare.doctors WHERE payment_date <= CURRENT_DATE - INTERVAL '6 months' LIMIT 50;


[User] Retrieve approval_status, verification_status, reconciliation_status for every doctor.

[Assistant] SELECT approval_status, verification_status, reconciliation_status FROM healthcare.doctors;

[User] Show me reconciliation_status, description, thumbnail, shares from doctors and their related billing.

[Assistant] SELECT approval_status, verification_status, reconciliation_status, billing.thumbnail, billing.shares FROM healthcare.doctors JOIN healthcare.billing ON doctors.billin_id = billing.id;

[User] Show the results sorted by verification_status descending.

[Assistant] SELECT approval_status, verification_status, reconciliation_status, billing.thumbnail, billing.shares FROM healthcare.doctors JOIN healthcare.billing ON doctors.billin_id = billing.id ORDER BY verification_status DESC;


[User] Retrieve password_hash, joined_at, billin_id for every patient.

[Assistant] SELECT password_hash, joined_at, billin_id FROM healthcare.patients;

[User] Can you order these by joined_at ascending?

[Assistant] SELECT password_hash, joined_at, billin_id FROM healthcare.patients ORDER BY joined_at ASC;

[User] What is the sum billin_id for each joined_at in patients?

[Assistant] SELECT joined_at, SUM(billin_id) AS sum_billin_id FROM healthcare.patients GROUP BY joined_at;


[User] Show me billin_id, last_name, is_active for all patients.

[Assistant] SELECT billin_id, last_name, is_active FROM healthcare.patients;

[User] List joined_at, last_name, updated_at, content for each patient along with their billing information.

[Assistant] SELECT billin_id, last_name, is_active, billing.updated_at, billing.content FROM healthcare.patients JOIN healthcare.billing ON patients.billin_id = billing.id;

[User] Limit the results to 100 rows.

[Assistant] SELECT billin_id, last_name, is_active, billing.updated_at, billing.content FROM healthcare.patients JOIN healthcare.billing ON patients.billin_id = billing.id LIMIT 100;


[User] List all patients.

[Assistant] SELECT * FROM healthcare.patients;

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

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

[User] Tally up patients by billin_id.

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


[User] Retrieve billin_id, joined_at, password_hash for every patient.

[Assistant] SELECT billin_id, joined_at, password_hash FROM healthcare.patients;

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

[Assistant] SELECT billin_id, joined_at, password_hash FROM healthcare.patients WHERE last_name LIKE 'A%';

[User] Calculate average of joined_at for each joined_at in patients.

[Assistant] SELECT joined_at, AVERAGE(joined_at) AS average_joined_at FROM healthcare.patients GROUP BY joined_at;


[User] Show me all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Get all patients from last week.

[Assistant] SELECT * FROM healthcare.patients WHERE joined_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Tally up patients by password_hash.

[Assistant] SELECT password_hash, COUNT(*) AS count FROM healthcare.patients GROUP BY password_hash 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 banking.sales (
  id text PRIMARY KEY -- unique identifier,
  traded_at date,
  payment_status character varying(256),
  card_type text NOT NULL,
  quantity char,
  product_id char,
  finance_id text NOT NULL -- reference to finances.payment_id,
  FOREIGN KEY (finance_id) REFERENCES finances(payment_id)
)

CREATE TABLE banking.finances (
  payment_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  created_at timestamp without time zone,
  exchange_rate character varying(256),
  status character varying(256),
  verification_status text,
  notes text NOT NULL,
  payee_id character varying(64) NOT NULL,
  reference_number character varying(256) NOT NULL,
  sale_id text -- reference to sales.id,
  FOREIGN KEY (sale_id) REFERENCES sales(id)
)

[User] Get card_type, payment_status, traded_at from all sales.

[Assistant] SELECT card_type, payment_status, traded_at FROM banking.sales;

[User] Retrieve sales where finance_id LIKE 'A%'.

[Assistant] SELECT card_type, payment_status, traded_at FROM banking.sales WHERE finance_id LIKE 'A%';

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

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


[User] Show me all sales.

[Assistant] SELECT * FROM banking.sales;

[User] Show me quantity, payment_status, payee_id, notes from sales and their related finances.

[Assistant] SELECT *, finances.payee_id, finances.notes FROM banking.sales JOIN banking.finances ON sales.finance_id = finances.payment_id;

[User] Group sales by card_type and show the min of finance_id.

[Assistant] SELECT card_type, MIN(finance_id) AS min_finance_id FROM banking.sales GROUP BY card_type;


[User] Retrieve processed_at, verification_status, status for every finance.

[Assistant] SELECT processed_at, verification_status, status FROM banking.finances;

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

[Assistant] SELECT processed_at, verification_status, status FROM banking.finances WHERE processed_at > '2023-12-01';

[User] How many finances are there per status?

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


[User] List all sales.

[Assistant] SELECT * FROM banking.sales;

[User] Retrieve sales where quantity LIKE 'A%'.

[Assistant] SELECT * FROM banking.sales WHERE quantity LIKE 'A%';

[User] Calculate average of product_id for each quantity in sales.

[Assistant] SELECT quantity, AVERAGE(product_id) AS average_product_id FROM banking.sales GROUP BY quantity;


[User] What are the product_id, payment_status, finance_id of each sale?

[Assistant] SELECT product_id, payment_status, finance_id FROM banking.sales;

[User] Retrieve sales where card_type LIKE 'A%'.

[Assistant] SELECT product_id, payment_status, finance_id FROM banking.sales WHERE card_type LIKE 'A%';

[User] Restrict the output to 20 items.

[Assistant] SELECT product_id, payment_status, finance_id FROM banking.sales WHERE card_type LIKE 'A%' LIMIT 20;


[User] Retrieve all sales.

[Assistant] SELECT * FROM banking.sales;

[User] Retrieve finance_id, card_type, exchange_rate, created_at showing the relationship between sales and finances.

[Assistant] SELECT *, finances.exchange_rate, finances.created_at FROM banking.sales JOIN banking.finances ON sales.finance_id = finances.payment_id;

[User] What is the sum product_id for each payment_status in sales?

[Assistant] SELECT payment_status, SUM(product_id) AS sum_product_id FROM banking.sales GROUP BY payment_status;


[User] List notes, verification_status, created_at from finances.

[Assistant] SELECT notes, verification_status, created_at FROM banking.finances;

[User] Find finances where exchange_rate LIKE 'A%'.

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

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

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


[User] Get product_id, payment_status, card_type from all sales.

[Assistant] SELECT product_id, payment_status, card_type FROM banking.sales;

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

[Assistant] SELECT product_id, payment_status, card_type FROM banking.sales WHERE finance_id LIKE 'A%';

[User] Restrict the output to 50 items.

[Assistant] SELECT product_id, payment_status, card_type FROM banking.sales WHERE finance_id LIKE 'A%' LIMIT 50;


[User] List all sales.

[Assistant] SELECT * FROM banking.sales;

[User] Sort the results by product_id descending.

[Assistant] SELECT * FROM banking.sales ORDER BY product_id DESC;

[User] Get sum of product_id by quantity from sales.

[Assistant] SELECT quantity, SUM(product_id) AS sum_product_id FROM banking.sales GROUP BY quantity;


[User] List reference_number, verification_status, sale_id from finances.

[Assistant] SELECT reference_number, verification_status, sale_id FROM banking.finances;

[User] Retrieve finances where the date is created yesterday.

[Assistant] SELECT reference_number, verification_status, sale_id FROM banking.finances WHERE processed_at = CURRENT_DATE - INTERVAL '1 day';

[User] Get the distribution of finances across different reference_number values.

[Assistant] SELECT reference_number, COUNT(*) AS count FROM banking.finances GROUP BY reference_number 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.enrollments (
  address_id character varying(64) NOT NULL -- unique identifier,
  last_inspected timestamp without time zone,
  created_at date,
  parking_available character varying(64),
  street varchar,
  location_lon character varying(256),
  coordinates character varying(64),
  department_id text -- reference to departments.venue_id,
  FOREIGN KEY (department_id) REFERENCES departments(venue_id)
)

CREATE TABLE education.students (
  id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  username character varying(64) NOT NULL,
  nationality character varying(256),
  country varchar NOT NULL,
  is_active boolean,
  phone character varying(128) NOT NULL,
  language character varying(128),
  age char
)

CREATE TABLE education.departments (
  venue_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  last_inspected date,
  location_lat character varying(256),
  parking_available character varying(256),
  operating_hours character varying(256),
  street character varying(256),
  timezone varchar,
  accessibility char NOT NULL,
  name character varying(128),
  student_id text NOT NULL -- reference to students.id,
  FOREIGN KEY (student_id) REFERENCES students(id)
)

[User] List all departments.

[Assistant] SELECT * FROM education.departments;

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

[Assistant] SELECT * FROM education.departments WHERE timezone LIKE 'A%';

[User] Group departments by accessibility and show the count of location_lat.

[Assistant] SELECT accessibility, COUNT(location_lat) AS count_location_lat FROM education.departments GROUP BY accessibility;


[User] List last_inspected, updated_at, name from departments.

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

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

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

[User] Count the number of departments in each parking_available category.

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


[User] Show me all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Show the results sorted by parking_available ascending.

[Assistant] SELECT * FROM education.enrollments ORDER BY parking_available ASC;

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

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


[User] Display all departments.

[Assistant] SELECT * FROM education.departments;

[User] Get departments that match street LIKE 'A%'.

[Assistant] SELECT * FROM education.departments WHERE street LIKE 'A%';

[User] Count the number of departments in each operating_hours category.

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


[User] Retrieve coordinates, address_id, department_id for every enrollment.

[Assistant] SELECT coordinates, address_id, department_id FROM education.enrollments;

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

[Assistant] SELECT coordinates, address_id, department_id FROM education.enrollments WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Return just 20 rows.

[Assistant] SELECT coordinates, address_id, department_id FROM education.enrollments WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 20;


[User] Display all departments.

[Assistant] SELECT * FROM education.departments;

[User] Order the output by parking_available descending.

[Assistant] SELECT * FROM education.departments ORDER BY parking_available DESC;

[User] Sort the results by street descending.

[Assistant] SELECT * FROM education.departments ORDER BY street DESC;


[User] Show me all departments.

[Assistant] SELECT * FROM education.departments;

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

[Assistant] SELECT * FROM education.departments WHERE student_id LIKE 'A%';

[User] What is the max name for each street in departments?

[Assistant] SELECT street, MAX(name) AS max_name FROM education.departments GROUP BY street;


[User] Show me all departments.

[Assistant] SELECT * FROM education.departments;

[User] List timezone, accessibility, country, created_at for each department along with their student information.

[Assistant] SELECT *, students.country, students.created_at FROM education.departments JOIN education.students ON departments.student_id = students.id;

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

[Assistant] SELECT *, students.country, students.created_at FROM education.departments JOIN education.students ON departments.student_id = students.id ORDER BY name DESC;


[User] Show me all departments.

[Assistant] SELECT * FROM education.departments;

[User] Show me operating_hours, parking_available, nationality, username from departments and their related students.

[Assistant] SELECT *, students.nationality, students.username FROM education.departments JOIN education.students ON departments.student_id = students.id;

[User] Tally up departments by last_inspected.

[Assistant] SELECT last_inspected, COUNT(*) AS count FROM education.departments GROUP BY last_inspected 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 finance.accounts (
  payment_id character varying(64) NOT NULL -- unique identifier,
  due_date timestamp without time zone,
  verification_status text,
  debit char NOT NULL,
  approval_status character varying(256),
  customer_id text NOT NULL -- reference to customers.customer_id,
  FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
)

CREATE TABLE finance.transactions (
  id integer PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  quantity character varying(128) NOT NULL,
  customer_id text -- identifier for customer,
  card_type text NOT NULL
)

CREATE TABLE finance.customers (
  customer_id text PRIMARY KEY -- unique identifier,
  last_active date,
  status character varying(64),
  display_name char NOT NULL,
  username varchar NOT NULL,
  api_key character varying(64) NOT NULL,
  account_status character varying(64) NOT NULL,
  membership_level character varying(128),
  transaction_id integer NOT NULL -- reference to transactions.id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(id)
)

[User] List all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Show me customers that were from 2023.

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

[User] Restrict the output to 5 items.

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


[User] List all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Find customers where username LIKE 'A%'.

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

[User] Show only 20 records.

[Assistant] SELECT * FROM finance.customers WHERE username LIKE 'A%' LIMIT 20;


[User] List all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Retrieve approval_status, debit, last_active, username showing the relationship between accounts and customers.

[Assistant] SELECT *, customers.last_active, customers.username FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.customer_id;

[User] Restrict the output to 100 items.

[Assistant] SELECT *, customers.last_active, customers.username FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.customer_id LIMIT 100;


[User] Get verification_status, payment_id, customer_id from all accounts.

[Assistant] SELECT verification_status, payment_id, customer_id FROM finance.accounts;

[User] List due_date, approval_status, username, membership_level for each account along with their customer information.

[Assistant] SELECT verification_status, payment_id, customer_id, customers.username, customers.membership_level FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.customer_id;

[User] Return just 5 rows.

[Assistant] SELECT verification_status, payment_id, customer_id, customers.username, customers.membership_level FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.customer_id LIMIT 5;


[User] List all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] What payment_id, verification_status, transaction_id, membership_level do we have for accounts and their associated customers?

[Assistant] SELECT *, customers.transaction_id, customers.membership_level FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.customer_id;

[User] Sort the results by approval_status descending.

[Assistant] SELECT *, customers.transaction_id, customers.membership_level FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.customer_id ORDER BY approval_status DESC;


[User] Get account_status, last_active, membership_level from all customers.

[Assistant] SELECT account_status, last_active, membership_level FROM finance.customers;

[User] Show me customers with account_status LIKE 'A%'.

[Assistant] SELECT account_status, last_active, membership_level FROM finance.customers WHERE account_status LIKE 'A%';

[User] What is the count api_key for each account_status in customers?

[Assistant] SELECT account_status, COUNT(api_key) AS count_api_key FROM finance.customers GROUP BY account_status;


[User] Get all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

[Assistant] SELECT * FROM finance.accounts WHERE due_date >= CURRENT_DATE - INTERVAL '30 days';

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

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


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Show me customers with membership_level LIKE 'A%'.

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

[User] Show me the count of customers grouped by transaction_id.

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


[User] Show me due_date, verification_status, customer_id for all accounts.

[Assistant] SELECT due_date, verification_status, customer_id FROM finance.accounts;

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

[Assistant] SELECT due_date, verification_status, customer_id FROM finance.accounts WHERE due_date >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Get the distribution of accounts across different customer_id values.

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


[User] Display all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] What payment_id, verification_status, api_key, membership_level do we have for accounts and their associated customers?

[Assistant] SELECT *, customers.api_key, customers.membership_level FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.customer_id;

[User] Get the distribution of accounts across different payment_id values.

[Assistant] SELECT payment_id, COUNT(*) AS count FROM finance.accounts GROUP BY payment_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 education.grades (
  item_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  expires_at timestamp without time zone,
  name character varying(128) NOT NULL,
  popularity_score char NOT NULL,
  featured_rank char NOT NULL,
  video_url character varying(128),
  manufacturer character varying(128) NOT NULL,
  tax_rate character varying(256),
  assignment_id text NOT NULL -- reference to assignments.id,
  FOREIGN KEY (assignment_id) REFERENCES assignments(id)
)

CREATE TABLE education.assignments (
  id varchar PRIMARY KEY -- unique identifier,
  published_at date,
  updated_at date,
  backorder character varying(256) NOT NULL,
  subcategory character varying(256),
  rating char,
  grade_id text NOT NULL -- reference to grades.item_id,
  FOREIGN KEY (grade_id) REFERENCES grades(item_id)
)

[User] Get featured_rank, assignment_id, manufacturer from all grades.

[Assistant] SELECT featured_rank, assignment_id, manufacturer FROM education.grades;

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

[Assistant] SELECT featured_rank, assignment_id, manufacturer FROM education.grades WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

[User] What is the count created_at for each popularity_score in grades?

[Assistant] SELECT popularity_score, COUNT(created_at) AS count_created_at FROM education.grades GROUP BY popularity_score;


[User] List all grades.

[Assistant] SELECT * FROM education.grades;

[User] Get grades that match manufacturer LIKE 'A%'.

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

[User] Get the distribution of grades across different expires_at values.

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


[User] List all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Sort the results by backorder ascending.

[Assistant] SELECT * FROM education.assignments ORDER BY backorder ASC;

[User] Limit the results to 50 rows.

[Assistant] SELECT * FROM education.assignments ORDER BY backorder ASC LIMIT 50;


[User] Display all grades.

[Assistant] SELECT * FROM education.grades;

[User] Show me assignment_id, tax_rate, published_at, updated_at from grades and their related assignments.

[Assistant] SELECT *, assignments.published_at, assignments.updated_at FROM education.grades JOIN education.assignments ON grades.assignment_id = assignments.id;

[User] Restrict the output to 25 items.

[Assistant] SELECT *, assignments.published_at, assignments.updated_at FROM education.grades JOIN education.assignments ON grades.assignment_id = assignments.id LIMIT 25;


[User] Get tax_rate, created_at, name from all grades.

[Assistant] SELECT tax_rate, created_at, name FROM education.grades;

[User] What assignment_id, expires_at, grade_id, published_at do we have for grades and their associated assignments?

[Assistant] SELECT tax_rate, created_at, name, assignments.grade_id, assignments.published_at FROM education.grades JOIN education.assignments ON grades.assignment_id = assignments.id;

[User] Get average of popularity_score by manufacturer from grades.

[Assistant] SELECT manufacturer, AVERAGE(popularity_score) AS average_popularity_score FROM education.grades GROUP BY manufacturer;


[User] Show me grade_id, rating, published_at for all assignments.

[Assistant] SELECT grade_id, rating, published_at FROM education.assignments;

[User] Show me backorder, rating, name, assignment_id from assignments and their related grades.

[Assistant] SELECT grade_id, rating, published_at, grades.name, grades.assignment_id FROM education.assignments JOIN education.grades ON assignments.grade_id = grades.item_id;

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

[Assistant] SELECT rating, SUM(published_at) AS sum_published_at FROM education.assignments GROUP BY rating;


[User] What are the published_at, grade_id, rating of each assignment?

[Assistant] SELECT published_at, grade_id, rating FROM education.assignments;

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

[Assistant] SELECT published_at, grade_id, rating FROM education.assignments ORDER BY grade_id ASC;

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

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


[User] Retrieve expires_at, assignment_id, manufacturer for every grade.

[Assistant] SELECT expires_at, assignment_id, manufacturer FROM education.grades;

[User] Get all grades between January and March.

[Assistant] SELECT expires_at, assignment_id, manufacturer FROM education.grades WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Restrict the output to 15 items.

[Assistant] SELECT expires_at, assignment_id, manufacturer FROM education.grades WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 15;


[User] Show me backorder, grade_id, rating for all assignments.

[Assistant] SELECT backorder, grade_id, rating FROM education.assignments;

[User] Sort the results by subcategory descending.

[Assistant] SELECT backorder, grade_id, rating FROM education.assignments ORDER BY subcategory DESC;

[User] Show only 100 records.

[Assistant] SELECT backorder, grade_id, rating FROM education.assignments ORDER BY subcategory DESC LIMIT 100;


[User] List all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Find assignments where updated_at > '2023-01-01'.

[Assistant] SELECT * FROM education.assignments WHERE updated_at > '2023-01-01';

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

[Assistant] SELECT * FROM education.assignments WHERE updated_at > '2023-01-01' ORDER BY updated_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 healthcare.medical_records (
  person_id character varying(64) NOT NULL -- unique identifier,
  last_active timestamp without time zone,
  updated_at date,
  nationality character varying(64),
  country char,
  salt text,
  website character varying(128),
  is_verified bit,
  billin_id text NOT NULL -- reference to billing.id,
  FOREIGN KEY (billin_id) REFERENCES billing(id)
)

CREATE TABLE healthcare.patients (
  customer_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  updated_at date,
  avatar character varying(128),
  last_name varchar,
  username text,
  birth_date date,
  display_name character varying(64),
  billin_id text -- reference to billing.id,
  FOREIGN KEY (billin_id) REFERENCES billing(id)
)

CREATE TABLE healthcare.billing (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  debit char,
  vendor_id character varying(256) NOT NULL -- identifier for vendor,
  approval_status text
)

[User] Show me website, last_active, salt for all medical_records.

[Assistant] SELECT website, last_active, salt FROM healthcare.medical_records;

[User] Get last_active, person_id, debit, approval_status by joining medical_records with billing.

[Assistant] SELECT website, last_active, salt, billing.debit, billing.approval_status FROM healthcare.medical_records JOIN healthcare.billing ON medical_records.billin_id = billing.id;

[User] Group medical_records by website and show the min of is_verified.

[Assistant] SELECT website, MIN(is_verified) AS min_is_verified FROM healthcare.medical_records GROUP BY website;


[User] What are the username, billin_id, updated_at of each patient?

[Assistant] SELECT username, billin_id, updated_at FROM healthcare.patients;

[User] List last_name, display_name, debit, updated_at for each patient along with their billing information.

[Assistant] SELECT username, billin_id, updated_at, billing.debit, billing.updated_at FROM healthcare.patients JOIN healthcare.billing ON patients.billin_id = billing.id;

[User] Show the results sorted by last_active descending.

[Assistant] SELECT username, billin_id, updated_at, billing.debit, billing.updated_at FROM healthcare.patients JOIN healthcare.billing ON patients.billin_id = billing.id ORDER BY last_active DESC;


[User] Get all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] Find medical_records where website LIKE 'A%'.

[Assistant] SELECT * FROM healthcare.medical_records WHERE website LIKE 'A%';

[User] Show me the count of medical_records grouped by website.

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


[User] Show me person_id, country, nationality for all medical_records.

[Assistant] SELECT person_id, country, nationality FROM healthcare.medical_records;

[User] Order the output by updated_at ascending.

[Assistant] SELECT person_id, country, nationality FROM healthcare.medical_records ORDER BY updated_at ASC;

[User] Restrict the output to 50 items.

[Assistant] SELECT person_id, country, nationality FROM healthcare.medical_records ORDER BY updated_at ASC LIMIT 50;


[User] Retrieve all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] Retrieve medical_records where billin_id LIKE 'A%'.

[Assistant] SELECT * FROM healthcare.medical_records WHERE billin_id LIKE 'A%';

[User] Calculate count of last_active for each updated_at in medical_records.

[Assistant] SELECT updated_at, COUNT(last_active) AS count_last_active FROM healthcare.medical_records GROUP BY updated_at;


[User] Display all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Retrieve username, avatar, approval_status, debit showing the relationship between patients and billing.

[Assistant] SELECT *, billing.approval_status, billing.debit FROM healthcare.patients JOIN healthcare.billing ON patients.billin_id = billing.id;

[User] What is the max last_name for each updated_at in patients?

[Assistant] SELECT updated_at, MAX(last_name) AS max_last_name FROM healthcare.patients GROUP BY updated_at;


[User] What are the last_active, updated_at, avatar of each patient?

[Assistant] SELECT last_active, updated_at, avatar FROM healthcare.patients;

[User] Show me username, billin_id, updated_at, vendor_id from patients and their related billing.

[Assistant] SELECT last_active, updated_at, avatar, billing.updated_at, billing.vendor_id FROM healthcare.patients JOIN healthcare.billing ON patients.billin_id = billing.id;

[User] Show the results sorted by birth_date ascending.

[Assistant] SELECT last_active, updated_at, avatar, billing.updated_at, billing.vendor_id FROM healthcare.patients JOIN healthcare.billing ON patients.billin_id = billing.id ORDER BY birth_date ASC;


[User] What are the billin_id, website, updated_at of each medical_record?

[Assistant] SELECT billin_id, website, updated_at FROM healthcare.medical_records;

[User] Can you order these by person_id ascending?

[Assistant] SELECT billin_id, website, updated_at FROM healthcare.medical_records ORDER BY person_id ASC;

[User] How many medical_records are there per country?

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


[User] Show me display_name, username, updated_at for all patients.

[Assistant] SELECT display_name, username, updated_at FROM healthcare.patients;

[User] Can you order these by last_name ascending?

[Assistant] SELECT display_name, username, updated_at FROM healthcare.patients ORDER BY last_name ASC;

[User] Get sum of display_name by billin_id from patients.

[Assistant] SELECT billin_id, SUM(display_name) AS sum_display_name FROM healthcare.patients GROUP BY billin_id;


[User] List all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] What avatar, billin_id, vendor_id, approval_status do we have for patients and their associated billing?

[Assistant] SELECT *, billing.vendor_id, billing.approval_status FROM healthcare.patients JOIN healthcare.billing ON patients.billin_id = billing.id;

[User] Show only 5 records.

[Assistant] SELECT *, billing.vendor_id, billing.approval_status FROM healthcare.patients JOIN healthcare.billing ON patients.billin_id = billing.id 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 e-commerce.shipping (
  venue_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  name character varying(64) NOT NULL,
  timezone varchar,
  zip_code varchar NOT NULL,
  state varchar,
  category varchar NOT NULL,
  order_id text -- reference to orders.payment_id,
  FOREIGN KEY (order_id) REFERENCES orders(payment_id)
)

CREATE TABLE e-commerce.orders (
  payment_id varchar PRIMARY KEY -- unique identifier,
  completed_at date,
  created_at date,
  total numeric,
  fee text NOT NULL,
  card_type character varying(256)
)

[User] Get zip_code, category, name from all shipping.

[Assistant] SELECT zip_code, category, name FROM e-commerce.shipping;

[User] What updated_at, timezone, fee, total do we have for shipping and their associated orders?

[Assistant] SELECT zip_code, category, name, orders.fee, orders.total FROM e-commerce.shipping JOIN e-commerce.orders ON shipping.order_id = orders.payment_id;

[User] How many shipping are there per zip_code?

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


[User] Display all shipping.

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

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

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

[User] Calculate max of state for each order_id in shipping.

[Assistant] SELECT order_id, MAX(state) AS max_state FROM e-commerce.shipping GROUP BY order_id;


[User] Get zip_code, order_id, venue_id from all shipping.

[Assistant] SELECT zip_code, order_id, venue_id FROM e-commerce.shipping;

[User] Order the output by order_id descending.

[Assistant] SELECT zip_code, order_id, venue_id FROM e-commerce.shipping ORDER BY order_id DESC;

[User] Group shipping by category and show the average of state.

[Assistant] SELECT category, AVERAGE(state) AS average_state FROM e-commerce.shipping GROUP BY category;


[User] Get all shipping.

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

[User] Get shipping that match order_id LIKE 'A%'.

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

[User] Limit the results to 5 rows.

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


[User] List name, state, timezone from shipping.

[Assistant] SELECT name, state, timezone FROM e-commerce.shipping;

[User] List shipping that have updated_at > '2023-01-01'.

[Assistant] SELECT name, state, timezone FROM e-commerce.shipping WHERE updated_at > '2023-01-01';

[User] Limit the results to 10 rows.

[Assistant] SELECT name, state, timezone FROM e-commerce.shipping WHERE updated_at > '2023-01-01' LIMIT 10;


[User] Show me timezone, venue_id, order_id for all shipping.

[Assistant] SELECT timezone, venue_id, order_id FROM e-commerce.shipping;

[User] What venue_id, category, created_at, completed_at do we have for shipping and their associated orders?

[Assistant] SELECT timezone, venue_id, order_id, orders.created_at, orders.completed_at FROM e-commerce.shipping JOIN e-commerce.orders ON shipping.order_id = orders.payment_id;

[User] Tally up shipping by updated_at.

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


[User] Retrieve state, zip_code, category for every shipping.

[Assistant] SELECT state, zip_code, category FROM e-commerce.shipping;

[User] Get all shipping from last week.

[Assistant] SELECT state, zip_code, category FROM e-commerce.shipping WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Return just 50 rows.

[Assistant] SELECT state, zip_code, category FROM e-commerce.shipping WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 50;


[User] Get all shipping.

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

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

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

[User] Only show the top 50 results.

[Assistant] SELECT * FROM e-commerce.shipping WHERE updated_at > '2023-01-01' LIMIT 50;


[User] Retrieve updated_at, name, timezone for every shipping.

[Assistant] SELECT updated_at, name, timezone FROM e-commerce.shipping;

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

[Assistant] SELECT updated_at, name, timezone FROM e-commerce.shipping ORDER BY zip_code ASC;

[User] Show me the count of shipping grouped by venue_id.

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


[User] What are the category, venue_id, zip_code of each shipping?

[Assistant] SELECT category, venue_id, zip_code FROM e-commerce.shipping;

[User] Find shipping where name LIKE 'A%'.

[Assistant] SELECT category, venue_id, zip_code FROM e-commerce.shipping WHERE name LIKE 'A%';

[User] Tally up shipping by state.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.orders (
  invoice_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  delivery_status character varying(256) NOT NULL,
  payment_status character varying(256),
  subtotal integer,
  buyer_id character varying(256) -- identifier for buyer,
  currency char,
  quantity text NOT NULL,
  inventor_id text NOT NULL -- reference to inventory.barcode,
  FOREIGN KEY (inventor_id) REFERENCES inventory(barcode)
)

CREATE TABLE e-commerce.users (
  customer_id integer PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  account_status varchar NOT NULL,
  gender character varying(256),
  status character varying(128) NOT NULL,
  username character varying(64),
  inventor_id text -- reference to inventory.barcode,
  FOREIGN KEY (inventor_id) REFERENCES inventory(barcode)
)

CREATE TABLE e-commerce.inventory (
  barcode text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  backorder text NOT NULL,
  currency char,
  tax_rate character varying(128) NOT NULL,
  brand text,
  media_url char NOT NULL,
  user_id integer -- reference to users.customer_id,
  FOREIGN KEY (user_id) REFERENCES users(customer_id)
)

[User] Retrieve updated_at, backorder, media_url for every inventory.

[Assistant] SELECT updated_at, backorder, media_url FROM e-commerce.inventory;

[User] Retrieve brand, user_id, inventor_id, username showing the relationship between inventory and users.

[Assistant] SELECT updated_at, backorder, media_url, users.inventor_id, users.username FROM e-commerce.inventory JOIN e-commerce.users ON inventory.user_id = users.customer_id;

[User] Restrict the output to 50 items.

[Assistant] SELECT updated_at, backorder, media_url, users.inventor_id, users.username FROM e-commerce.inventory JOIN e-commerce.users ON inventory.user_id = users.customer_id LIMIT 50;


[User] Get inventor_id, username, status from all users.

[Assistant] SELECT inventor_id, username, status FROM e-commerce.users;

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

[Assistant] SELECT inventor_id, username, status FROM e-commerce.users ORDER BY account_status DESC;

[User] Tally up users by account_status.

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


[User] List all inventory.

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

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

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

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

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


[User] Display all orders.

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

[User] List quantity, payment_status, updated_at, brand for each order along with their inventory information.

[Assistant] SELECT *, inventory.updated_at, inventory.brand FROM e-commerce.orders JOIN e-commerce.inventory ON orders.inventor_id = inventory.barcode;

[User] How many orders are there per subtotal?

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


[User] Retrieve all users.

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

[User] Order the output by joined_at descending.

[Assistant] SELECT * FROM e-commerce.users ORDER BY joined_at DESC;

[User] Can you order these by inventor_id descending?

[Assistant] SELECT * FROM e-commerce.users ORDER BY inventor_id DESC;


[User] List updated_at, buyer_id, subtotal from orders.

[Assistant] SELECT updated_at, buyer_id, subtotal FROM e-commerce.orders;

[User] Sort the results by updated_at descending.

[Assistant] SELECT updated_at, buyer_id, subtotal FROM e-commerce.orders ORDER BY updated_at DESC;

[User] Return just 25 rows.

[Assistant] SELECT updated_at, buyer_id, subtotal FROM e-commerce.orders ORDER BY updated_at DESC LIMIT 25;


[User] What are the inventor_id, currency, quantity of each order?

[Assistant] SELECT inventor_id, currency, quantity FROM e-commerce.orders;

[User] What currency, inventor_id, user_id, tax_rate do we have for orders and their associated inventory?

[Assistant] SELECT inventor_id, currency, quantity, inventory.user_id, inventory.tax_rate FROM e-commerce.orders JOIN e-commerce.inventory ON orders.inventor_id = inventory.barcode;

[User] Sort the results by payment_status ascending.

[Assistant] SELECT inventor_id, currency, quantity, inventory.user_id, inventory.tax_rate FROM e-commerce.orders JOIN e-commerce.inventory ON orders.inventor_id = inventory.barcode ORDER BY payment_status ASC;


[User] List account_status, inventor_id, username from users.

[Assistant] SELECT account_status, inventor_id, username FROM e-commerce.users;

[User] List users that have status LIKE 'A%'.

[Assistant] SELECT account_status, inventor_id, username FROM e-commerce.users WHERE status LIKE 'A%';

[User] Tally up users by gender.

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


[User] Get account_status, status, joined_at from all users.

[Assistant] SELECT account_status, status, joined_at FROM e-commerce.users;

[User] Get username, account_status, user_id, backorder by joining users with inventory.

[Assistant] SELECT account_status, status, joined_at, inventory.user_id, inventory.backorder FROM e-commerce.users JOIN e-commerce.inventory ON users.inventor_id = inventory.barcode;

[User] Show only 50 records.

[Assistant] SELECT account_status, status, joined_at, inventory.user_id, inventory.backorder FROM e-commerce.users JOIN e-commerce.inventory ON users.inventor_id = inventory.barcode LIMIT 50;


[User] What are the gender, account_status, status of each user?

[Assistant] SELECT gender, account_status, status FROM e-commerce.users;

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

[Assistant] SELECT gender, account_status, status FROM e-commerce.users WHERE joined_at > '2023-12-01';

[User] Show me the count of users grouped by username.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.orders (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  traded_at timestamp without time zone,
  cancelled_at timestamp without time zone,
  user_id char,
  card_type varchar,
  status text NOT NULL,
  fee char NOT NULL,
  amount smallint,
  subtotal bigint NOT NULL,
  shippin_id text NOT NULL -- reference to shipping.transaction_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(transaction_id)
)

CREATE TABLE e-commerce.shipping (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at timestamp,
  payee_id character varying(256),
  credit text NOT NULL,
  debit character varying(64),
  status character varying(256)
)

CREATE TABLE e-commerce.products (
  barcode text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  updated_at date,
  tax_rate varchar,
  title character varying(256),
  currency character varying(64),
  subcategory text
)

CREATE TABLE e-commerce.reviews (
  content_id character varying(64) NOT NULL -- unique identifier,
  published_at date,
  keywords text,
  attachment_url character varying(64),
  score character varying(128)
)

[User] Get all orders.

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

[User] Sort the results by amount ascending.

[Assistant] SELECT * FROM e-commerce.orders ORDER BY amount ASC;

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

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


[User] Get all orders.

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

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

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

[User] Show only 10 records.

[Assistant] SELECT * FROM e-commerce.orders WHERE traded_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 10;


[User] Get all orders.

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

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

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

[User] Return just 20 rows.

[Assistant] SELECT * FROM e-commerce.orders WHERE transaction_id LIKE 'A%' LIMIT 20;


[User] Get transaction_id, shippin_id, cancelled_at from all orders.

[Assistant] SELECT transaction_id, shippin_id, cancelled_at FROM e-commerce.orders;

[User] What amount, cancelled_at, created_at, payee_id do we have for orders and their associated shipping?

[Assistant] SELECT transaction_id, shippin_id, cancelled_at, shipping.created_at, shipping.payee_id FROM e-commerce.orders JOIN e-commerce.shipping ON orders.shippin_id = shipping.transaction_id;

[User] Return just 15 rows.

[Assistant] SELECT transaction_id, shippin_id, cancelled_at, shipping.created_at, shipping.payee_id FROM e-commerce.orders JOIN e-commerce.shipping ON orders.shippin_id = shipping.transaction_id LIMIT 15;


[User] Retrieve all orders.

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

[User] Retrieve card_type, transaction_id, credit, updated_at showing the relationship between orders and shipping.

[Assistant] SELECT *, shipping.credit, shipping.updated_at FROM e-commerce.orders JOIN e-commerce.shipping ON orders.shippin_id = shipping.transaction_id;

[User] Restrict the output to 20 items.

[Assistant] SELECT *, shipping.credit, shipping.updated_at FROM e-commerce.orders JOIN e-commerce.shipping ON orders.shippin_id = shipping.transaction_id LIMIT 20;


[User] Retrieve all orders.

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

[User] Show me orders that were from 2023.

[Assistant] SELECT * FROM e-commerce.orders WHERE traded_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Tally up orders by fee.

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


[User] What are the status, card_type, cancelled_at of each order?

[Assistant] SELECT status, card_type, cancelled_at FROM e-commerce.orders;

[User] What traded_at, user_id, debit, status do we have for orders and their associated shipping?

[Assistant] SELECT status, card_type, cancelled_at, shipping.debit, shipping.status FROM e-commerce.orders JOIN e-commerce.shipping ON orders.shippin_id = shipping.transaction_id;

[User] Show only 5 records.

[Assistant] SELECT status, card_type, cancelled_at, shipping.debit, shipping.status FROM e-commerce.orders JOIN e-commerce.shipping ON orders.shippin_id = shipping.transaction_id LIMIT 5;


[User] Display all orders.

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

[User] List amount, fee, created_at, payee_id for each order along with their shipping information.

[Assistant] SELECT *, shipping.created_at, shipping.payee_id FROM e-commerce.orders JOIN e-commerce.shipping ON orders.shippin_id = shipping.transaction_id;

[User] Show only 5 records.

[Assistant] SELECT *, shipping.created_at, shipping.payee_id FROM e-commerce.orders JOIN e-commerce.shipping ON orders.shippin_id = shipping.transaction_id LIMIT 5;


[User] Show me all orders.

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

[User] Show the results sorted by fee ascending.

[Assistant] SELECT * FROM e-commerce.orders ORDER BY fee ASC;

[User] Can you order these by transaction_id ascending?

[Assistant] SELECT * FROM e-commerce.orders ORDER BY transaction_id ASC;


[User] Show me all orders.

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

[User] Find orders from 2023.

[Assistant] SELECT * FROM e-commerce.orders WHERE cancelled_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Show the results sorted by transaction_id descending.

[Assistant] SELECT * FROM e-commerce.orders WHERE cancelled_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY transaction_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 e-commerce.shipping (
  id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  views varchar,
  video_url character varying(128) -- identifier for video_url,
  stock_level varchar NOT NULL,
  title char NOT NULL
)

CREATE TABLE e-commerce.orders (
  payment_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at timestamp without time zone,
  delivery_status text,
  exchange_rate text NOT NULL,
  card_type character varying(128),
  fee character varying(128),
  tax numeric NOT NULL
)

CREATE TABLE e-commerce.order_items (
  store_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  location_lat char,
  parking_available character varying(256),
  type char,
  operating_hours char,
  longitude character varying(256) NOT NULL,
  order_id text NOT NULL -- reference to orders.payment_id,
  FOREIGN KEY (order_id) REFERENCES orders(payment_id)
)

CREATE TABLE e-commerce.categories (
  barcode character varying(64) NOT NULL -- unique identifier,
  published_at date,
  video_url character varying(64) -- identifier for video_url,
  thumbnail_url char,
  featured_rank character varying(64),
  price decimal,
  media_url character varying(256)
)

[User] Get all order_items.

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

[User] Retrieve order_id, updated_at, created_at, fee showing the relationship between order_items and orders.

[Assistant] SELECT *, orders.created_at, orders.fee FROM e-commerce.order_items JOIN e-commerce.orders ON order_items.order_id = orders.payment_id;

[User] Count the number of order_items in each operating_hours category.

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


[User] What are the location_lat, updated_at, longitude of each order_item?

[Assistant] SELECT location_lat, updated_at, longitude FROM e-commerce.order_items;

[User] Sort the results by order_id ascending.

[Assistant] SELECT location_lat, updated_at, longitude FROM e-commerce.order_items ORDER BY order_id ASC;

[User] Count the number of order_items in each operating_hours category.

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


[User] Retrieve all order_items.

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

[User] Retrieve order_items where parking_available LIKE 'A%'.

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

[User] Show me max of parking_available grouped by order_id for order_items.

[Assistant] SELECT order_id, MAX(parking_available) AS max_parking_available FROM e-commerce.order_items GROUP BY order_id;


[User] List location_lat, longitude, type from order_items.

[Assistant] SELECT location_lat, longitude, type FROM e-commerce.order_items;

[User] Get all order_items between January and March.

[Assistant] SELECT location_lat, longitude, type FROM e-commerce.order_items WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Only show the top 10 results.

[Assistant] SELECT location_lat, longitude, type FROM e-commerce.order_items WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 10;


[User] List longitude, parking_available, store_id from order_items.

[Assistant] SELECT longitude, parking_available, store_id FROM e-commerce.order_items;

[User] Can you order these by type descending?

[Assistant] SELECT longitude, parking_available, store_id FROM e-commerce.order_items ORDER BY type DESC;

[User] Can you order these by type descending?

[Assistant] SELECT longitude, parking_available, store_id FROM e-commerce.order_items ORDER BY type DESC;


[User] Get all order_items.

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

[User] List parking_available, order_id, updated_at, card_type for each order_item along with their order information.

[Assistant] SELECT *, orders.updated_at, orders.card_type FROM e-commerce.order_items JOIN e-commerce.orders ON order_items.order_id = orders.payment_id;

[User] Tally up order_items by operating_hours.

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


[User] Show me all order_items.

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

[User] Get order_items that match order_id LIKE 'A%'.

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

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM e-commerce.order_items WHERE order_id LIKE 'A%' LIMIT 10;


[User] Retrieve all order_items.

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

[User] Can you order these by updated_at descending?

[Assistant] SELECT * FROM e-commerce.order_items ORDER BY updated_at DESC;

[User] Order the output by updated_at ascending.

[Assistant] SELECT * FROM e-commerce.order_items ORDER BY updated_at ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE music.locations (
  store_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  last_inspected date,
  street char,
  name varchar NOT NULL,
  country text,
  state char,
  finance_id integer -- reference to finances.account_id,
  FOREIGN KEY (finance_id) REFERENCES finances(account_id)
)

CREATE TABLE music.finances (
  account_id integer PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  exchange_rate character varying(128),
  reconciliation_status text,
  invoice_number character varying(128) NOT NULL
)

[User] Show me all locations.

[Assistant] SELECT * FROM music.locations;

[User] Can you order these by last_inspected descending?

[Assistant] SELECT * FROM music.locations ORDER BY last_inspected DESC;

[User] Tally up locations by country.

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


[User] List all locations.

[Assistant] SELECT * FROM music.locations;

[User] Show me street, store_id, reconciliation_status, exchange_rate from locations and their related finances.

[Assistant] SELECT *, finances.reconciliation_status, finances.exchange_rate FROM music.locations JOIN music.finances ON locations.finance_id = finances.account_id;

[User] How many locations are there per finance_id?

[Assistant] SELECT finance_id, COUNT(*) AS count FROM music.locations GROUP BY finance_id ORDER BY count DESC;


[User] Get store_id, name, country from all locations.

[Assistant] SELECT store_id, name, country FROM music.locations;

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

[Assistant] SELECT store_id, name, country FROM music.locations WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Get the distribution of locations across different last_inspected values.

[Assistant] SELECT last_inspected, COUNT(*) AS count FROM music.locations GROUP BY last_inspected ORDER BY count DESC;


[User] List all locations.

[Assistant] SELECT * FROM music.locations;

[User] List locations that have finance_id > 66.

[Assistant] SELECT * FROM music.locations WHERE finance_id > 66;

[User] Get count of last_inspected by created_at from locations.

[Assistant] SELECT created_at, COUNT(last_inspected) AS count_last_inspected FROM music.locations GROUP BY created_at;


[User] Display all locations.

[Assistant] SELECT * FROM music.locations;

[User] Retrieve locations where street LIKE 'A%'.

[Assistant] SELECT * FROM music.locations WHERE street LIKE 'A%';

[User] Can you order these by created_at descending?

[Assistant] SELECT * FROM music.locations WHERE street LIKE 'A%' ORDER BY created_at DESC;


[User] List all locations.

[Assistant] SELECT * FROM music.locations;

[User] List created_at, store_id, reconciliation_status, processed_at for each location along with their finance information.

[Assistant] SELECT *, finances.reconciliation_status, finances.processed_at FROM music.locations JOIN music.finances ON locations.finance_id = finances.account_id;

[User] Show me the count of locations grouped by store_id.

[Assistant] SELECT store_id, COUNT(*) AS count FROM music.locations GROUP BY store_id ORDER BY count DESC;


[User] List all locations.

[Assistant] SELECT * FROM music.locations;

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

[Assistant] SELECT * FROM music.locations WHERE last_inspected <= CURRENT_DATE - INTERVAL '6 months';

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

[Assistant] SELECT * FROM music.locations WHERE last_inspected <= CURRENT_DATE - INTERVAL '6 months' ORDER BY name ASC;


[User] Show me all locations.

[Assistant] SELECT * FROM music.locations;

[User] Show me locations with name LIKE 'A%'.

[Assistant] SELECT * FROM music.locations WHERE name LIKE 'A%';

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

[Assistant] SELECT * FROM music.locations WHERE name LIKE 'A%' ORDER BY created_at DESC;


[User] Display all locations.

[Assistant] SELECT * FROM music.locations;

[User] Retrieve name, finance_id, exchange_rate, reconciliation_status showing the relationship between locations and finances.

[Assistant] SELECT *, finances.exchange_rate, finances.reconciliation_status FROM music.locations JOIN music.finances ON locations.finance_id = finances.account_id;

[User] Limit the results to 25 rows.

[Assistant] SELECT *, finances.exchange_rate, finances.reconciliation_status FROM music.locations JOIN music.finances ON locations.finance_id = finances.account_id LIMIT 25;


[User] Retrieve all locations.

[Assistant] SELECT * FROM music.locations;

[User] Show me name, finance_id, invoice_number, processed_at from locations and their related finances.

[Assistant] SELECT *, finances.invoice_number, finances.processed_at FROM music.locations JOIN music.finances ON locations.finance_id = finances.account_id;

[User] Show me min of finance_id grouped by country for locations.

[Assistant] SELECT country, MIN(finance_id) AS min_finance_id FROM music.locations GROUP BY country;


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.customers (
  person_id integer PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  last_login timestamp,
  city character varying(64),
  phone text NOT NULL,
  last_name text,
  email char,
  investment_id text -- reference to investments.id,
  FOREIGN KEY (investment_id) REFERENCES investments(id)
)

CREATE TABLE finance.audits (
  account_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  approval_status char,
  exchange_rate char,
  verification_status character varying(256) NOT NULL,
  payment_id integer NOT NULL -- reference to payments.id,
  FOREIGN KEY (payment_id) REFERENCES payments(id)
)

CREATE TABLE finance.payments (
  id integer PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  account_id text -- identifier for account,
  total numeric(38,14),
  card_type character varying(64) NOT NULL,
  customer_id integer -- reference to customers.person_id,
  FOREIGN KEY (customer_id) REFERENCES customers(person_id)
)

CREATE TABLE finance.investments (
  id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at timestamp,
  country varchar NOT NULL,
  operating_hours text,
  longitude char,
  timezone character varying(64),
  state character varying(64),
  category varchar
)

[User] Show me all audits.

[Assistant] SELECT * FROM finance.audits;

[User] List payment_id, approval_status, customer_id, card_type for each audit along with their payment information.

[Assistant] SELECT *, payments.customer_id, payments.card_type FROM finance.audits JOIN finance.payments ON audits.payment_id = payments.id;

[User] Order the output by payment_id ascending.

[Assistant] SELECT *, payments.customer_id, payments.card_type FROM finance.audits JOIN finance.payments ON audits.payment_id = payments.id ORDER BY payment_id ASC;


[User] Get all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Show me email, city, longitude, state from customers and their related investments.

[Assistant] SELECT *, investments.longitude, investments.state FROM finance.customers JOIN finance.investments ON customers.investment_id = investments.id;

[User] Return just 20 rows.

[Assistant] SELECT *, investments.longitude, investments.state FROM finance.customers JOIN finance.investments ON customers.investment_id = investments.id LIMIT 20;


[User] Display all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Can you order these by card_type descending?

[Assistant] SELECT * FROM finance.payments ORDER BY card_type DESC;

[User] Show me the count of payments grouped by total.

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


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Can you order these by investment_id descending?

[Assistant] SELECT * FROM finance.customers ORDER BY investment_id DESC;

[User] Can you order these by last_login descending?

[Assistant] SELECT * FROM finance.customers ORDER BY last_login DESC;


[User] Get all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Get max of card_type by account_id from payments.

[Assistant] SELECT account_id, MAX(card_type) AS max_card_type FROM finance.payments GROUP BY account_id;


[User] Get all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Limit the results to 5 rows.

[Assistant] SELECT * FROM finance.customers WHERE last_login > '2023-12-01' LIMIT 5;


[User] Show me investment_id, email, last_name for all customers.

[Assistant] SELECT investment_id, email, last_name FROM finance.customers;

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

[Assistant] SELECT investment_id, email, last_name FROM finance.customers ORDER BY city DESC;

[User] How many customers are there per investment_id?

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


[User] Get investment_id, last_login, joined_at from all customers.

[Assistant] SELECT investment_id, last_login, joined_at FROM finance.customers;

[User] List customers that have email LIKE 'A%'.

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

[User] Show me min of phone grouped by email for customers.

[Assistant] SELECT email, MIN(phone) AS min_phone FROM finance.customers GROUP BY email;


[User] Display all audits.

[Assistant] SELECT * FROM finance.audits;

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

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

[User] Can you order these by created_at descending?

[Assistant] SELECT * FROM finance.audits WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY created_at DESC;


[User] What are the total, card_type, account_id of each payment?

[Assistant] SELECT total, card_type, account_id FROM finance.payments;

[User] Get payments that match card_type LIKE 'A%'.

[Assistant] SELECT total, card_type, account_id FROM finance.payments WHERE card_type LIKE 'A%';

[User] Show me the count of payments grouped by account_id.

[Assistant] SELECT account_id, COUNT(*) AS count FROM finance.payments GROUP BY account_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 healthcare.billing (
  account_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at timestamp without time zone,
  user_id text NOT NULL,
  debit character varying(256),
  amount integer,
  customer_id varchar,
  status char
)

CREATE TABLE healthcare.departments (
  post_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  attachment_url text,
  author_id text,
  message character varying(256)
)

CREATE TABLE healthcare.prescriptions (
  comment_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp without time zone,
  rating character varying(256),
  user_id varchar,
  attachment_url char NOT NULL,
  parent_id char NOT NULL -- identifier for parent
)

[User] Get status, debit, created_at from all billing.

[Assistant] SELECT status, debit, created_at FROM healthcare.billing;

[User] Can you order these by customer_id ascending?

[Assistant] SELECT status, debit, created_at FROM healthcare.billing ORDER BY customer_id ASC;

[User] Get the distribution of billing across different customer_id values.

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


[User] Retrieve author_id, message, updated_at for every department.

[Assistant] SELECT author_id, message, updated_at FROM healthcare.departments;

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

[Assistant] SELECT author_id, message, updated_at FROM healthcare.departments WHERE updated_at > '2023-01-01';

[User] Only show the top 20 results.

[Assistant] SELECT author_id, message, updated_at FROM healthcare.departments WHERE updated_at > '2023-01-01' LIMIT 20;


[User] List all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

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

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


[User] Get amount, status, debit from all billing.

[Assistant] SELECT amount, status, debit FROM healthcare.billing;

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

[Assistant] SELECT amount, status, debit FROM healthcare.billing WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Only show the top 10 results.

[Assistant] SELECT amount, status, debit FROM healthcare.billing WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 10;


[User] Display all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

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

[Assistant] SELECT * FROM healthcare.prescriptions ORDER BY published_at DESC;

[User] Calculate count of published_at for each published_at in prescriptions.

[Assistant] SELECT published_at, COUNT(published_at) AS count_published_at FROM healthcare.prescriptions GROUP BY published_at;


[User] What are the message, updated_at, author_id of each department?

[Assistant] SELECT message, updated_at, author_id FROM healthcare.departments;

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

[Assistant] SELECT message, updated_at, author_id FROM healthcare.departments WHERE updated_at > '2023-12-01';

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

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


[User] Get user_id, updated_at, created_at from all billing.

[Assistant] SELECT user_id, updated_at, created_at FROM healthcare.billing;

[User] Find billing where user_id LIKE 'A%'.

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

[User] Group billing by amount and show the sum of status.

[Assistant] SELECT amount, SUM(status) AS sum_status FROM healthcare.billing GROUP BY amount;


[User] List all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Show me prescriptions with attachment_url LIKE 'A%'.

[Assistant] SELECT * FROM healthcare.prescriptions WHERE attachment_url LIKE 'A%';

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM healthcare.prescriptions WHERE attachment_url LIKE 'A%' LIMIT 10;


[User] Get all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Can you order these by status descending?

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

[User] Get the distribution of billing across different debit values.

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


[User] List user_id, parent_id, attachment_url from prescriptions.

[Assistant] SELECT user_id, parent_id, attachment_url FROM healthcare.prescriptions;

[User] Get prescriptions that match comment_id LIKE 'A%'.

[Assistant] SELECT user_id, parent_id, attachment_url FROM healthcare.prescriptions WHERE comment_id LIKE 'A%';

[User] Tally up prescriptions by comment_id.

[Assistant] SELECT comment_id, COUNT(*) AS count FROM healthcare.prescriptions GROUP BY comment_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 finance.payments (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  traded_at date,
  subtotal integer NOT NULL,
  customer_id character varying(64) -- identifier for customer,
  approval_status varchar,
  loan_id text -- reference to loans.order_id,
  FOREIGN KEY (loan_id) REFERENCES loans(order_id)
)

CREATE TABLE finance.transactions (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  tax bigint NOT NULL,
  product_id character varying(256) -- identifier for product,
  approval_status character varying(256),
  customer_id text NOT NULL -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

CREATE TABLE finance.investments (
  store_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  last_inspected date,
  location_lon varchar NOT NULL,
  name text,
  latitude character varying(64),
  accessibility char
)

CREATE TABLE finance.loans (
  order_id varchar PRIMARY KEY -- unique identifier,
  traded_at timestamp,
  updated_at date,
  card_type text NOT NULL,
  quantity character varying(64),
  status text,
  customer_id char,
  delivery_status text
)

CREATE TABLE finance.customers (
  employee_id text PRIMARY KEY -- unique identifier,
  created_at date,
  api_key character varying(128),
  birth_date date,
  website character varying(256),
  status char,
  last_name varchar NOT NULL,
  country text
)

[User] List all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Can you order these by subtotal ascending?

[Assistant] SELECT * FROM finance.payments WHERE traded_at > '2023-12-01' ORDER BY subtotal ASC;


[User] Show me all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Retrieve transactions where invoice_id LIKE 'A%'.

[Assistant] SELECT * FROM finance.transactions WHERE invoice_id LIKE 'A%';

[User] Can you order these by created_at ascending?

[Assistant] SELECT * FROM finance.transactions WHERE invoice_id LIKE 'A%' ORDER BY created_at ASC;


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Order the output by product_id ascending.

[Assistant] SELECT * FROM finance.transactions ORDER BY product_id ASC;

[User] Limit the results to 20 rows.

[Assistant] SELECT * FROM finance.transactions ORDER BY product_id ASC LIMIT 20;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.customers (
  customer_id integer PRIMARY KEY -- unique identifier,
  joined_at date,
  updated_at date,
  salt varchar NOT NULL,
  account_status character varying(256),
  city varchar NOT NULL,
  last_login timestamp NOT NULL
)

CREATE TABLE finance.transactions (
  payment_id character varying(64) NOT NULL -- unique identifier,
  processed_at date,
  status char,
  payment_status varchar,
  customer_id integer NOT NULL -- reference to customers.customer_id,
  FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
)

[User] Retrieve all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Find transactions where customer_id > 79.

[Assistant] SELECT * FROM finance.transactions WHERE customer_id > 79;

[User] Calculate min of processed_at for each payment_id in transactions.

[Assistant] SELECT payment_id, MIN(processed_at) AS min_processed_at FROM finance.transactions GROUP BY payment_id;


[User] Show me status, customer_id, payment_id for all transactions.

[Assistant] SELECT status, customer_id, payment_id FROM finance.transactions;

[User] Get customer_id, status, account_status, city by joining transactions with customers.

[Assistant] SELECT status, customer_id, payment_id, customers.account_status, customers.city FROM finance.transactions JOIN finance.customers ON transactions.customer_id = customers.customer_id;

[User] Tally up transactions by payment_status.

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


[User] Retrieve all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Find transactions created yesterday.

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

[User] Tally up transactions by payment_status.

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


[User] Display all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Get all transactions from 2023.

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

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

[Assistant] SELECT * FROM finance.transactions WHERE processed_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY payment_id ASC;


[User] Show me all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Sort the results by processed_at ascending.

[Assistant] SELECT * FROM finance.transactions ORDER BY processed_at ASC;

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

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


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Order the output by processed_at ascending.

[Assistant] SELECT * FROM finance.transactions ORDER BY processed_at ASC;

[User] Order the output by payment_id descending.

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


[User] List payment_id, processed_at, payment_status from transactions.

[Assistant] SELECT payment_id, processed_at, payment_status FROM finance.transactions;

[User] List transactions that have customer_id > 99.

[Assistant] SELECT payment_id, processed_at, payment_status FROM finance.transactions WHERE customer_id > 99;

[User] Group transactions by customer_id and show the max of status.

[Assistant] SELECT customer_id, MAX(status) AS max_status FROM finance.transactions GROUP BY customer_id;


[User] Show me status, customer_id, payment_status for all transactions.

[Assistant] SELECT status, customer_id, payment_status FROM finance.transactions;

[User] Find transactions modified within the last hour.

[Assistant] SELECT status, customer_id, payment_status FROM finance.transactions WHERE processed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Can you order these by customer_id descending?

[Assistant] SELECT status, customer_id, payment_status FROM finance.transactions WHERE processed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY customer_id DESC;


[User] Get customer_id, payment_id, payment_status from all transactions.

[Assistant] SELECT customer_id, payment_id, payment_status FROM finance.transactions;

[User] Show me customer_id, processed_at, joined_at, updated_at from transactions and their related customers.

[Assistant] SELECT customer_id, payment_id, payment_status, customers.joined_at, customers.updated_at FROM finance.transactions JOIN finance.customers ON transactions.customer_id = customers.customer_id;

[User] Show the results sorted by status descending.

[Assistant] SELECT customer_id, payment_id, payment_status, customers.joined_at, customers.updated_at FROM finance.transactions JOIN finance.customers ON transactions.customer_id = customers.customer_id ORDER BY status DESC;


[User] Display all transactions.

[Assistant] SELECT * FROM finance.transactions;

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

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

[User] Tally up transactions by payment_status.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.customers (
  customer_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  last_active date,
  username text,
  last_name varchar,
  last_login timestamp NOT NULL,
  first_name text,
  payment_id text NOT NULL -- reference to payments.transaction_id,
  FOREIGN KEY (payment_id) REFERENCES payments(transaction_id)
)

CREATE TABLE finance.audits (
  invoice_id integer PRIMARY KEY -- unique identifier,
  cancelled_at timestamp without time zone,
  total numeric(38,14),
  price bigint,
  payment_status character varying(256),
  exchange_rate character varying(256),
  customer_id char NOT NULL,
  subtotal numeric(38,14)
)

CREATE TABLE finance.payments (
  transaction_id text PRIMARY KEY -- unique identifier,
  completed_at date,
  cancelled_at timestamp,
  payment_status character varying(256) NOT NULL,
  discount numeric(38,14),
  delivery_status character varying(64) NOT NULL,
  customer_id text -- reference to customers.customer_id,
  audit_id integer -- reference to audits.invoice_id,
  FOREIGN KEY (customer_id) REFERENCES customers(customer_id),
  FOREIGN KEY (audit_id) REFERENCES audits(invoice_id)
)

[User] List discount, delivery_status, payment_status from payments.

[Assistant] SELECT discount, delivery_status, payment_status FROM finance.payments;

[User] Get all payments older than 6 months.

[Assistant] SELECT discount, delivery_status, payment_status FROM finance.payments WHERE cancelled_at <= CURRENT_DATE - INTERVAL '6 months';

[User] What is the sum audit_id for each payment_status in payments?

[Assistant] SELECT payment_status, SUM(audit_id) AS sum_audit_id FROM finance.payments GROUP BY payment_status;


[User] Show me last_active, last_name, first_name for all customers.

[Assistant] SELECT last_active, last_name, first_name FROM finance.customers;

[User] Order the output by payment_id descending.

[Assistant] SELECT last_active, last_name, first_name FROM finance.customers ORDER BY payment_id DESC;

[User] How many customers are there per first_name?

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


[User] Show me all customers.

[Assistant] SELECT * FROM finance.customers;

[User] What last_name, last_login, audit_id, cancelled_at do we have for customers and their associated payments?

[Assistant] SELECT *, payments.audit_id, payments.cancelled_at FROM finance.customers JOIN finance.payments ON customers.payment_id = payments.transaction_id;

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

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


[User] List completed_at, discount, cancelled_at from payments.

[Assistant] SELECT completed_at, discount, cancelled_at FROM finance.payments;

[User] Retrieve customer_id, payment_status, first_name, last_login showing the relationship between payments and customers.

[Assistant] SELECT completed_at, discount, cancelled_at, customers.first_name, customers.last_login FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.customer_id;

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

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


[User] What are the first_name, last_active, payment_id of each customer?

[Assistant] SELECT first_name, last_active, payment_id FROM finance.customers;

[User] Retrieve last_active, last_login, customer_id, delivery_status showing the relationship between customers and payments.

[Assistant] SELECT first_name, last_active, payment_id, payments.customer_id, payments.delivery_status FROM finance.customers JOIN finance.payments ON customers.payment_id = payments.transaction_id;

[User] Show only 5 records.

[Assistant] SELECT first_name, last_active, payment_id, payments.customer_id, payments.delivery_status FROM finance.customers JOIN finance.payments ON customers.payment_id = payments.transaction_id LIMIT 5;


[User] Get all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Retrieve payments where completed_at > '2023-01-01'.

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

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

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


[User] Get payment_status, discount, completed_at from all payments.

[Assistant] SELECT payment_status, discount, completed_at FROM finance.payments;

[User] Get customer_id, payment_status, username, last_active by joining payments with customers.

[Assistant] SELECT payment_status, discount, completed_at, customers.username, customers.last_active FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.customer_id;

[User] What is the sum completed_at for each customer_id in payments?

[Assistant] SELECT customer_id, SUM(completed_at) AS sum_completed_at FROM finance.payments GROUP BY customer_id;


[User] Get payment_status, audit_id, completed_at from all payments.

[Assistant] SELECT payment_status, audit_id, completed_at FROM finance.payments;

[User] Order the output by payment_status ascending.

[Assistant] SELECT payment_status, audit_id, completed_at FROM finance.payments ORDER BY payment_status ASC;

[User] Can you order these by payment_status descending?

[Assistant] SELECT payment_status, audit_id, completed_at FROM finance.payments ORDER BY payment_status DESC;


[User] Show me cancelled_at, payment_status, completed_at for all payments.

[Assistant] SELECT cancelled_at, payment_status, completed_at FROM finance.payments;

[User] Get payments that match discount > 16.

[Assistant] SELECT cancelled_at, payment_status, completed_at FROM finance.payments WHERE discount > 16;

[User] Can you order these by audit_id ascending?

[Assistant] SELECT cancelled_at, payment_status, completed_at FROM finance.payments WHERE discount > 16 ORDER BY audit_id ASC;


[User] Get all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Sort the results by discount ascending.

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

[User] Show me the count of payments grouped by completed_at.

[Assistant] SELECT completed_at, COUNT(*) AS count FROM finance.payments GROUP BY completed_at 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 finance.transactions (
  order_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  account_id character varying(64) -- identifier for account,
  currency character varying(64),
  customer_id varchar -- identifier for customer,
  card_type varchar
)

CREATE TABLE finance.customers (
  employee_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  updated_at timestamp without time zone,
  address char,
  website character varying(256),
  birth_date timestamp,
  transaction_id text NOT NULL -- reference to transactions.order_id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(order_id)
)

[User] Show me address, created_at, transaction_id for all customers.

[Assistant] SELECT address, created_at, transaction_id FROM finance.customers;

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

[Assistant] SELECT address, created_at, transaction_id FROM finance.customers ORDER BY employee_id DESC;

[User] Only show the top 25 results.

[Assistant] SELECT address, created_at, transaction_id FROM finance.customers ORDER BY employee_id DESC LIMIT 25;


[User] Retrieve transaction_id, created_at, website for every customer.

[Assistant] SELECT transaction_id, created_at, website FROM finance.customers;

[User] Find customers from last week.

[Assistant] SELECT transaction_id, created_at, website FROM finance.customers WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Show only 20 records.

[Assistant] SELECT transaction_id, created_at, website FROM finance.customers WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 20;


[User] Show me all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Can you order these by website descending?

[Assistant] SELECT * FROM finance.customers ORDER BY website DESC;

[User] Calculate count of created_at for each transaction_id in customers.

[Assistant] SELECT transaction_id, COUNT(created_at) AS count_created_at FROM finance.customers GROUP BY transaction_id;


[User] Show me updated_at, employee_id, transaction_id for all customers.

[Assistant] SELECT updated_at, employee_id, transaction_id FROM finance.customers;

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

[Assistant] SELECT updated_at, employee_id, transaction_id FROM finance.customers WHERE birth_date >= CURRENT_DATE - INTERVAL '30 days';

[User] Show the results sorted by employee_id ascending.

[Assistant] SELECT updated_at, employee_id, transaction_id FROM finance.customers WHERE birth_date >= CURRENT_DATE - INTERVAL '30 days' ORDER BY employee_id ASC;


[User] What are the address, employee_id, birth_date of each customer?

[Assistant] SELECT address, employee_id, birth_date FROM finance.customers;

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

[Assistant] SELECT address, employee_id, birth_date FROM finance.customers ORDER BY transaction_id DESC;

[User] Tally up customers by created_at.

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


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

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

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


[User] Get all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Sort the results by website descending.

[Assistant] SELECT * FROM finance.customers ORDER BY website DESC;

[User] Return just 25 rows.

[Assistant] SELECT * FROM finance.customers ORDER BY website DESC LIMIT 25;


[User] List all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Get max of employee_id by created_at from customers.

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


[User] Get all customers.

[Assistant] SELECT * FROM finance.customers;

[User] List birth_date, created_at, customer_id, card_type for each customer along with their transaction information.

[Assistant] SELECT *, transactions.customer_id, transactions.card_type FROM finance.customers JOIN finance.transactions ON customers.transaction_id = transactions.order_id;

[User] Order the output by employee_id descending.

[Assistant] SELECT *, transactions.customer_id, transactions.card_type FROM finance.customers JOIN finance.transactions ON customers.transaction_id = transactions.order_id ORDER BY employee_id DESC;