[User] Show me created_at, bio, nationality for all customers.

[Assistant] SELECT created_at, bio, nationality FROM finance.customers;

[User] List membership_level, created_at, parent_id, user_id for each customer along with their audit information.

[Assistant] SELECT created_at, bio, nationality, audits.parent_id, audits.user_id FROM finance.customers JOIN finance.audits ON customers.audit_id = audits.id;

[User] Only show the top 15 results.

[Assistant] SELECT created_at, bio, nationality, audits.parent_id, audits.user_id FROM finance.customers JOIN finance.audits ON customers.audit_id = audits.id LIMIT 15;


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 (
  id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  bio char NOT NULL,
  full_name character varying(128),
  nationality char,
  language text,
  membership_level character varying(64),
  audit_id text NOT NULL -- reference to audits.id,
  FOREIGN KEY (audit_id) REFERENCES audits(id)
)

CREATE TABLE finance.accounts (
  invoice_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  payment_date timestamp without time zone,
  amount smallint NOT NULL,
  user_id text -- identifier for user,
  reference_number char NOT NULL,
  audit_id text NOT NULL -- reference to audits.id,
  FOREIGN KEY (audit_id) REFERENCES audits(id)
)

CREATE TABLE finance.audits (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  user_id character varying(64),
  author_id character varying(128) -- identifier for author,
  parent_id varchar
)

[User] List all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

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

[Assistant] SELECT * FROM finance.customers WHERE created_at > '2023-12-01' ORDER BY audit_id DESC;


[User] Display all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

[Assistant] SELECT * FROM finance.accounts WHERE payment_date > '2023-01-01';

[User] Get min of audit_id by reference_number from accounts.

[Assistant] SELECT reference_number, MIN(audit_id) AS min_audit_id FROM finance.accounts GROUP BY reference_number;


[User] Get all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] What reference_number, processed_at, author_id, created_at do we have for accounts and their associated audits?

[Assistant] SELECT *, audits.author_id, audits.created_at FROM finance.accounts JOIN finance.audits ON accounts.audit_id = audits.id;

[User] Calculate count of payment_date for each user_id in accounts.

[Assistant] SELECT user_id, COUNT(payment_date) AS count_payment_date FROM finance.accounts GROUP BY user_id;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

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

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


[User] Retrieve audit_id, payment_date, reference_number for every account.

[Assistant] SELECT audit_id, payment_date, reference_number FROM finance.accounts;

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

[Assistant] SELECT audit_id, payment_date, reference_number FROM finance.accounts WHERE payment_date > '2023-01-01';

[User] Group accounts by amount and show the count of user_id.

[Assistant] SELECT amount, COUNT(user_id) AS count_user_id FROM finance.accounts GROUP BY amount;


[User] List user_id, audit_id, amount from accounts.

[Assistant] SELECT user_id, audit_id, amount FROM finance.accounts;

[User] Get accounts that match audit_id LIKE 'A%'.

[Assistant] SELECT user_id, audit_id, amount FROM finance.accounts WHERE audit_id LIKE 'A%';

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

[Assistant] SELECT user_id, audit_id, amount FROM finance.accounts WHERE audit_id LIKE 'A%' ORDER BY user_id ASC;


[User] Get audit_id, membership_level, full_name from all customers.

[Assistant] SELECT audit_id, membership_level, full_name FROM finance.customers;

[User] Sort the results by language descending.

[Assistant] SELECT audit_id, membership_level, full_name FROM finance.customers ORDER BY language DESC;

[User] Calculate max of nationality for each audit_id in customers.

[Assistant] SELECT audit_id, MAX(nationality) AS max_nationality FROM finance.customers GROUP BY audit_id;


[User] Retrieve id, membership_level, full_name for every customer.

[Assistant] SELECT id, membership_level, full_name FROM finance.customers;

[User] What nationality, bio, user_id, created_at do we have for customers and their associated audits?

[Assistant] SELECT id, membership_level, full_name, audits.user_id, audits.created_at FROM finance.customers JOIN finance.audits ON customers.audit_id = audits.id;

[User] Calculate min of membership_level for each created_at in customers.

[Assistant] SELECT created_at, MIN(membership_level) AS min_membership_level FROM finance.customers GROUP BY created_at;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE humanresources.items (
  item_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  published_at date,
  popularity_score character varying(64),
  manufacturer varchar,
  msrp varchar,
  reserved character varying(256),
  description char,
  subcategory character varying(128),
  customer_id integer NOT NULL -- reference to customers.customer_id,
  FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
)

CREATE TABLE humanresources.customers (
  customer_id integer PRIMARY KEY -- unique identifier,
  last_active timestamp,
  joined_at date,
  birth_date timestamp,
  email character varying(64),
  avatar character varying(128),
  is_active boolean
)

[User] What are the reserved, msrp, customer_id of each item?

[Assistant] SELECT reserved, msrp, customer_id FROM humanresources.items;

[User] Show me items with description LIKE 'A%'.

[Assistant] SELECT reserved, msrp, customer_id FROM humanresources.items WHERE description LIKE 'A%';

[User] Can you order these by published_at ascending?

[Assistant] SELECT reserved, msrp, customer_id FROM humanresources.items WHERE description LIKE 'A%' ORDER BY published_at ASC;


[User] Show me all items.

[Assistant] SELECT * FROM humanresources.items;

[User] Get items that match subcategory LIKE 'A%'.

[Assistant] SELECT * FROM humanresources.items WHERE subcategory LIKE 'A%';

[User] Show me the count of items grouped by popularity_score.

[Assistant] SELECT popularity_score, COUNT(*) AS count FROM humanresources.items GROUP BY popularity_score ORDER BY count DESC;


[User] Display all items.

[Assistant] SELECT * FROM humanresources.items;

[User] Show me items with description LIKE 'A%'.

[Assistant] SELECT * FROM humanresources.items WHERE description LIKE 'A%';

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM humanresources.items WHERE description LIKE 'A%' LIMIT 10;


[User] Show me all items.

[Assistant] SELECT * FROM humanresources.items;

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

[Assistant] SELECT * FROM humanresources.items WHERE updated_at > '2023-12-01';

[User] How many items are there per customer_id?

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


[User] What are the reserved, manufacturer, published_at of each item?

[Assistant] SELECT reserved, manufacturer, published_at FROM humanresources.items;

[User] Find items where msrp LIKE 'A%'.

[Assistant] SELECT reserved, manufacturer, published_at FROM humanresources.items WHERE msrp LIKE 'A%';

[User] Get average of published_at by msrp from items.

[Assistant] SELECT msrp, AVERAGE(published_at) AS average_published_at FROM humanresources.items GROUP BY msrp;


[User] List all items.

[Assistant] SELECT * FROM humanresources.items;

[User] Retrieve updated_at, msrp, birth_date, is_active showing the relationship between items and customers.

[Assistant] SELECT *, customers.birth_date, customers.is_active FROM humanresources.items JOIN humanresources.customers ON items.customer_id = customers.customer_id;

[User] Show me the count of items grouped by popularity_score.

[Assistant] SELECT popularity_score, COUNT(*) AS count FROM humanresources.items GROUP BY popularity_score ORDER BY count DESC;


[User] List description, msrp, reserved from items.

[Assistant] SELECT description, msrp, reserved FROM humanresources.items;

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

[Assistant] SELECT description, msrp, reserved FROM humanresources.items WHERE published_at >= CURRENT_DATE - INTERVAL '30 days';

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

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


[User] List all items.

[Assistant] SELECT * FROM humanresources.items;

[User] Show me customer_id, updated_at, last_active, email from items and their related customers.

[Assistant] SELECT *, customers.last_active, customers.email FROM humanresources.items JOIN humanresources.customers ON items.customer_id = customers.customer_id;

[User] Limit the results to 100 rows.

[Assistant] SELECT *, customers.last_active, customers.email FROM humanresources.items JOIN humanresources.customers ON items.customer_id = customers.customer_id LIMIT 100;


[User] Show me all items.

[Assistant] SELECT * FROM humanresources.items;

[User] Show me customer_id, subcategory, joined_at, is_active from items and their related customers.

[Assistant] SELECT *, customers.joined_at, customers.is_active FROM humanresources.items JOIN humanresources.customers ON items.customer_id = customers.customer_id;

[User] Order the output by customer_id ascending.

[Assistant] SELECT *, customers.joined_at, customers.is_active FROM humanresources.items JOIN humanresources.customers ON items.customer_id = customers.customer_id ORDER BY customer_id ASC;


[User] Retrieve subcategory, customer_id, popularity_score for every item.

[Assistant] SELECT subcategory, customer_id, popularity_score FROM humanresources.items;

[User] List items that have manufacturer LIKE 'A%'.

[Assistant] SELECT subcategory, customer_id, popularity_score FROM humanresources.items WHERE manufacturer LIKE 'A%';

[User] Sort the results by msrp descending.

[Assistant] SELECT subcategory, customer_id, popularity_score FROM humanresources.items WHERE manufacturer LIKE 'A%' ORDER BY msrp 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 (
  customer_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  account_status character varying(128),
  country text,
  zip_code text,
  doctor_id text -- reference to doctors.transaction_id,
  FOREIGN KEY (doctor_id) REFERENCES doctors(transaction_id)
)

CREATE TABLE healthcare.doctors (
  transaction_id text PRIMARY KEY -- unique identifier,
  processed_at date,
  updated_at date,
  exchange_rate text,
  status character varying(128) NOT NULL,
  amount bigint,
  price numeric NOT NULL
)

[User] What are the country, account_status, zip_code of each medical_record?

[Assistant] SELECT country, account_status, zip_code FROM healthcare.medical_records;

[User] Order the output by zip_code ascending.

[Assistant] SELECT country, account_status, zip_code FROM healthcare.medical_records ORDER BY zip_code ASC;

[User] Count the number of medical_records in each doctor_id category.

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


[User] Show me all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

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

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

[User] Show the results sorted by account_status ascending.

[Assistant] SELECT * FROM healthcare.medical_records WHERE account_status LIKE 'A%' ORDER BY account_status ASC;


[User] Retrieve all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

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

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

[User] What is the min account_status for each country in medical_records?

[Assistant] SELECT country, MIN(account_status) AS min_account_status FROM healthcare.medical_records GROUP BY country;


[User] Show me country, doctor_id, customer_id for all medical_records.

[Assistant] SELECT country, doctor_id, customer_id FROM healthcare.medical_records;

[User] Sort the results by customer_id ascending.

[Assistant] SELECT country, doctor_id, customer_id FROM healthcare.medical_records ORDER BY customer_id ASC;

[User] Can you order these by customer_id ascending?

[Assistant] SELECT country, doctor_id, customer_id FROM healthcare.medical_records ORDER BY customer_id ASC;


[User] Display all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] Retrieve created_at, customer_id, amount, processed_at showing the relationship between medical_records and doctors.

[Assistant] SELECT *, doctors.amount, doctors.processed_at FROM healthcare.medical_records JOIN healthcare.doctors ON medical_records.doctor_id = doctors.transaction_id;

[User] Count the number of medical_records in each customer_id category.

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


[User] Get customer_id, account_status, zip_code from all medical_records.

[Assistant] SELECT customer_id, account_status, zip_code FROM healthcare.medical_records;

[User] What customer_id, zip_code, price, amount do we have for medical_records and their associated doctors?

[Assistant] SELECT customer_id, account_status, zip_code, doctors.price, doctors.amount FROM healthcare.medical_records JOIN healthcare.doctors ON medical_records.doctor_id = doctors.transaction_id;

[User] What is the count created_at for each zip_code in medical_records?

[Assistant] SELECT zip_code, COUNT(created_at) AS count_created_at FROM healthcare.medical_records GROUP BY zip_code;


[User] List customer_id, account_status, country from medical_records.

[Assistant] SELECT customer_id, account_status, country FROM healthcare.medical_records;

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

[Assistant] SELECT customer_id, account_status, country FROM healthcare.medical_records WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Order the output by account_status descending.

[Assistant] SELECT customer_id, account_status, country FROM healthcare.medical_records WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY account_status DESC;


[User] Get all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] Get all medical_records from 2023.

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

[User] What is the max customer_id for each customer_id in medical_records?

[Assistant] SELECT customer_id, MAX(customer_id) AS max_customer_id FROM healthcare.medical_records GROUP BY customer_id;


[User] Retrieve account_status, customer_id, country for every medical_record.

[Assistant] SELECT account_status, customer_id, country FROM healthcare.medical_records;

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

[Assistant] SELECT account_status, customer_id, country FROM healthcare.medical_records WHERE created_at > '2023-12-01';

[User] Count the number of medical_records in each doctor_id category.

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


[User] Show me all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

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

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

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

[Assistant] SELECT created_at, COUNT(*) AS count FROM healthcare.medical_records GROUP BY created_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.customers (
  employee_id character varying(64) NOT NULL -- unique identifier,
  joined_at date,
  updated_at timestamp,
  nationality character varying(64),
  language text,
  membership_level text,
  state character varying(128),
  last_name char NOT NULL,
  investment_id text NOT NULL -- reference to investments.payment_id,
  FOREIGN KEY (investment_id) REFERENCES investments(payment_id)
)

CREATE TABLE finance.investments (
  payment_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  updated_at timestamp,
  exchange_rate character varying(128) NOT NULL,
  price decimal,
  account_id character varying(64) NOT NULL -- identifier for account,
  quantity character varying(128),
  customer_id text NOT NULL -- identifier for customer,
  status character varying(64)
)

[User] List all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Order the output by employee_id descending.

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

[User] Tally up customers by state.

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


[User] Get membership_level, joined_at, employee_id from all customers.

[Assistant] SELECT membership_level, joined_at, employee_id FROM finance.customers;

[User] Can you order these by joined_at descending?

[Assistant] SELECT membership_level, joined_at, employee_id FROM finance.customers ORDER BY joined_at DESC;

[User] Return just 15 rows.

[Assistant] SELECT membership_level, joined_at, employee_id FROM finance.customers ORDER BY joined_at DESC LIMIT 15;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Calculate sum of last_name for each employee_id in customers.

[Assistant] SELECT employee_id, SUM(last_name) AS sum_last_name FROM finance.customers GROUP BY employee_id;


[User] Show me nationality, last_name, state for all customers.

[Assistant] SELECT nationality, last_name, state FROM finance.customers;

[User] Get investment_id, last_name, updated_at, account_id by joining customers with investments.

[Assistant] SELECT nationality, last_name, state, investments.updated_at, investments.account_id FROM finance.customers JOIN finance.investments ON customers.investment_id = investments.payment_id;

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

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


[User] Get nationality, membership_level, joined_at from all customers.

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

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

[Assistant] SELECT nationality, membership_level, joined_at FROM finance.customers WHERE joined_at > '2023-12-01';

[User] What is the max language for each last_name in customers?

[Assistant] SELECT last_name, MAX(language) AS max_language FROM finance.customers GROUP BY last_name;


[User] Retrieve all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Get nationality, joined_at, exchange_rate, account_id by joining customers with investments.

[Assistant] SELECT *, investments.exchange_rate, investments.account_id FROM finance.customers JOIN finance.investments ON customers.investment_id = investments.payment_id;

[User] Calculate max of language for each joined_at in customers.

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


[User] Retrieve all customers.

[Assistant] SELECT * FROM finance.customers;

[User] List membership_level, updated_at, account_id, exchange_rate for each customer along with their investment information.

[Assistant] SELECT *, investments.account_id, investments.exchange_rate FROM finance.customers JOIN finance.investments ON customers.investment_id = investments.payment_id;

[User] Tally up customers by joined_at.

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


[User] Show me all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

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

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


[User] Retrieve all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Order the output by language descending.

[Assistant] SELECT * FROM finance.customers WHERE joined_at > '2023-12-01' ORDER BY language DESC;


[User] What are the updated_at, investment_id, language of each customer?

[Assistant] SELECT updated_at, investment_id, language FROM finance.customers;

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

[Assistant] SELECT updated_at, investment_id, language FROM finance.customers WHERE language LIKE 'A%';

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

[Assistant] SELECT employee_id, COUNT(*) AS count FROM finance.customers GROUP BY employee_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 tradingplatform.assets (
  product_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at date,
  featured_rank text,
  image_url char,
  popularity_score char,
  msrp character varying(256),
  backorder char,
  video_url text,
  log_id text -- reference to logs.location_id,
  FOREIGN KEY (log_id) REFERENCES logs(location_id)
)

CREATE TABLE tradingplatform.users (
  customer_id text PRIMARY KEY -- unique identifier,
  joined_at date,
  last_name character varying(256) NOT NULL,
  bio character varying(128) NOT NULL,
  timezone char,
  nationality text,
  city varchar,
  country character varying(64),
  website char NOT NULL,
  asset_id text NOT NULL -- reference to assets.product_id,
  log_id text NOT NULL -- reference to logs.location_id,
  FOREIGN KEY (asset_id) REFERENCES assets(product_id),
  FOREIGN KEY (log_id) REFERENCES logs(location_id)
)

CREATE TABLE tradingplatform.logs (
  location_id varchar PRIMARY KEY -- unique identifier,
  last_inspected timestamp without time zone,
  created_at date,
  country varchar,
  address_line1 character varying(128),
  geo_point varchar,
  operating_hours text,
  user_id text NOT NULL -- reference to users.customer_id,
  FOREIGN KEY (user_id) REFERENCES users(customer_id)
)

[User] List timezone, asset_id, website from users.

[Assistant] SELECT timezone, asset_id, website FROM tradingplatform.users;

[User] Show me users with log_id LIKE 'A%'.

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

[User] Get average of last_name by city from users.

[Assistant] SELECT city, AVERAGE(last_name) AS average_last_name FROM tradingplatform.users GROUP BY city;


[User] Retrieve all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Show me logs that were from 2023.

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

[User] Can you order these by created_at descending?

[Assistant] SELECT * FROM tradingplatform.logs WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY created_at DESC;


[User] Get bio, country, asset_id from all users.

[Assistant] SELECT bio, country, asset_id FROM tradingplatform.users;

[User] Retrieve users where the date is older than 6 months.

[Assistant] SELECT bio, country, asset_id FROM tradingplatform.users WHERE joined_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Calculate sum of country for each asset_id in users.

[Assistant] SELECT asset_id, SUM(country) AS sum_country FROM tradingplatform.users GROUP BY asset_id;


[User] Display all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

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

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

[User] Only show the top 15 results.

[Assistant] SELECT * FROM tradingplatform.logs WHERE created_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 15;


[User] List all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] List image_url, featured_rank, created_at, geo_point for each asset along with their log information.

[Assistant] SELECT *, logs.created_at, logs.geo_point FROM tradingplatform.assets JOIN tradingplatform.logs ON assets.log_id = logs.location_id;

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

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


[User] Retrieve all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Sort the results by address_line1 ascending.

[Assistant] SELECT * FROM tradingplatform.logs ORDER BY address_line1 ASC;

[User] Only show the top 100 results.

[Assistant] SELECT * FROM tradingplatform.logs ORDER BY address_line1 ASC LIMIT 100;


[User] List city, asset_id, timezone from users.

[Assistant] SELECT city, asset_id, timezone FROM tradingplatform.users;

[User] List users with dates created yesterday.

[Assistant] SELECT city, asset_id, timezone FROM tradingplatform.users WHERE joined_at = CURRENT_DATE - INTERVAL '1 day';

[User] What is the sum log_id for each bio in users?

[Assistant] SELECT bio, SUM(log_id) AS sum_log_id FROM tradingplatform.users GROUP BY bio;


[User] Get all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Find logs between January and March.

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

[User] Get the distribution of logs across different address_line1 values.

[Assistant] SELECT address_line1, COUNT(*) AS count FROM tradingplatform.logs GROUP BY address_line1 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 (
  payment_id varchar PRIMARY KEY -- unique identifier,
  traded_at timestamp,
  delivery_status character varying(256),
  approval_status char,
  discount decimal,
  quantity varchar,
  customer_id character varying(128) NOT NULL
)

CREATE TABLE e-commerce.users (
  employee_id varchar PRIMARY KEY -- unique identifier,
  last_active date,
  updated_at timestamp without time zone,
  language character varying(128),
  status character varying(256)
)

CREATE TABLE e-commerce.products (
  id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp,
  expires_at timestamp,
  image_url varchar,
  discount decimal,
  reserved varchar,
  user_id text NOT NULL -- reference to users.employee_id,
  order_id text -- reference to orders.payment_id,
  FOREIGN KEY (user_id) REFERENCES users(employee_id),
  FOREIGN KEY (order_id) REFERENCES orders(payment_id)
)

CREATE TABLE e-commerce.shipping (
  store_id character varying(64) NOT NULL -- unique identifier,
  last_inspected date,
  created_at date,
  street character varying(128),
  postal_code character varying(128),
  operating_hours character varying(256),
  order_id text -- reference to orders.payment_id,
  FOREIGN KEY (order_id) REFERENCES orders(payment_id)
)

[User] Display all products.

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

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

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

[User] Restrict the output to 15 items.

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


[User] Show me all products.

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

[User] Sort the results by order_id descending.

[Assistant] SELECT * FROM e-commerce.products ORDER BY order_id DESC;

[User] Tally up products by image_url.

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


[User] Display all shipping.

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

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

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

[User] Show the results sorted by street ascending.

[Assistant] SELECT * FROM e-commerce.shipping WHERE last_inspected = CURRENT_DATE - INTERVAL '1 day' ORDER BY street ASC;


[User] Get all shipping.

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

[User] Retrieve shipping where operating_hours LIKE 'A%'.

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

[User] What is the average store_id for each postal_code in shipping?

[Assistant] SELECT postal_code, AVERAGE(store_id) AS average_store_id FROM e-commerce.shipping GROUP BY postal_code;


[User] Retrieve all shipping.

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

[User] List store_id, postal_code, traded_at, quantity for each shipping along with their order information.

[Assistant] SELECT *, orders.traded_at, orders.quantity FROM e-commerce.shipping JOIN e-commerce.orders ON shipping.order_id = orders.payment_id;

[User] Show only 5 records.

[Assistant] SELECT *, orders.traded_at, orders.quantity FROM e-commerce.shipping JOIN e-commerce.orders ON shipping.order_id = orders.payment_id LIMIT 5;


[User] List image_url, published_at, expires_at from products.

[Assistant] SELECT image_url, published_at, expires_at FROM e-commerce.products;

[User] Get all products from last week.

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

[User] Can you order these by user_id ascending?

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


[User] Show me id, discount, published_at for all products.

[Assistant] SELECT id, discount, published_at FROM e-commerce.products;

[User] Retrieve products where expires_at > '2023-01-01'.

[Assistant] SELECT id, discount, published_at FROM e-commerce.products WHERE expires_at > '2023-01-01';

[User] How many products are there per reserved?

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


[User] Get postal_code, store_id, street from all shipping.

[Assistant] SELECT postal_code, store_id, street FROM e-commerce.shipping;

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

[Assistant] SELECT postal_code, store_id, street FROM e-commerce.shipping WHERE order_id LIKE 'A%';

[User] Restrict the output to 15 items.

[Assistant] SELECT postal_code, store_id, street FROM e-commerce.shipping WHERE order_id LIKE 'A%' LIMIT 15;


[User] Get all shipping.

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

[User] Show me shipping with store_id LIKE 'A%'.

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

[User] Can you order these by postal_code descending?

[Assistant] SELECT * FROM e-commerce.shipping WHERE store_id LIKE 'A%' ORDER BY postal_code DESC;


[User] Show me all products.

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

[User] Retrieve products where reserved LIKE 'A%'.

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

[User] Calculate min of reserved for each image_url in products.

[Assistant] SELECT image_url, MIN(reserved) AS min_reserved FROM e-commerce.products GROUP BY image_url;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.students (
  person_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at timestamp,
  timezone character varying(64),
  account_status varchar,
  is_active boolean,
  country text NOT NULL,
  language char NOT NULL,
  course_id text NOT NULL -- reference to courses.address_id,
  FOREIGN KEY (course_id) REFERENCES courses(address_id)
)

CREATE TABLE education.departments (
  store_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at timestamp without time zone,
  operating_hours character varying(256) NOT NULL,
  type char,
  capacity char,
  latitude character varying(64) NOT NULL,
  student_id integer NOT NULL -- reference to students.person_id,
  FOREIGN KEY (student_id) REFERENCES students(person_id)
)

CREATE TABLE education.teachers (
  comment_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  edited_at timestamp without time zone,
  author_id varchar,
  text text NOT NULL,
  subject varchar,
  body character varying(128) NOT NULL,
  media_url char NOT NULL
)

CREATE TABLE education.courses (
  address_id text PRIMARY KEY -- unique identifier,
  last_inspected date,
  coordinates text NOT NULL,
  country char,
  capacity varchar
)

[User] Display all students.

[Assistant] SELECT * FROM education.students;

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

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

[User] Tally up students by country.

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


[User] Get all departments.

[Assistant] SELECT * FROM education.departments;

[User] Find departments where student_id > 55.

[Assistant] SELECT * FROM education.departments WHERE student_id > 55;

[User] Show me min of latitude grouped by capacity for departments.

[Assistant] SELECT capacity, MIN(latitude) AS min_latitude FROM education.departments GROUP BY capacity;


[User] Display all students.

[Assistant] SELECT * FROM education.students;

[User] Find students from last week.

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

[User] Can you order these by country descending?

[Assistant] SELECT * FROM education.students WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY country DESC;


[User] Retrieve all students.

[Assistant] SELECT * FROM education.students;

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

[Assistant] SELECT * FROM education.students WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Get max of country by updated_at from students.

[Assistant] SELECT updated_at, MAX(country) AS max_country FROM education.students GROUP BY updated_at;


[User] Display all students.

[Assistant] SELECT * FROM education.students;

[User] Find students where is_active = TRUE.

[Assistant] SELECT * FROM education.students WHERE is_active = TRUE;

[User] Calculate sum of updated_at for each country in students.

[Assistant] SELECT country, SUM(updated_at) AS sum_updated_at FROM education.students GROUP BY country;


[User] Show me capacity, type, latitude for all departments.

[Assistant] SELECT capacity, type, latitude FROM education.departments;

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

[Assistant] SELECT capacity, type, latitude FROM education.departments WHERE created_at > '2023-01-01';

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

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


[User] What are the operating_hours, latitude, created_at of each department?

[Assistant] SELECT operating_hours, latitude, created_at FROM education.departments;

[User] Show the results sorted by updated_at descending.

[Assistant] SELECT operating_hours, latitude, created_at FROM education.departments ORDER BY updated_at DESC;

[User] Restrict the output to 100 items.

[Assistant] SELECT operating_hours, latitude, created_at FROM education.departments ORDER BY updated_at DESC LIMIT 100;


[User] Show me capacity, student_id, created_at for all departments.

[Assistant] SELECT capacity, student_id, created_at FROM education.departments;

[User] Can you order these by operating_hours descending?

[Assistant] SELECT capacity, student_id, created_at FROM education.departments ORDER BY operating_hours DESC;

[User] Can you order these by type ascending?

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


[User] Get latitude, updated_at, type from all departments.

[Assistant] SELECT latitude, updated_at, type FROM education.departments;

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

[Assistant] SELECT latitude, updated_at, type FROM education.departments WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

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

[Assistant] SELECT type, COUNT(type) AS count_type FROM education.departments GROUP BY type;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.accounts (
  id text PRIMARY KEY -- unique identifier,
  created_at date,
  verification_status character varying(64) NOT NULL,
  invoice_number char,
  notes character varying(64),
  exchange_rate varchar NOT NULL,
  description character varying(64),
  reconciliation_status character varying(64) NOT NULL,
  audit_id text -- reference to audits.transaction_id,
  FOREIGN KEY (audit_id) REFERENCES audits(transaction_id)
)

CREATE TABLE finance.audits (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  cancelled_at date,
  fee char,
  delivery_status char,
  currency character varying(64),
  account_id text -- reference to accounts.id,
  FOREIGN KEY (account_id) REFERENCES accounts(id)
)

[User] Retrieve all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Can you order these by fee descending?

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

[User] Return just 50 rows.

[Assistant] SELECT * FROM finance.audits ORDER BY fee DESC LIMIT 50;


[User] Get all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Can you order these by delivery_status ascending?

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

[User] Order the output by fee ascending.

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


[User] What are the fee, delivery_status, cancelled_at of each audit?

[Assistant] SELECT fee, delivery_status, cancelled_at FROM finance.audits;

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

[Assistant] SELECT fee, delivery_status, cancelled_at FROM finance.audits WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Can you order these by created_at ascending?

[Assistant] SELECT fee, delivery_status, cancelled_at FROM finance.audits WHERE created_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY created_at ASC;


[User] Get all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Find audits older than 6 months.

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

[User] Get max of cancelled_at by fee from audits.

[Assistant] SELECT fee, MAX(cancelled_at) AS max_cancelled_at FROM finance.audits GROUP BY fee;


[User] Display all audits.

[Assistant] SELECT * FROM finance.audits;

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

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

[User] Limit the results to 100 rows.

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


[User] List audit_id, reconciliation_status, created_at from accounts.

[Assistant] SELECT audit_id, reconciliation_status, created_at FROM finance.accounts;

[User] Get audit_id, created_at, currency, cancelled_at by joining accounts with audits.

[Assistant] SELECT audit_id, reconciliation_status, created_at, audits.currency, audits.cancelled_at FROM finance.accounts JOIN finance.audits ON accounts.audit_id = audits.transaction_id;

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

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


[User] What are the currency, created_at, account_id of each audit?

[Assistant] SELECT currency, created_at, account_id FROM finance.audits;

[User] Get audits that match created_at > '2023-01-01'.

[Assistant] SELECT currency, created_at, account_id FROM finance.audits WHERE created_at > '2023-01-01';

[User] Tally up audits by account_id.

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


[User] Show me all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

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

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

[Assistant] SELECT * FROM finance.accounts WHERE created_at > '2023-12-01' ORDER BY created_at ASC;


[User] Display all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

[Assistant] SELECT * FROM finance.accounts ORDER BY created_at DESC;

[User] Calculate count of invoice_number for each created_at in accounts.

[Assistant] SELECT created_at, COUNT(invoice_number) AS count_invoice_number FROM finance.accounts GROUP BY created_at;


[User] List all audits.

[Assistant] SELECT * FROM finance.audits;

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

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

[User] Return just 5 rows.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.departments (
  item_id varchar PRIMARY KEY -- unique identifier,
  expires_at date,
  published_at timestamp without time zone,
  quantity character varying(256),
  title character varying(128) NOT NULL,
  msrp varchar,
  video_url text -- identifier for video_url,
  popularity_score character varying(128) NOT NULL,
  prescription_id text NOT NULL -- reference to prescriptions.invoice_id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(invoice_id)
)

CREATE TABLE healthcare.patients (
  person_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  updated_at date,
  gender text,
  zip_code text,
  salt char,
  country char,
  department_id text -- reference to departments.item_id,
  prescription_id text NOT NULL -- reference to prescriptions.invoice_id,
  FOREIGN KEY (department_id) REFERENCES departments(item_id),
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(invoice_id)
)

CREATE TABLE healthcare.prescriptions (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  approval_status character varying(128) NOT NULL,
  account_id char -- identifier for account,
  card_type char,
  currency varchar NOT NULL,
  payment_method char
)

CREATE TABLE healthcare.billing (
  id text PRIMARY KEY -- unique identifier,
  created_at date,
  payer_id character varying(64),
  customer_id character varying(256),
  balance bigint
)

[User] Show me all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Order the output by country descending.

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

[User] Only show the top 5 results.

[Assistant] SELECT * FROM healthcare.patients ORDER BY country DESC LIMIT 5;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.patients (
  user_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  joined_at date,
  status varchar NOT NULL,
  first_name character varying(256),
  appointment_id text -- reference to appointments.content_id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(content_id)
)

CREATE TABLE healthcare.appointments (
  content_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  edited_at timestamp without time zone,
  shares char,
  tags character varying(256) NOT NULL,
  likes char NOT NULL,
  visibility char,
  description character varying(256) NOT NULL,
  text character varying(128),
  subject varchar NOT NULL,
  patient_id text NOT NULL -- reference to patients.user_id,
  FOREIGN KEY (patient_id) REFERENCES patients(user_id)
)

CREATE TABLE healthcare.departments (
  message_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  edited_at timestamp,
  reply_to_id character varying(128),
  format text,
  shares char,
  appointment_id text NOT NULL -- reference to appointments.content_id,
  patient_id text NOT NULL -- reference to patients.user_id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(content_id),
  FOREIGN KEY (patient_id) REFERENCES patients(user_id)
)

[User] Retrieve appointment_id, created_at, first_name for every patient.

[Assistant] SELECT appointment_id, created_at, first_name FROM healthcare.patients;

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

[Assistant] SELECT appointment_id, created_at, first_name FROM healthcare.patients WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Can you order these by first_name ascending?

[Assistant] SELECT appointment_id, created_at, first_name FROM healthcare.patients WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY first_name ASC;


[User] Get all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Get appointments that match shares LIKE 'A%'.

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

[User] How many appointments are there per edited_at?

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


[User] Show me all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Show the results sorted by appointment_id ascending.

[Assistant] SELECT * FROM healthcare.patients ORDER BY appointment_id ASC;

[User] Tally up patients by joined_at.

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


[User] List all patients.

[Assistant] SELECT * FROM healthcare.patients;

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

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

[User] Get min of joined_at by joined_at from patients.

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


[User] What are the updated_at, subject, tags of each appointment?

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

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

[Assistant] SELECT updated_at, subject, tags FROM healthcare.appointments WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Order the output by visibility descending.

[Assistant] SELECT updated_at, subject, tags FROM healthcare.appointments WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY visibility DESC;


[User] Retrieve all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Get tags, description, appointment_id, created_at by joining appointments with patients.

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

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

[Assistant] SELECT text, COUNT(*) AS count FROM healthcare.appointments GROUP BY text 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 (
  transaction_id text PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  completed_at timestamp,
  product_id varchar NOT NULL -- identifier for product,
  quantity character varying(64),
  exchange_rate varchar,
  payment_method character varying(256),
  subtotal bigint NOT NULL,
  account_id varchar
)

CREATE TABLE finance.accounts (
  id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  created_at date,
  reconciliation_status text,
  category character varying(128),
  currency varchar,
  credit char,
  payee_id varchar -- identifier for payee
)

CREATE TABLE finance.payments (
  id integer PRIMARY KEY -- unique identifier,
  cancelled_at date,
  exchange_rate text,
  amount integer,
  approval_status char,
  payment_status character varying(256) NOT NULL,
  status varchar,
  customer_id character varying(256),
  account_id text -- reference to accounts.id,
  FOREIGN KEY (account_id) REFERENCES accounts(id)
)

[User] What are the payment_status, approval_status, cancelled_at of each payment?

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

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

[Assistant] SELECT payment_status, approval_status, cancelled_at FROM finance.payments WHERE status LIKE 'A%';

[User] How many payments are there per exchange_rate?

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


[User] Get customer_id, payment_status, cancelled_at from all payments.

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

[User] Sort the results by account_id descending.

[Assistant] SELECT customer_id, payment_status, cancelled_at FROM finance.payments ORDER BY account_id DESC;

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

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


[User] Retrieve all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Get amount, status, currency, category by joining payments with accounts.

[Assistant] SELECT *, accounts.currency, accounts.category FROM finance.payments JOIN finance.accounts ON payments.account_id = accounts.id;

[User] Show the results sorted by payment_status descending.

[Assistant] SELECT *, accounts.currency, accounts.category FROM finance.payments JOIN finance.accounts ON payments.account_id = accounts.id ORDER BY payment_status DESC;


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

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

[User] Order the output by cancelled_at descending.

[Assistant] SELECT status, customer_id, exchange_rate FROM finance.payments ORDER BY cancelled_at DESC;

[User] Show the results sorted by cancelled_at ascending.

[Assistant] SELECT status, customer_id, exchange_rate FROM finance.payments ORDER BY cancelled_at ASC;


[User] Retrieve account_id, payment_status, status for every payment.

[Assistant] SELECT account_id, payment_status, status FROM finance.payments;

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

[Assistant] SELECT account_id, payment_status, status FROM finance.payments WHERE exchange_rate LIKE 'A%';

[User] Show only 50 records.

[Assistant] SELECT account_id, payment_status, status FROM finance.payments WHERE exchange_rate LIKE 'A%' LIMIT 50;


[User] Get all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

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

[Assistant] SELECT * FROM finance.payments WHERE cancelled_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY exchange_rate ASC;


[User] Retrieve all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Order the output by exchange_rate ascending.

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

[User] Calculate average of customer_id for each status in payments.

[Assistant] SELECT status, AVERAGE(customer_id) AS average_customer_id FROM finance.payments GROUP BY status;


[User] Get exchange_rate, payment_status, amount from all payments.

[Assistant] SELECT exchange_rate, payment_status, amount FROM finance.payments;

[User] Find payments created yesterday.

[Assistant] SELECT exchange_rate, payment_status, amount FROM finance.payments WHERE cancelled_at = CURRENT_DATE - INTERVAL '1 day';

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

[Assistant] SELECT exchange_rate, payment_status, amount FROM finance.payments WHERE cancelled_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY payment_status DESC;


[User] List exchange_rate, status, amount from payments.

[Assistant] SELECT exchange_rate, status, amount FROM finance.payments;

[User] Sort the results by approval_status descending.

[Assistant] SELECT exchange_rate, status, amount FROM finance.payments ORDER BY approval_status DESC;

[User] Tally up payments by payment_status.

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


[User] List all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Get amount, status, category, reconciliation_status by joining payments with accounts.

[Assistant] SELECT *, accounts.category, accounts.reconciliation_status FROM finance.payments JOIN finance.accounts ON payments.account_id = accounts.id;

[User] Return just 15 rows.

[Assistant] SELECT *, accounts.category, accounts.reconciliation_status FROM finance.payments JOIN finance.accounts ON payments.account_id = accounts.id LIMIT 15;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.patients (
  person_id text PRIMARY KEY -- unique identifier,
  last_active date,
  created_at date,
  website character varying(256),
  full_name varchar,
  last_name char,
  prescription_id text -- reference to prescriptions.account_id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(account_id)
)

CREATE TABLE healthcare.prescriptions (
  account_id text PRIMARY KEY -- unique identifier,
  due_date date,
  created_at date,
  customer_id character varying(128),
  verification_status char,
  reference_number varchar NOT NULL
)

[User] List all patients.

[Assistant] SELECT * FROM healthcare.patients;

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

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

[User] Tally up patients by full_name.

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


[User] Show me full_name, prescription_id, last_active for all patients.

[Assistant] SELECT full_name, prescription_id, last_active FROM healthcare.patients;

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

[Assistant] SELECT full_name, prescription_id, last_active FROM healthcare.patients WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] How many patients are there per created_at?

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


[User] Get all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Find patients where last_name LIKE 'A%'.

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

[User] Can you order these by last_name ascending?

[Assistant] SELECT * FROM healthcare.patients WHERE last_name LIKE 'A%' ORDER BY last_name ASC;


[User] Retrieve created_at, full_name, last_active for every patient.

[Assistant] SELECT created_at, full_name, last_active FROM healthcare.patients;

[User] Show me patients that were from 2023.

[Assistant] SELECT created_at, full_name, last_active FROM healthcare.patients WHERE last_active BETWEEN '2023-01-01' AND '2023-12-31';

[User] Return just 10 rows.

[Assistant] SELECT created_at, full_name, last_active FROM healthcare.patients WHERE last_active BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 10;


[User] List all patients.

[Assistant] SELECT * FROM healthcare.patients;

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

[Assistant] SELECT * FROM healthcare.patients ORDER BY last_active ASC;

[User] Only show the top 100 results.

[Assistant] SELECT * FROM healthcare.patients ORDER BY last_active ASC LIMIT 100;


[User] Get full_name, last_active, prescription_id from all patients.

[Assistant] SELECT full_name, last_active, prescription_id FROM healthcare.patients;

[User] Get patients that match last_name LIKE 'A%'.

[Assistant] SELECT full_name, last_active, prescription_id FROM healthcare.patients WHERE last_name LIKE 'A%';

[User] Sort the results by created_at descending.

[Assistant] SELECT full_name, last_active, prescription_id FROM healthcare.patients WHERE last_name LIKE 'A%' ORDER BY created_at DESC;


[User] Show me all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] List patients that have website LIKE 'A%'.

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

[User] Restrict the output to 15 items.

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


[User] What are the created_at, last_active, last_name of each patient?

[Assistant] SELECT created_at, last_active, last_name FROM healthcare.patients;

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

[Assistant] SELECT created_at, last_active, last_name FROM healthcare.patients WHERE last_active > '2023-01-01';

[User] Show only 50 records.

[Assistant] SELECT created_at, last_active, last_name FROM healthcare.patients WHERE last_active > '2023-01-01' LIMIT 50;


[User] Show me all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Order the output by last_active descending.

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

[User] Can you order these by last_active descending?

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


[User] Show me last_active, prescription_id, created_at for all patients.

[Assistant] SELECT last_active, prescription_id, created_at FROM healthcare.patients;

[User] What last_active, created_at, due_date, reference_number do we have for patients and their associated prescriptions?

[Assistant] SELECT last_active, prescription_id, created_at, prescriptions.due_date, prescriptions.reference_number FROM healthcare.patients JOIN healthcare.prescriptions ON patients.prescription_id = prescriptions.account_id;

[User] Sort the results by last_name descending.

[Assistant] SELECT last_active, prescription_id, created_at, prescriptions.due_date, prescriptions.reference_number FROM healthcare.patients JOIN healthcare.prescriptions ON patients.prescription_id = prescriptions.account_id ORDER BY last_name DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.comments (
  content_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  created_at date,
  author_id character varying(256),
  user_id varchar,
  parent_id varchar -- identifier for parent,
  rating character varying(64) NOT NULL,
  categories character varying(64),
  image_url varchar
)

CREATE TABLE socialmedia.messages (
  message_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  published_at date,
  tags character varying(64) NOT NULL,
  likes text,
  categories character varying(256),
  media_url character varying(128) NOT NULL,
  score character varying(64),
  user_id character varying(128) NOT NULL -- identifier for user
)

[User] Show me author_id, categories, rating for all comments.

[Assistant] SELECT author_id, categories, rating FROM socialmedia.comments;

[User] Retrieve comments where image_url LIKE 'A%'.

[Assistant] SELECT author_id, categories, rating FROM socialmedia.comments WHERE image_url LIKE 'A%';

[User] Limit the results to 100 rows.

[Assistant] SELECT author_id, categories, rating FROM socialmedia.comments WHERE image_url LIKE 'A%' LIMIT 100;


[User] Get all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Sort the results by rating ascending.

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

[User] Return just 5 rows.

[Assistant] SELECT * FROM socialmedia.comments ORDER BY rating ASC LIMIT 5;


[User] Display all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

[Assistant] SELECT * FROM socialmedia.comments WHERE updated_at > '2023-12-01';

[User] Count the number of comments in each parent_id category.

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


[User] Get updated_at, parent_id, categories from all comments.

[Assistant] SELECT updated_at, parent_id, categories FROM socialmedia.comments;

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

[Assistant] SELECT updated_at, parent_id, categories FROM socialmedia.comments WHERE categories LIKE 'A%';

[User] Group comments by rating and show the sum of image_url.

[Assistant] SELECT rating, SUM(image_url) AS sum_image_url FROM socialmedia.comments GROUP BY rating;


[User] Show me all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

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

[User] Calculate min of categories for each rating in comments.

[Assistant] SELECT rating, MIN(categories) AS min_categories FROM socialmedia.comments GROUP BY rating;


[User] Get all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

[Assistant] SELECT * FROM socialmedia.comments WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Show only 50 records.

[Assistant] SELECT * FROM socialmedia.comments WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 50;


[User] List categories, created_at, user_id from comments.

[Assistant] SELECT categories, created_at, user_id FROM socialmedia.comments;

[User] Can you order these by parent_id ascending?

[Assistant] SELECT categories, created_at, user_id FROM socialmedia.comments ORDER BY parent_id ASC;

[User] Show only 15 records.

[Assistant] SELECT categories, created_at, user_id FROM socialmedia.comments ORDER BY parent_id ASC LIMIT 15;


[User] Display all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Show the results sorted by content_id descending.

[Assistant] SELECT * FROM socialmedia.comments ORDER BY content_id DESC;

[User] Return just 20 rows.

[Assistant] SELECT * FROM socialmedia.comments ORDER BY content_id DESC LIMIT 20;


[User] Get rating, content_id, author_id from all comments.

[Assistant] SELECT rating, content_id, author_id FROM socialmedia.comments;

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

[Assistant] SELECT rating, content_id, author_id FROM socialmedia.comments ORDER BY author_id ASC;

[User] Restrict the output to 25 items.

[Assistant] SELECT rating, content_id, author_id FROM socialmedia.comments ORDER BY author_id ASC LIMIT 25;


[User] Retrieve all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Show me comments with image_url LIKE 'A%'.

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

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

[Assistant] SELECT updated_at, COUNT(*) AS count FROM socialmedia.comments GROUP BY updated_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 healthcare.appointments (
  transaction_id text PRIMARY KEY -- unique identifier,
  completed_at date,
  created_at date,
  payment_status character varying(256),
  approval_status varchar NOT NULL,
  currency text NOT NULL,
  doctor_id text NOT NULL -- reference to doctors.item_id,
  FOREIGN KEY (doctor_id) REFERENCES doctors(item_id)
)

CREATE TABLE healthcare.doctors (
  item_id varchar PRIMARY KEY -- unique identifier,
  expires_at timestamp without time zone,
  manufacturer character varying(128),
  image_url text NOT NULL,
  brand character varying(128) NOT NULL,
  name character varying(256) NOT NULL,
  appointment_id text -- reference to appointments.transaction_id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(transaction_id)
)

[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Get doctor_id, currency, brand, expires_at by joining appointments with doctors.

[Assistant] SELECT *, doctors.brand, doctors.expires_at FROM healthcare.appointments JOIN healthcare.doctors ON appointments.doctor_id = doctors.item_id;

[User] Show the results sorted by created_at descending.

[Assistant] SELECT *, doctors.brand, doctors.expires_at FROM healthcare.appointments JOIN healthcare.doctors ON appointments.doctor_id = doctors.item_id ORDER BY created_at DESC;


[User] List currency, doctor_id, payment_status from appointments.

[Assistant] SELECT currency, doctor_id, payment_status FROM healthcare.appointments;

[User] Get payment_status, currency, name, appointment_id by joining appointments with doctors.

[Assistant] SELECT currency, doctor_id, payment_status, doctors.name, doctors.appointment_id FROM healthcare.appointments JOIN healthcare.doctors ON appointments.doctor_id = doctors.item_id;

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

[Assistant] SELECT currency, doctor_id, payment_status, doctors.name, doctors.appointment_id FROM healthcare.appointments JOIN healthcare.doctors ON appointments.doctor_id = doctors.item_id ORDER BY doctor_id ASC;


[User] Show me image_url, expires_at, appointment_id for all doctors.

[Assistant] SELECT image_url, expires_at, appointment_id FROM healthcare.doctors;

[User] Find doctors created yesterday.

[Assistant] SELECT image_url, expires_at, appointment_id FROM healthcare.doctors WHERE expires_at = CURRENT_DATE - INTERVAL '1 day';

[User] Show me sum of appointment_id grouped by name for doctors.

[Assistant] SELECT name, SUM(appointment_id) AS sum_appointment_id FROM healthcare.doctors GROUP BY name;


[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Find appointments from 2023.

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

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

[Assistant] SELECT * FROM healthcare.appointments WHERE completed_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY currency DESC;


[User] What are the completed_at, payment_status, created_at of each appointment?

[Assistant] SELECT completed_at, payment_status, created_at FROM healthcare.appointments;

[User] Show me payment_status, approval_status, manufacturer, expires_at from appointments and their related doctors.

[Assistant] SELECT completed_at, payment_status, created_at, doctors.manufacturer, doctors.expires_at FROM healthcare.appointments JOIN healthcare.doctors ON appointments.doctor_id = doctors.item_id;

[User] Order the output by doctor_id ascending.

[Assistant] SELECT completed_at, payment_status, created_at, doctors.manufacturer, doctors.expires_at FROM healthcare.appointments JOIN healthcare.doctors ON appointments.doctor_id = doctors.item_id ORDER BY doctor_id ASC;


[User] Get all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

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

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

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

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


[User] Show me manufacturer, appointment_id, brand for all doctors.

[Assistant] SELECT manufacturer, appointment_id, brand FROM healthcare.doctors;

[User] Retrieve doctors where appointment_id LIKE 'A%'.

[Assistant] SELECT manufacturer, appointment_id, brand FROM healthcare.doctors WHERE appointment_id LIKE 'A%';

[User] What is the min appointment_id for each appointment_id in doctors?

[Assistant] SELECT appointment_id, MIN(appointment_id) AS min_appointment_id FROM healthcare.doctors GROUP BY appointment_id;


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Sort the results by expires_at ascending.

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

[User] Can you order these by image_url ascending?

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


[User] Retrieve all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

[Assistant] SELECT * FROM healthcare.doctors WHERE manufacturer LIKE 'A%';

[User] Group doctors by expires_at and show the count of image_url.

[Assistant] SELECT expires_at, COUNT(image_url) AS count_image_url FROM healthcare.doctors GROUP BY expires_at;


[User] Show me created_at, doctor_id, approval_status for all appointments.

[Assistant] SELECT created_at, doctor_id, approval_status FROM healthcare.appointments;

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

[Assistant] SELECT created_at, doctor_id, approval_status FROM healthcare.appointments WHERE created_at > '2023-12-01';

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

[Assistant] SELECT created_at, doctor_id, approval_status FROM healthcare.appointments WHERE created_at > '2023-12-01' ORDER BY created_at DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE humanresources.articles (
  comment_id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  updated_at timestamp without time zone,
  media_url text NOT NULL,
  format character varying(128),
  score character varying(64),
  subscription_id text -- reference to subscriptions.invoice_id,
  FOREIGN KEY (subscription_id) REFERENCES subscriptions(invoice_id)
)

CREATE TABLE humanresources.products (
  item_id varchar PRIMARY KEY -- unique identifier,
  expires_at timestamp,
  published_at timestamp,
  msrp char NOT NULL,
  image_url char,
  cost integer
)

CREATE TABLE humanresources.subscriptions (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  updated_at date,
  debit character varying(256),
  credit varchar NOT NULL,
  user_id varchar,
  payer_id text -- identifier for payer,
  currency varchar,
  product_id text NOT NULL -- reference to products.item_id,
  FOREIGN KEY (product_id) REFERENCES products(item_id)
)

[User] List all subscriptions.

[Assistant] SELECT * FROM humanresources.subscriptions;

[User] Can you order these by currency descending?

[Assistant] SELECT * FROM humanresources.subscriptions ORDER BY currency DESC;

[User] Get sum of payer_id by updated_at from subscriptions.

[Assistant] SELECT updated_at, SUM(payer_id) AS sum_payer_id FROM humanresources.subscriptions GROUP BY updated_at;


[User] Display all articles.

[Assistant] SELECT * FROM humanresources.articles;

[User] List articles with dates from 2023.

[Assistant] SELECT * FROM humanresources.articles WHERE edited_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Order the output by subscription_id ascending.

[Assistant] SELECT * FROM humanresources.articles WHERE edited_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY subscription_id ASC;


[User] What are the updated_at, subscription_id, edited_at of each article?

[Assistant] SELECT updated_at, subscription_id, edited_at FROM humanresources.articles;

[User] Show me edited_at, score, payer_id, currency from articles and their related subscriptions.

[Assistant] SELECT updated_at, subscription_id, edited_at, subscriptions.payer_id, subscriptions.currency FROM humanresources.articles JOIN humanresources.subscriptions ON articles.subscription_id = subscriptions.invoice_id;

[User] Limit the results to 20 rows.

[Assistant] SELECT updated_at, subscription_id, edited_at, subscriptions.payer_id, subscriptions.currency FROM humanresources.articles JOIN humanresources.subscriptions ON articles.subscription_id = subscriptions.invoice_id LIMIT 20;


[User] Get all subscriptions.

[Assistant] SELECT * FROM humanresources.subscriptions;

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

[Assistant] SELECT * FROM humanresources.subscriptions WHERE currency LIKE 'A%';

[User] Sort the results by product_id descending.

[Assistant] SELECT * FROM humanresources.subscriptions WHERE currency LIKE 'A%' ORDER BY product_id DESC;


[User] List all articles.

[Assistant] SELECT * FROM humanresources.articles;

[User] Can you order these by format descending?

[Assistant] SELECT * FROM humanresources.articles ORDER BY format DESC;

[User] Sort the results by format ascending.

[Assistant] SELECT * FROM humanresources.articles ORDER BY format ASC;


[User] Retrieve all articles.

[Assistant] SELECT * FROM humanresources.articles;

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

[Assistant] SELECT * FROM humanresources.articles WHERE edited_at BETWEEN '2023-01-01' AND '2023-12-31';

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

[Assistant] SELECT * FROM humanresources.articles WHERE edited_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY subscription_id DESC;


[User] List all articles.

[Assistant] SELECT * FROM humanresources.articles;

[User] Get articles that match score LIKE 'A%'.

[Assistant] SELECT * FROM humanresources.articles WHERE score LIKE 'A%';

[User] Order the output by subscription_id descending.

[Assistant] SELECT * FROM humanresources.articles WHERE score LIKE 'A%' ORDER BY subscription_id DESC;


[User] Retrieve format, edited_at, score for every article.

[Assistant] SELECT format, edited_at, score FROM humanresources.articles;

[User] Show the results sorted by subscription_id descending.

[Assistant] SELECT format, edited_at, score FROM humanresources.articles ORDER BY subscription_id DESC;

[User] Get min of format by updated_at from articles.

[Assistant] SELECT updated_at, MIN(format) AS min_format FROM humanresources.articles GROUP BY updated_at;


[User] Retrieve all articles.

[Assistant] SELECT * FROM humanresources.articles;

[User] Show me articles with edited_at > '2023-01-01'.

[Assistant] SELECT * FROM humanresources.articles WHERE edited_at > '2023-01-01';

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

[Assistant] SELECT updated_at, MIN(updated_at) AS min_updated_at FROM humanresources.articles GROUP BY updated_at;


[User] List subscription_id, score, updated_at from articles.

[Assistant] SELECT subscription_id, score, updated_at FROM humanresources.articles;

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

[Assistant] SELECT subscription_id, score, updated_at FROM humanresources.articles WHERE updated_at > '2023-01-01';

[User] Group articles by edited_at and show the max of updated_at.

[Assistant] SELECT edited_at, MAX(updated_at) AS max_updated_at FROM humanresources.articles GROUP BY edited_at;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.billing (
  payment_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  payer_id char NOT NULL -- identifier for payer,
  credit char,
  notes character varying(256),
  prescription_id text -- reference to prescriptions.transaction_id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(transaction_id)
)

CREATE TABLE healthcare.prescriptions (
  transaction_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  category character varying(256),
  amount smallint,
  currency varchar NOT NULL
)

CREATE TABLE healthcare.departments (
  store_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  address_line1 character varying(64),
  operating_hours character varying(64),
  country char,
  category varchar
)

CREATE TABLE healthcare.doctors (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  cancelled_at timestamp,
  tax decimal,
  product_id character varying(128),
  payment_method character varying(64),
  seller_id character varying(64) NOT NULL,
  subtotal smallint,
  prescription_id text -- reference to prescriptions.transaction_id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(transaction_id)
)

[User] List all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Show me product_id, invoice_id, created_at, category from doctors and their related prescriptions.

[Assistant] SELECT *, prescriptions.created_at, prescriptions.category FROM healthcare.doctors JOIN healthcare.prescriptions ON doctors.prescription_id = prescriptions.transaction_id;

[User] Tally up doctors by seller_id.

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


[User] List all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] What notes, prescription_id, category, amount do we have for billing and their associated prescriptions?

[Assistant] SELECT *, prescriptions.category, prescriptions.amount FROM healthcare.billing JOIN healthcare.prescriptions ON billing.prescription_id = prescriptions.transaction_id;

[User] What is the min prescription_id for each payer_id in billing?

[Assistant] SELECT payer_id, MIN(prescription_id) AS min_prescription_id FROM healthcare.billing GROUP BY payer_id;


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

[Assistant] SELECT * FROM healthcare.doctors ORDER BY seller_id DESC;

[User] Tally up doctors by subtotal.

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


[User] Retrieve all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

[Assistant] SELECT * FROM healthcare.billing WHERE payer_id LIKE 'A%';

[User] Order the output by processed_at ascending.

[Assistant] SELECT * FROM healthcare.billing WHERE payer_id LIKE 'A%' ORDER BY processed_at ASC;


[User] What are the payer_id, notes, prescription_id of each billing?

[Assistant] SELECT payer_id, notes, prescription_id FROM healthcare.billing;

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

[Assistant] SELECT payer_id, notes, prescription_id FROM healthcare.billing WHERE processed_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Order the output by payer_id ascending.

[Assistant] SELECT payer_id, notes, prescription_id FROM healthcare.billing WHERE processed_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY payer_id ASC;


[User] What are the prescription_id, subtotal, tax of each doctor?

[Assistant] SELECT prescription_id, subtotal, tax FROM healthcare.doctors;

[User] Sort the results by seller_id descending.

[Assistant] SELECT prescription_id, subtotal, tax FROM healthcare.doctors ORDER BY seller_id DESC;

[User] Show me average of payment_method grouped by tax for doctors.

[Assistant] SELECT tax, AVERAGE(payment_method) AS average_payment_method FROM healthcare.doctors GROUP BY tax;


[User] Retrieve credit, prescription_id, processed_at for every billing.

[Assistant] SELECT credit, prescription_id, processed_at FROM healthcare.billing;

[User] Can you order these by prescription_id descending?

[Assistant] SELECT credit, prescription_id, processed_at FROM healthcare.billing ORDER BY prescription_id DESC;

[User] How many billing are there per notes?

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


[User] List cancelled_at, prescription_id, invoice_id from doctors.

[Assistant] SELECT cancelled_at, prescription_id, invoice_id FROM healthcare.doctors;

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

[Assistant] SELECT cancelled_at, prescription_id, invoice_id FROM healthcare.doctors WHERE cancelled_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Show me max of subtotal grouped by seller_id for doctors.

[Assistant] SELECT seller_id, MAX(subtotal) AS max_subtotal FROM healthcare.doctors GROUP BY seller_id;


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Order the output by product_id descending.

[Assistant] SELECT * FROM healthcare.doctors ORDER BY product_id DESC;

[User] Group doctors by product_id and show the count of subtotal.

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


[User] Get processed_at, payer_id, notes from all billing.

[Assistant] SELECT processed_at, payer_id, notes FROM healthcare.billing;

[User] List billing with dates from 2023.

[Assistant] SELECT processed_at, payer_id, notes FROM healthcare.billing WHERE processed_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] How many billing are there per notes?

[Assistant] SELECT notes, COUNT(*) AS count FROM healthcare.billing GROUP BY notes 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.loans (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  payment_date date,
  due_date timestamp without time zone,
  payer_id character varying(64) -- identifier for payer,
  notes text NOT NULL,
  reference_number char,
  description character varying(256),
  customer_id integer NOT NULL -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

CREATE TABLE finance.accounts (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  credit char,
  exchange_rate character varying(128),
  invoice_number character varying(256) NOT NULL,
  loan_id text -- reference to loans.invoice_id,
  FOREIGN KEY (loan_id) REFERENCES loans(invoice_id)
)

CREATE TABLE finance.payments (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  customer_id character varying(64) NOT NULL -- identifier for customer,
  payment_method text,
  delivery_status char NOT NULL,
  account_id text NOT NULL -- reference to accounts.invoice_id,
  FOREIGN KEY (account_id) REFERENCES accounts(invoice_id)
)

CREATE TABLE finance.customers (
  employee_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  last_active timestamp without time zone,
  avatar char NOT NULL,
  membership_level char,
  status character varying(256),
  last_name character varying(256) NOT NULL,
  email character varying(64),
  loan_id text NOT NULL -- reference to loans.invoice_id,
  FOREIGN KEY (loan_id) REFERENCES loans(invoice_id)
)

[User] List all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Order the output by payment_method ascending.

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

[User] Order the output by account_id ascending.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.trades (
  transaction_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at timestamp,
  buyer_id character varying(64),
  currency character varying(256) NOT NULL,
  user_id character varying(64),
  status character varying(256),
  approval_status character varying(256),
  metadat_id text NOT NULL -- reference to metadata.id,
  FOREIGN KEY (metadat_id) REFERENCES metadata(id)
)

CREATE TABLE tradingplatform.notifications (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  due_date timestamp without time zone,
  created_at date,
  description character varying(128),
  vendor_id character varying(128) -- identifier for vendor,
  payee_id varchar -- identifier for payee,
  category character varying(256),
  payer_id char NOT NULL
)

CREATE TABLE tradingplatform.metadata (
  id varchar PRIMARY KEY -- unique identifier,
  processed_at date,
  card_type char NOT NULL,
  status varchar,
  delivery_status varchar,
  trade_id text NOT NULL -- reference to trades.transaction_id,
  FOREIGN KEY (trade_id) REFERENCES trades(transaction_id)
)

[User] Show me all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Get all metadata from 2023.

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

[User] What is the min trade_id for each card_type in metadata?

[Assistant] SELECT card_type, MIN(trade_id) AS min_trade_id FROM tradingplatform.metadata GROUP BY card_type;


[User] What are the processed_at, status, delivery_status of each metadata?

[Assistant] SELECT processed_at, status, delivery_status FROM tradingplatform.metadata;

[User] Find metadata older than 6 months.

[Assistant] SELECT processed_at, status, delivery_status FROM tradingplatform.metadata WHERE processed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Count the number of metadata in each card_type category.

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


[User] Retrieve processed_at, card_type, delivery_status for every metadata.

[Assistant] SELECT processed_at, card_type, delivery_status FROM tradingplatform.metadata;

[User] List metadata with dates from 2023.

[Assistant] SELECT processed_at, card_type, delivery_status FROM tradingplatform.metadata WHERE processed_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Get average of status by trade_id from metadata.

[Assistant] SELECT trade_id, AVERAGE(status) AS average_status FROM tradingplatform.metadata GROUP BY trade_id;


[User] Show me all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Sort the results by trade_id ascending.

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

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

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


[User] What are the status, card_type, delivery_status of each metadata?

[Assistant] SELECT status, card_type, delivery_status FROM tradingplatform.metadata;

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

[Assistant] SELECT status, card_type, delivery_status FROM tradingplatform.metadata WHERE processed_at > '2023-12-01';

[User] Sort the results by delivery_status descending.

[Assistant] SELECT status, card_type, delivery_status FROM tradingplatform.metadata WHERE processed_at > '2023-12-01' ORDER BY delivery_status DESC;


[User] Get currency, created_at, approval_status from all trades.

[Assistant] SELECT currency, created_at, approval_status FROM tradingplatform.trades;

[User] What approval_status, updated_at, status, processed_at do we have for trades and their associated metadata?

[Assistant] SELECT currency, created_at, approval_status, metadata.status, metadata.processed_at FROM tradingplatform.trades JOIN tradingplatform.metadata ON trades.metadat_id = metadata.id;

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

[Assistant] SELECT currency, created_at, approval_status, metadata.status, metadata.processed_at FROM tradingplatform.trades JOIN tradingplatform.metadata ON trades.metadat_id = metadata.id ORDER BY approval_status ASC;


[User] Display all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

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

[Assistant] SELECT * FROM tradingplatform.trades WHERE updated_at > '2023-01-01';

[User] Restrict the output to 20 items.

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


[User] What are the delivery_status, trade_id, card_type of each metadata?

[Assistant] SELECT delivery_status, trade_id, card_type FROM tradingplatform.metadata;

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

[Assistant] SELECT delivery_status, trade_id, card_type FROM tradingplatform.metadata WHERE delivery_status LIKE 'A%';

[User] Calculate max of processed_at for each trade_id in metadata.

[Assistant] SELECT trade_id, MAX(processed_at) AS max_processed_at FROM tradingplatform.metadata GROUP BY trade_id;


[User] What are the processed_at, delivery_status, card_type of each metadata?

[Assistant] SELECT processed_at, delivery_status, card_type FROM tradingplatform.metadata;

[User] What card_type, processed_at, currency, updated_at do we have for metadata and their associated trades?

[Assistant] SELECT processed_at, delivery_status, card_type, trades.currency, trades.updated_at FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.transaction_id;

[User] Get count of card_type by status from metadata.

[Assistant] SELECT status, COUNT(card_type) AS count_card_type FROM tradingplatform.metadata GROUP BY status;


[User] Get trade_id, status, card_type from all metadata.

[Assistant] SELECT trade_id, status, card_type FROM tradingplatform.metadata;

[User] Show the results sorted by processed_at ascending.

[Assistant] SELECT trade_id, status, card_type FROM tradingplatform.metadata ORDER BY processed_at ASC;

[User] Show only 100 records.

[Assistant] SELECT trade_id, status, card_type FROM tradingplatform.metadata ORDER BY processed_at ASC LIMIT 100;


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.assignments (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  image_url character varying(256),
  title char,
  discount numeric,
  grade_id text -- reference to grades.order_id,
  FOREIGN KEY (grade_id) REFERENCES grades(order_id)
)

CREATE TABLE education.teachers (
  venue_id text PRIMARY KEY -- unique identifier,
  last_inspected date,
  updated_at timestamp,
  operating_hours char NOT NULL,
  timezone text,
  country character varying(128),
  longitude varchar NOT NULL,
  assignment_id text NOT NULL -- reference to assignments.id,
  grade_id text NOT NULL -- reference to grades.order_id,
  FOREIGN KEY (assignment_id) REFERENCES assignments(id),
  FOREIGN KEY (grade_id) REFERENCES grades(order_id)
)

CREATE TABLE education.grades (
  order_id text PRIMARY KEY -- unique identifier,
  completed_at timestamp,
  seller_id character varying(64) -- identifier for seller,
  approval_status text,
  exchange_rate character varying(256)
)

[User] Get updated_at, grade_id, title from all assignments.

[Assistant] SELECT updated_at, grade_id, title FROM education.assignments;

[User] Show me assignments with updated_at > '2023-01-01'.

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

[User] Only show the top 20 results.

[Assistant] SELECT updated_at, grade_id, title FROM education.assignments WHERE updated_at > '2023-01-01' LIMIT 20;


[User] List discount, updated_at, title from assignments.

[Assistant] SELECT discount, updated_at, title FROM education.assignments;

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

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

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

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


[User] List updated_at, discount, grade_id from assignments.

[Assistant] SELECT updated_at, discount, grade_id FROM education.assignments;

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

[Assistant] SELECT updated_at, discount, grade_id FROM education.assignments WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months';

[User] What is the min discount for each grade_id in assignments?

[Assistant] SELECT grade_id, MIN(discount) AS min_discount FROM education.assignments GROUP BY grade_id;


[User] Get image_url, title, grade_id from all assignments.

[Assistant] SELECT image_url, title, grade_id FROM education.assignments;

[User] List assignments that have discount > 82.

[Assistant] SELECT image_url, title, grade_id FROM education.assignments WHERE discount > 82;

[User] Only show the top 50 results.

[Assistant] SELECT image_url, title, grade_id FROM education.assignments WHERE discount > 82 LIMIT 50;


[User] List all assignments.

[Assistant] SELECT * FROM education.assignments;

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

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

[User] How many assignments are there per image_url?

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


[User] List all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] Order the output by updated_at ascending.

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

[User] Sort the results by country ascending.

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


[User] Show me grade_id, title, updated_at for all assignments.

[Assistant] SELECT grade_id, title, updated_at FROM education.assignments;

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

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

[User] Show me the count of assignments grouped by title.

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


[User] What are the last_inspected, grade_id, longitude of each teacher?

[Assistant] SELECT last_inspected, grade_id, longitude FROM education.teachers;

[User] Can you order these by timezone descending?

[Assistant] SELECT last_inspected, grade_id, longitude FROM education.teachers ORDER BY timezone DESC;

[User] Only show the top 5 results.

[Assistant] SELECT last_inspected, grade_id, longitude FROM education.teachers ORDER BY timezone DESC LIMIT 5;


[User] Retrieve all assignments.

[Assistant] SELECT * FROM education.assignments;

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

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

[User] Group assignments by updated_at and show the average of grade_id.

[Assistant] SELECT updated_at, AVERAGE(grade_id) AS average_grade_id FROM education.assignments GROUP BY updated_at;


[User] List all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

[User] Sort the results by longitude descending.

[Assistant] SELECT * FROM education.teachers WHERE last_inspected >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY longitude DESC;