[User] List featured_rank, updated_at, quantity from prescriptions.

[Assistant] SELECT featured_rank, updated_at, quantity FROM healthcare.prescriptions;

[User] Show the results sorted by patient_id ascending.

[Assistant] SELECT featured_rank, updated_at, quantity FROM healthcare.prescriptions ORDER BY patient_id ASC;

[User] Return just 5 rows.

[Assistant] SELECT featured_rank, updated_at, quantity FROM healthcare.prescriptions ORDER BY patient_id ASC LIMIT 5;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.medical_records (
  id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  approval_status character varying(256) NOT NULL,
  payment_method varchar NOT NULL,
  prescription_id text -- reference to prescriptions.sku,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(sku)
)

CREATE TABLE healthcare.patients (
  customer_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  joined_at date,
  username varchar,
  last_login timestamp without time zone,
  city character varying(128) NOT NULL
)

CREATE TABLE healthcare.prescriptions (
  sku varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  featured_rank text,
  image_url character varying(256) NOT NULL,
  quantity char,
  subcategory text,
  patient_id integer -- reference to patients.customer_id,
  FOREIGN KEY (patient_id) REFERENCES patients(customer_id)
)

CREATE TABLE healthcare.billing (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  thumbnail character varying(128),
  user_id character varying(64) NOT NULL -- identifier for user,
  score char,
  author_id character varying(128)
)

[User] List subcategory, updated_at, quantity from prescriptions.

[Assistant] SELECT subcategory, updated_at, quantity FROM healthcare.prescriptions;

[User] Show the results sorted by subcategory descending.

[Assistant] SELECT subcategory, updated_at, quantity FROM healthcare.prescriptions ORDER BY subcategory DESC;

[User] Get average of quantity by image_url from prescriptions.

[Assistant] SELECT image_url, AVERAGE(quantity) AS average_quantity FROM healthcare.prescriptions GROUP BY image_url;


[User] Display all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] Get all medical_records created yesterday.

[Assistant] SELECT * FROM healthcare.medical_records WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Sort the results by updated_at descending.

[Assistant] SELECT * FROM healthcare.medical_records WHERE updated_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY updated_at DESC;


[User] List all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] List medical_records with dates from last week.

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

[User] Group medical_records by approval_status and show the sum of payment_method.

[Assistant] SELECT approval_status, SUM(payment_method) AS sum_payment_method FROM healthcare.medical_records GROUP BY approval_status;


[User] List all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

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

[Assistant] SELECT * FROM healthcare.medical_records ORDER BY approval_status DESC;

[User] Return just 25 rows.

[Assistant] SELECT * FROM healthcare.medical_records ORDER BY approval_status DESC LIMIT 25;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.order_items (
  person_id integer PRIMARY KEY -- unique identifier,
  last_active date,
  joined_at date,
  avatar character varying(256),
  password_hash varchar NOT NULL,
  language character varying(64),
  display_name character varying(256),
  email character varying(64),
  last_login date,
  review_id text -- reference to reviews.comment_id,
  FOREIGN KEY (review_id) REFERENCES reviews(comment_id)
)

CREATE TABLE e-commerce.reviews (
  comment_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  edited_at timestamp,
  visibility character varying(128),
  views char,
  image_url char,
  author_id char -- identifier for author
)

CREATE TABLE e-commerce.categories (
  comment_id text PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  edited_at timestamp without time zone,
  subject char NOT NULL,
  tags char,
  reply_to_id character varying(64),
  shares text NOT NULL,
  rating character varying(256),
  description varchar,
  likes text NOT NULL
)

[User] Retrieve language, last_active, joined_at for every order_item.

[Assistant] SELECT language, last_active, joined_at FROM e-commerce.order_items;

[User] Find order_items where last_login > '2023-01-01'.

[Assistant] SELECT language, last_active, joined_at FROM e-commerce.order_items WHERE last_login > '2023-01-01';

[User] Limit the results to 20 rows.

[Assistant] SELECT language, last_active, joined_at FROM e-commerce.order_items WHERE last_login > '2023-01-01' LIMIT 20;


[User] Retrieve avatar, display_name, email for every order_item.

[Assistant] SELECT avatar, display_name, email FROM e-commerce.order_items;

[User] List order_items that have review_id LIKE 'A%'.

[Assistant] SELECT avatar, display_name, email FROM e-commerce.order_items WHERE review_id LIKE 'A%';

[User] Return just 25 rows.

[Assistant] SELECT avatar, display_name, email FROM e-commerce.order_items WHERE review_id LIKE 'A%' LIMIT 25;


[User] Show me all order_items.

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

[User] Retrieve language, avatar, image_url, created_at showing the relationship between order_items and reviews.

[Assistant] SELECT *, reviews.image_url, reviews.created_at FROM e-commerce.order_items JOIN e-commerce.reviews ON order_items.review_id = reviews.comment_id;

[User] What is the average review_id for each last_login in order_items?

[Assistant] SELECT last_login, AVERAGE(review_id) AS average_review_id FROM e-commerce.order_items GROUP BY last_login;


[User] List last_login, review_id, language from order_items.

[Assistant] SELECT last_login, review_id, language FROM e-commerce.order_items;

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

[Assistant] SELECT last_login, review_id, language FROM e-commerce.order_items WHERE joined_at > '2023-01-01';

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

[Assistant] SELECT last_login, review_id, language FROM e-commerce.order_items WHERE joined_at > '2023-01-01' ORDER BY joined_at ASC;


[User] Show me last_active, avatar, display_name for all order_items.

[Assistant] SELECT last_active, avatar, display_name FROM e-commerce.order_items;

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

[Assistant] SELECT last_active, avatar, display_name FROM e-commerce.order_items WHERE last_active BETWEEN '2023-01-01' AND '2023-12-31';

[User] Calculate count of password_hash for each language in order_items.

[Assistant] SELECT language, COUNT(password_hash) AS count_password_hash FROM e-commerce.order_items GROUP BY language;


[User] Show me all order_items.

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

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

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

[User] Sort the results by last_active ascending.

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


[User] List last_active, last_login, avatar from order_items.

[Assistant] SELECT last_active, last_login, avatar FROM e-commerce.order_items;

[User] Show me last_login, avatar, created_at, author_id from order_items and their related reviews.

[Assistant] SELECT last_active, last_login, avatar, reviews.created_at, reviews.author_id FROM e-commerce.order_items JOIN e-commerce.reviews ON order_items.review_id = reviews.comment_id;

[User] Calculate count of last_active for each display_name in order_items.

[Assistant] SELECT display_name, COUNT(last_active) AS count_last_active FROM e-commerce.order_items GROUP BY display_name;


[User] List last_login, joined_at, last_active from order_items.

[Assistant] SELECT last_login, joined_at, last_active FROM e-commerce.order_items;

[User] What avatar, review_id, author_id, edited_at do we have for order_items and their associated reviews?

[Assistant] SELECT last_login, joined_at, last_active, reviews.author_id, reviews.edited_at FROM e-commerce.order_items JOIN e-commerce.reviews ON order_items.review_id = reviews.comment_id;

[User] What is the min last_login for each avatar in order_items?

[Assistant] SELECT avatar, MIN(last_login) AS min_last_login FROM e-commerce.order_items GROUP BY avatar;


[User] Display all order_items.

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

[User] Show me joined_at, review_id, author_id, visibility from order_items and their related reviews.

[Assistant] SELECT *, reviews.author_id, reviews.visibility FROM e-commerce.order_items JOIN e-commerce.reviews ON order_items.review_id = reviews.comment_id;

[User] What is the average password_hash for each email in order_items?

[Assistant] SELECT email, AVERAGE(password_hash) AS average_password_hash FROM e-commerce.order_items GROUP BY email;


[User] List last_login, password_hash, email from order_items.

[Assistant] SELECT last_login, password_hash, email FROM e-commerce.order_items;

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

[Assistant] SELECT last_login, password_hash, email FROM e-commerce.order_items WHERE language LIKE 'A%';

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE logistics.subscriptions (
  transaction_id text PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  processed_at timestamp,
  reconciliation_status char,
  user_id text NOT NULL,
  verification_status character varying(64) NOT NULL,
  customer_id integer -- reference to customers.person_id,
  FOREIGN KEY (customer_id) REFERENCES customers(person_id)
)

CREATE TABLE logistics.locations (
  venue_id integer PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at timestamp,
  address_line2 character varying(64),
  street character varying(256),
  description character varying(256),
  zip_code text NOT NULL,
  timezone varchar,
  review_id integer NOT NULL -- reference to reviews.message_id,
  FOREIGN KEY (review_id) REFERENCES reviews(message_id)
)

CREATE TABLE logistics.customers (
  person_id integer PRIMARY KEY -- unique identifier,
  last_active date,
  created_at timestamp without time zone,
  language character varying(128) NOT NULL,
  display_name text,
  phone char,
  bio char,
  token text,
  is_verified boolean
)

CREATE TABLE logistics.reviews (
  message_id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  text text NOT NULL,
  attachment_url char,
  rating character varying(128),
  visibility character varying(256) NOT NULL
)

[User] List all locations.

[Assistant] SELECT * FROM logistics.locations;

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

[Assistant] SELECT * FROM logistics.locations WHERE updated_at > '2023-01-01';

[User] Group locations by street and show the max of street.

[Assistant] SELECT street, MAX(street) AS max_street FROM logistics.locations GROUP BY street;


[User] Show me all subscriptions.

[Assistant] SELECT * FROM logistics.subscriptions;

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

[Assistant] SELECT * FROM logistics.subscriptions WHERE payment_date > '2023-01-01';

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

[Assistant] SELECT customer_id, MAX(processed_at) AS max_processed_at FROM logistics.subscriptions GROUP BY customer_id;


[User] Display all subscriptions.

[Assistant] SELECT * FROM logistics.subscriptions;

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

[Assistant] SELECT * FROM logistics.subscriptions WHERE payment_date >= CURRENT_DATE - INTERVAL '30 days';

[User] How many subscriptions are there per reconciliation_status?

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


[User] Display all locations.

[Assistant] SELECT * FROM logistics.locations;

[User] Find locations created yesterday.

[Assistant] SELECT * FROM logistics.locations WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

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

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


[User] List all locations.

[Assistant] SELECT * FROM logistics.locations;

[User] Get all locations between January and March.

[Assistant] SELECT * FROM logistics.locations WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

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

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


[User] Retrieve address_line2, timezone, street for every location.

[Assistant] SELECT address_line2, timezone, street FROM logistics.locations;

[User] List locations with dates from 2023.

[Assistant] SELECT address_line2, timezone, street FROM logistics.locations WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Get average of zip_code by description from locations.

[Assistant] SELECT description, AVERAGE(zip_code) AS average_zip_code FROM logistics.locations GROUP BY description;


[User] List all subscriptions.

[Assistant] SELECT * FROM logistics.subscriptions;

[User] Find subscriptions from last week.

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

[User] Only show the top 20 results.

[Assistant] SELECT * FROM logistics.subscriptions WHERE processed_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 20;


[User] Display all locations.

[Assistant] SELECT * FROM logistics.locations;

[User] What created_at, review_id, visibility, rating do we have for locations and their associated reviews?

[Assistant] SELECT *, reviews.visibility, reviews.rating FROM logistics.locations JOIN logistics.reviews ON locations.review_id = reviews.message_id;

[User] Limit the results to 50 rows.

[Assistant] SELECT *, reviews.visibility, reviews.rating FROM logistics.locations JOIN logistics.reviews ON locations.review_id = reviews.message_id LIMIT 50;


[User] Show me all subscriptions.

[Assistant] SELECT * FROM logistics.subscriptions;

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

[Assistant] SELECT * FROM logistics.subscriptions WHERE payment_date > '2023-01-01';

[User] Show me average of processed_at grouped by reconciliation_status for subscriptions.

[Assistant] SELECT reconciliation_status, AVERAGE(processed_at) AS average_processed_at FROM logistics.subscriptions GROUP BY reconciliation_status;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE media.reviews (
  message_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  edited_at timestamp without time zone,
  reply_to_id character varying(64),
  score character varying(256) NOT NULL,
  parent_id character varying(64) NOT NULL,
  categories text,
  format char
)

CREATE TABLE media.transactions (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  traded_at timestamp without time zone,
  buyer_id character varying(128) NOT NULL -- identifier for buyer,
  customer_id character varying(64),
  approval_status char NOT NULL,
  payment_status character varying(64),
  subtotal bigint,
  currency character varying(128),
  tax numeric,
  review_id integer NOT NULL -- reference to reviews.message_id,
  FOREIGN KEY (review_id) REFERENCES reviews(message_id)
)

[User] List all transactions.

[Assistant] SELECT * FROM media.transactions;

[User] Find transactions modified within the last hour.

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

[User] Get min of payment_status by customer_id from transactions.

[Assistant] SELECT customer_id, MIN(payment_status) AS min_payment_status FROM media.transactions GROUP BY customer_id;


[User] Display all transactions.

[Assistant] SELECT * FROM media.transactions;

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

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

[User] Show me max of approval_status grouped by tax for transactions.

[Assistant] SELECT tax, MAX(approval_status) AS max_approval_status FROM media.transactions GROUP BY tax;


[User] Show me all transactions.

[Assistant] SELECT * FROM media.transactions;

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

[Assistant] SELECT * FROM media.transactions WHERE updated_at > '2023-01-01';

[User] Show me average of buyer_id grouped by currency for transactions.

[Assistant] SELECT currency, AVERAGE(buyer_id) AS average_buyer_id FROM media.transactions GROUP BY currency;


[User] What are the updated_at, customer_id, buyer_id of each transaction?

[Assistant] SELECT updated_at, customer_id, buyer_id FROM media.transactions;

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

[Assistant] SELECT updated_at, customer_id, buyer_id FROM media.transactions WHERE traded_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Group transactions by buyer_id and show the min of tax.

[Assistant] SELECT buyer_id, MIN(tax) AS min_tax FROM media.transactions GROUP BY buyer_id;


[User] Retrieve traded_at, review_id, subtotal for every transaction.

[Assistant] SELECT traded_at, review_id, subtotal FROM media.transactions;

[User] Find transactions where tax > 9.

[Assistant] SELECT traded_at, review_id, subtotal FROM media.transactions WHERE tax > 9;

[User] Show the results sorted by updated_at descending.

[Assistant] SELECT traded_at, review_id, subtotal FROM media.transactions WHERE tax > 9 ORDER BY updated_at DESC;


[User] Get all transactions.

[Assistant] SELECT * FROM media.transactions;

[User] Show me payment_status, updated_at, score, categories from transactions and their related reviews.

[Assistant] SELECT *, reviews.score, reviews.categories FROM media.transactions JOIN media.reviews ON transactions.review_id = reviews.message_id;

[User] Tally up transactions by customer_id.

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


[User] List approval_status, payment_status, review_id from transactions.

[Assistant] SELECT approval_status, payment_status, review_id FROM media.transactions;

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

[Assistant] SELECT approval_status, payment_status, review_id FROM media.transactions WHERE traded_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] What is the count review_id for each traded_at in transactions?

[Assistant] SELECT traded_at, COUNT(review_id) AS count_review_id FROM media.transactions GROUP BY traded_at;


[User] What are the currency, customer_id, tax of each transaction?

[Assistant] SELECT currency, customer_id, tax FROM media.transactions;

[User] Retrieve transactions where traded_at > '2023-01-01'.

[Assistant] SELECT currency, customer_id, tax FROM media.transactions WHERE traded_at > '2023-01-01';

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

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


[User] Retrieve all transactions.

[Assistant] SELECT * FROM media.transactions;

[User] Sort the results by payment_status ascending.

[Assistant] SELECT * FROM media.transactions ORDER BY payment_status ASC;

[User] Tally up transactions by traded_at.

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


[User] Show me review_id, customer_id, updated_at for all transactions.

[Assistant] SELECT review_id, customer_id, updated_at FROM media.transactions;

[User] Retrieve transactions where tax > 36.

[Assistant] SELECT review_id, customer_id, updated_at FROM media.transactions WHERE tax > 36;

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.payments (
  order_id character varying(64) NOT NULL -- unique identifier,
  traded_at date,
  tax smallint NOT NULL,
  payment_method character varying(256),
  currency character varying(64),
  buyer_id text,
  approval_status text,
  quantity varchar,
  customer_id text -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

CREATE TABLE finance.loans (
  payment_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  due_date timestamp without time zone,
  status character varying(256),
  currency varchar,
  customer_id character varying(256) -- identifier for customer,
  notes character varying(256),
  verification_status char NOT NULL,
  invoice_number character varying(256) NOT NULL
)

CREATE TABLE finance.customers (
  employee_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  display_name char NOT NULL,
  salt text NOT NULL,
  birth_date timestamp without time zone NOT NULL
)

[User] Retrieve approval_status, customer_id, payment_method for every payment.

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

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

[Assistant] SELECT approval_status, customer_id, payment_method FROM finance.payments WHERE traded_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Can you order these by tax descending?

[Assistant] SELECT approval_status, customer_id, payment_method FROM finance.payments WHERE traded_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY tax DESC;


[User] Get buyer_id, currency, payment_method from all payments.

[Assistant] SELECT buyer_id, currency, payment_method FROM finance.payments;

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

[Assistant] SELECT buyer_id, currency, payment_method FROM finance.payments WHERE traded_at > '2023-01-01';

[User] Restrict the output to 20 items.

[Assistant] SELECT buyer_id, currency, payment_method FROM finance.payments WHERE traded_at > '2023-01-01' LIMIT 20;


[User] Show me all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Sort the results by payment_method ascending.

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

[User] Get count of order_id by order_id from payments.

[Assistant] SELECT order_id, COUNT(order_id) AS count_order_id FROM finance.payments GROUP BY order_id;


[User] List all payments.

[Assistant] SELECT * FROM finance.payments;

[User] List order_id, currency, display_name, birth_date for each payment along with their customer information.

[Assistant] SELECT *, customers.display_name, customers.birth_date FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.employee_id;

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

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


[User] Display all payments.

[Assistant] SELECT * FROM finance.payments;

[User] List payments with dates from last week.

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

[User] Can you order these by approval_status descending?

[Assistant] SELECT * FROM finance.payments WHERE traded_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY approval_status DESC;


[User] Retrieve buyer_id, payment_method, order_id for every payment.

[Assistant] SELECT buyer_id, payment_method, order_id FROM finance.payments;

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

[Assistant] SELECT buyer_id, payment_method, order_id FROM finance.payments WHERE traded_at > '2023-01-01';

[User] Limit the results to 100 rows.

[Assistant] SELECT buyer_id, payment_method, order_id FROM finance.payments WHERE traded_at > '2023-01-01' LIMIT 100;


[User] Get all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Restrict the output to 100 items.

[Assistant] SELECT * FROM finance.payments WHERE currency LIKE 'A%' LIMIT 100;


[User] Show me all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Get traded_at, quantity, birth_date, salt by joining payments with customers.

[Assistant] SELECT *, customers.birth_date, customers.salt FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.employee_id;

[User] Can you order these by order_id descending?

[Assistant] SELECT *, customers.birth_date, customers.salt FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.employee_id ORDER BY order_id DESC;


[User] List approval_status, payment_method, quantity from payments.

[Assistant] SELECT approval_status, payment_method, quantity FROM finance.payments;

[User] Get all payments from 2023.

[Assistant] SELECT approval_status, payment_method, quantity FROM finance.payments WHERE traded_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Return just 50 rows.

[Assistant] SELECT approval_status, payment_method, quantity FROM finance.payments WHERE traded_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 50;


[User] Retrieve traded_at, currency, tax for every payment.

[Assistant] SELECT traded_at, currency, tax FROM finance.payments;

[User] Sort the results by tax ascending.

[Assistant] SELECT traded_at, currency, tax FROM finance.payments ORDER BY tax ASC;

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

[Assistant] SELECT customer_id, COUNT(*) AS count FROM finance.payments GROUP BY customer_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.wallets (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  due_date timestamp,
  payment_date timestamp without time zone,
  description character varying(256),
  approval_status varchar,
  user_id text -- reference to users.user_id,
  order_id integer NOT NULL -- reference to orders.payment_id,
  FOREIGN KEY (user_id) REFERENCES users(user_id),
  FOREIGN KEY (order_id) REFERENCES orders(payment_id)
)

CREATE TABLE tradingplatform.orders (
  payment_id integer PRIMARY KEY -- unique identifier,
  traded_at date,
  cancelled_at date,
  account_id text -- identifier for account,
  payment_status character varying(256),
  price bigint,
  quantity character varying(128),
  user_id text -- reference to users.user_id,
  FOREIGN KEY (user_id) REFERENCES users(user_id)
)

CREATE TABLE tradingplatform.users (
  user_id varchar PRIMARY KEY -- unique identifier,
  joined_at date,
  last_active date,
  is_active bit NOT NULL,
  status char,
  display_name character varying(256) NOT NULL,
  website character varying(128),
  is_verified boolean NOT NULL -- indicates if verified is true
)

[User] Show me all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Find orders where price > 57.

[Assistant] SELECT * FROM tradingplatform.orders WHERE price > 57;

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

[Assistant] SELECT * FROM tradingplatform.orders WHERE price > 57 ORDER BY quantity DESC;


[User] Show me user_id, traded_at, quantity for all orders.

[Assistant] SELECT user_id, traded_at, quantity FROM tradingplatform.orders;

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

[Assistant] SELECT user_id, traded_at, quantity FROM tradingplatform.orders WHERE account_id LIKE 'A%';

[User] Order the output by payment_status ascending.

[Assistant] SELECT user_id, traded_at, quantity FROM tradingplatform.orders WHERE account_id LIKE 'A%' ORDER BY payment_status ASC;


[User] List cancelled_at, traded_at, user_id from orders.

[Assistant] SELECT cancelled_at, traded_at, user_id FROM tradingplatform.orders;

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

[Assistant] SELECT cancelled_at, traded_at, user_id FROM tradingplatform.orders WHERE traded_at > '2023-12-01';

[User] Return just 50 rows.

[Assistant] SELECT cancelled_at, traded_at, user_id FROM tradingplatform.orders WHERE traded_at > '2023-12-01' LIMIT 50;


[User] Get all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY price DESC;

[User] Only show the top 25 results.

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY price DESC LIMIT 25;


[User] List due_date, user_id, approval_status from wallets.

[Assistant] SELECT due_date, user_id, approval_status FROM tradingplatform.wallets;

[User] What invoice_id, due_date, is_verified, is_active do we have for wallets and their associated users?

[Assistant] SELECT due_date, user_id, approval_status, users.is_verified, users.is_active FROM tradingplatform.wallets JOIN tradingplatform.users ON wallets.user_id = users.user_id;

[User] Limit the results to 50 rows.

[Assistant] SELECT due_date, user_id, approval_status, users.is_verified, users.is_active FROM tradingplatform.wallets JOIN tradingplatform.users ON wallets.user_id = users.user_id LIMIT 50;


[User] What are the traded_at, price, account_id of each order?

[Assistant] SELECT traded_at, price, account_id FROM tradingplatform.orders;

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

[Assistant] SELECT traded_at, price, account_id FROM tradingplatform.orders WHERE traded_at > '2023-01-01';

[User] Get max of price by payment_status from orders.

[Assistant] SELECT payment_status, MAX(price) AS max_price FROM tradingplatform.orders GROUP BY payment_status;


[User] Show me order_id, payment_date, description for all wallets.

[Assistant] SELECT order_id, payment_date, description FROM tradingplatform.wallets;

[User] Get order_id, description, is_active, joined_at by joining wallets with users.

[Assistant] SELECT order_id, payment_date, description, users.is_active, users.joined_at FROM tradingplatform.wallets JOIN tradingplatform.users ON wallets.user_id = users.user_id;

[User] Can you order these by description ascending?

[Assistant] SELECT order_id, payment_date, description, users.is_active, users.joined_at FROM tradingplatform.wallets JOIN tradingplatform.users ON wallets.user_id = users.user_id ORDER BY description ASC;


[User] Show me order_id, approval_status, user_id for all wallets.

[Assistant] SELECT order_id, approval_status, user_id FROM tradingplatform.wallets;

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

[Assistant] SELECT order_id, approval_status, user_id FROM tradingplatform.wallets ORDER BY user_id DESC;

[User] Only show the top 10 results.

[Assistant] SELECT order_id, approval_status, user_id FROM tradingplatform.wallets ORDER BY user_id DESC LIMIT 10;


[User] What are the cancelled_at, price, account_id of each order?

[Assistant] SELECT cancelled_at, price, account_id FROM tradingplatform.orders;

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

[Assistant] SELECT cancelled_at, price, account_id FROM tradingplatform.orders WHERE traded_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Restrict the output to 10 items.

[Assistant] SELECT cancelled_at, price, account_id FROM tradingplatform.orders WHERE traded_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 10;


[User] Get description, order_id, invoice_id from all wallets.

[Assistant] SELECT description, order_id, invoice_id FROM tradingplatform.wallets;

[User] Show the results sorted by approval_status ascending.

[Assistant] SELECT description, order_id, invoice_id FROM tradingplatform.wallets ORDER BY approval_status ASC;

[User] Show me the count of wallets grouped by payment_date.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.teachers (
  payment_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  completed_at date,
  delivery_status character varying(256),
  seller_id character varying(256) -- identifier for seller,
  currency character varying(128),
  approval_status char,
  customer_id character varying(128)
)

CREATE TABLE education.courses (
  store_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  city character varying(128) NOT NULL,
  latitude character varying(256) NOT NULL,
  address_line2 text NOT NULL,
  category character varying(256) NOT NULL,
  state text NOT NULL,
  capacity text,
  accessibility character varying(128) NOT NULL
)

CREATE TABLE education.assignments (
  order_id character varying(64) NOT NULL -- unique identifier,
  cancelled_at timestamp without time zone,
  seller_id character varying(64) NOT NULL -- identifier for seller,
  subtotal integer,
  approval_status char NOT NULL,
  account_id varchar -- identifier for account,
  payment_method varchar
)

[User] Retrieve all assignments.

[Assistant] SELECT * FROM education.assignments;

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

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

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

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


[User] Show me customer_id, approval_status, seller_id for all teachers.

[Assistant] SELECT customer_id, approval_status, seller_id FROM education.teachers;

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

[Assistant] SELECT customer_id, approval_status, seller_id FROM education.teachers WHERE created_at > '2023-12-01';

[User] Return just 50 rows.

[Assistant] SELECT customer_id, approval_status, seller_id FROM education.teachers WHERE created_at > '2023-12-01' LIMIT 50;


[User] Show me address_line2, capacity, store_id for all courses.

[Assistant] SELECT address_line2, capacity, store_id FROM education.courses;

[User] Show me courses with accessibility LIKE 'A%'.

[Assistant] SELECT address_line2, capacity, store_id FROM education.courses WHERE accessibility LIKE 'A%';

[User] What is the count state for each address_line2 in courses?

[Assistant] SELECT address_line2, COUNT(state) AS count_state FROM education.courses GROUP BY address_line2;


[User] List currency, approval_status, delivery_status from teachers.

[Assistant] SELECT currency, approval_status, delivery_status FROM education.teachers;

[User] Order the output by delivery_status descending.

[Assistant] SELECT currency, approval_status, delivery_status FROM education.teachers ORDER BY delivery_status DESC;

[User] Only show the top 10 results.

[Assistant] SELECT currency, approval_status, delivery_status FROM education.teachers ORDER BY delivery_status DESC LIMIT 10;


[User] Show me currency, approval_status, seller_id for all teachers.

[Assistant] SELECT currency, approval_status, seller_id FROM education.teachers;

[User] Find teachers where seller_id LIKE 'A%'.

[Assistant] SELECT currency, approval_status, seller_id FROM education.teachers WHERE seller_id LIKE 'A%';

[User] Get the distribution of teachers across different delivery_status values.

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


[User] Display all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] Can you order these by completed_at descending?

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

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

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


[User] Display all courses.

[Assistant] SELECT * FROM education.courses;

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

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

[User] Get count of accessibility by state from courses.

[Assistant] SELECT state, COUNT(accessibility) AS count_accessibility FROM education.courses GROUP BY state;


[User] Get all courses.

[Assistant] SELECT * FROM education.courses;

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

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

[User] Show me the count of courses grouped by created_at.

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


[User] What are the currency, completed_at, seller_id of each teacher?

[Assistant] SELECT currency, completed_at, seller_id FROM education.teachers;

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

[Assistant] SELECT currency, completed_at, seller_id FROM education.teachers WHERE created_at = CURRENT_DATE - INTERVAL '1 day';

[User] Count the number of teachers in each seller_id category.

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


[User] What are the state, capacity, accessibility of each course?

[Assistant] SELECT state, capacity, accessibility FROM education.courses;

[User] Order the output by city descending.

[Assistant] SELECT state, capacity, accessibility FROM education.courses ORDER BY city DESC;

[User] Get the distribution of courses across different store_id values.

[Assistant] SELECT store_id, COUNT(*) AS count FROM education.courses GROUP BY store_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.notifications (
  barcode integer PRIMARY KEY -- unique identifier,
  published_at timestamp,
  image_url varchar,
  manufacturer char,
  metadat_id integer NOT NULL -- reference to metadata.product_id,
  FOREIGN KEY (metadat_id) REFERENCES metadata(product_id)
)

CREATE TABLE tradingplatform.metadata (
  product_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  popularity_score character varying(256),
  backorder character varying(256),
  thumbnail_url varchar,
  reserved character varying(256),
  views character varying(64) NOT NULL
)

CREATE TABLE tradingplatform.trades (
  transaction_id text PRIMARY KEY -- unique identifier,
  completed_at timestamp without time zone,
  user_id character varying(64) NOT NULL,
  approval_status text,
  delivery_status character varying(256),
  quantity text,
  notification_id integer NOT NULL -- reference to notifications.barcode,
  FOREIGN KEY (notification_id) REFERENCES notifications(barcode)
)

[User] Retrieve all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

[User] Get trades that match notification_id > 61.

[Assistant] SELECT * FROM tradingplatform.trades WHERE notification_id > 61;

[User] Get min of notification_id by delivery_status from trades.

[Assistant] SELECT delivery_status, MIN(notification_id) AS min_notification_id FROM tradingplatform.trades GROUP BY delivery_status;


[User] Display all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Retrieve notifications where manufacturer LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE manufacturer LIKE 'A%';

[User] Restrict the output to 50 items.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE manufacturer LIKE 'A%' LIMIT 50;


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

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

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

[User] Limit the results to 15 rows.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE published_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 15;


[User] List all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

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

[Assistant] SELECT * FROM tradingplatform.trades WHERE user_id LIKE 'A%';

[User] Restrict the output to 15 items.

[Assistant] SELECT * FROM tradingplatform.trades WHERE user_id LIKE 'A%' LIMIT 15;


[User] Get notification_id, delivery_status, completed_at from all trades.

[Assistant] SELECT notification_id, delivery_status, completed_at FROM tradingplatform.trades;

[User] Retrieve completed_at, notification_id, metadat_id, manufacturer showing the relationship between trades and notifications.

[Assistant] SELECT notification_id, delivery_status, completed_at, notifications.metadat_id, notifications.manufacturer FROM tradingplatform.trades JOIN tradingplatform.notifications ON trades.notification_id = notifications.barcode;

[User] Group trades by completed_at and show the max of notification_id.

[Assistant] SELECT completed_at, MAX(notification_id) AS max_notification_id FROM tradingplatform.trades GROUP BY completed_at;


[User] Retrieve all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Order the output by image_url descending.

[Assistant] SELECT * FROM tradingplatform.notifications ORDER BY image_url DESC;

[User] Show me the count of notifications grouped by manufacturer.

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


[User] Retrieve all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

[User] Show me trades that were from 2023.

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

[User] Calculate min of delivery_status for each notification_id in trades.

[Assistant] SELECT notification_id, MIN(delivery_status) AS min_delivery_status FROM tradingplatform.trades GROUP BY notification_id;


[User] Show me completed_at, delivery_status, quantity for all trades.

[Assistant] SELECT completed_at, delivery_status, quantity FROM tradingplatform.trades;

[User] Show the results sorted by approval_status descending.

[Assistant] SELECT completed_at, delivery_status, quantity FROM tradingplatform.trades ORDER BY approval_status DESC;

[User] Can you order these by approval_status ascending?

[Assistant] SELECT completed_at, delivery_status, quantity FROM tradingplatform.trades ORDER BY approval_status ASC;


[User] Retrieve all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

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

[Assistant] SELECT * FROM tradingplatform.notifications WHERE manufacturer LIKE 'A%';

[User] Show me the count of notifications grouped by metadat_id.

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


[User] Get image_url, manufacturer, published_at from all notifications.

[Assistant] SELECT image_url, manufacturer, published_at FROM tradingplatform.notifications;

[User] Find notifications from 2023.

[Assistant] SELECT image_url, manufacturer, published_at FROM tradingplatform.notifications WHERE published_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Return just 20 rows.

[Assistant] SELECT image_url, manufacturer, published_at FROM tradingplatform.notifications WHERE published_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 20;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.messages (
  id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  views char NOT NULL,
  visibility character varying(128),
  thumbnail varchar,
  user_id char,
  keywords character varying(128) NOT NULL,
  parent_id character varying(128),
  event_id text NOT NULL -- reference to events.address_id,
  FOREIGN KEY (event_id) REFERENCES events(address_id)
)

CREATE TABLE socialmedia.events (
  address_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  updated_at timestamp,
  geo_point char,
  longitude character varying(128),
  latitude char,
  address_line1 char NOT NULL,
  name character varying(64),
  message_id text NOT NULL -- reference to messages.id,
  FOREIGN KEY (message_id) REFERENCES messages(id)
)

[User] List event_id, parent_id, visibility from messages.

[Assistant] SELECT event_id, parent_id, visibility FROM socialmedia.messages;

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

[Assistant] SELECT event_id, parent_id, visibility FROM socialmedia.messages WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] What is the count views for each user_id in messages?

[Assistant] SELECT user_id, COUNT(views) AS count_views FROM socialmedia.messages GROUP BY user_id;


[User] Retrieve parent_id, keywords, updated_at for every message.

[Assistant] SELECT parent_id, keywords, updated_at FROM socialmedia.messages;

[User] Sort the results by keywords descending.

[Assistant] SELECT parent_id, keywords, updated_at FROM socialmedia.messages ORDER BY keywords DESC;

[User] Tally up messages by keywords.

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


[User] Get user_id, keywords, updated_at from all messages.

[Assistant] SELECT user_id, keywords, updated_at FROM socialmedia.messages;

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

[Assistant] SELECT user_id, keywords, updated_at FROM socialmedia.messages WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Tally up messages by keywords.

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


[User] Display all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Sort the results by address_line1 ascending.

[Assistant] SELECT * FROM socialmedia.events ORDER BY address_line1 ASC;

[User] Restrict the output to 25 items.

[Assistant] SELECT * FROM socialmedia.events ORDER BY address_line1 ASC LIMIT 25;


[User] Get created_at, name, latitude from all events.

[Assistant] SELECT created_at, name, latitude FROM socialmedia.events;

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

[Assistant] SELECT created_at, name, latitude FROM socialmedia.events WHERE name LIKE 'A%';

[User] Show me the count of events grouped by latitude.

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


[User] Retrieve parent_id, thumbnail, updated_at for every message.

[Assistant] SELECT parent_id, thumbnail, updated_at FROM socialmedia.messages;

[User] Show the results sorted by parent_id descending.

[Assistant] SELECT parent_id, thumbnail, updated_at FROM socialmedia.messages ORDER BY parent_id DESC;

[User] Restrict the output to 50 items.

[Assistant] SELECT parent_id, thumbnail, updated_at FROM socialmedia.messages ORDER BY parent_id DESC LIMIT 50;


[User] What are the message_id, created_at, address_line1 of each event?

[Assistant] SELECT message_id, created_at, address_line1 FROM socialmedia.events;

[User] Sort the results by message_id descending.

[Assistant] SELECT message_id, created_at, address_line1 FROM socialmedia.events ORDER BY message_id DESC;

[User] Restrict the output to 5 items.

[Assistant] SELECT message_id, created_at, address_line1 FROM socialmedia.events ORDER BY message_id DESC LIMIT 5;


[User] List updated_at, views, user_id from messages.

[Assistant] SELECT updated_at, views, user_id FROM socialmedia.messages;

[User] Find messages where views LIKE 'A%'.

[Assistant] SELECT updated_at, views, user_id FROM socialmedia.messages WHERE views LIKE 'A%';

[User] Return just 5 rows.

[Assistant] SELECT updated_at, views, user_id FROM socialmedia.messages WHERE views LIKE 'A%' LIMIT 5;


[User] Get geo_point, longitude, latitude from all events.

[Assistant] SELECT geo_point, longitude, latitude FROM socialmedia.events;

[User] Show me events with address_line1 LIKE 'A%'.

[Assistant] SELECT geo_point, longitude, latitude FROM socialmedia.events WHERE address_line1 LIKE 'A%';

[User] Can you order these by longitude ascending?

[Assistant] SELECT geo_point, longitude, latitude FROM socialmedia.events WHERE address_line1 LIKE 'A%' ORDER BY longitude ASC;


[User] Display all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Find messages where keywords LIKE 'A%'.

[Assistant] SELECT * FROM socialmedia.messages WHERE keywords LIKE 'A%';

[User] Order the output by updated_at ascending.

[Assistant] SELECT * FROM socialmedia.messages WHERE keywords LIKE 'A%' ORDER BY updated_at ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.notifications (
  id character varying(64) NOT NULL -- unique identifier,
  published_at date,
  reply_to_id text,
  user_id character varying(256),
  attachment_url character varying(256),
  media_url character varying(128),
  categories varchar NOT NULL,
  parent_id character varying(64) NOT NULL -- identifier for parent,
  trade_id text NOT NULL -- reference to trades.id,
  FOREIGN KEY (trade_id) REFERENCES trades(id)
)

CREATE TABLE tradingplatform.trades (
  id text PRIMARY KEY -- unique identifier,
  traded_at date,
  seller_id text NOT NULL -- identifier for seller,
  delivery_status char,
  quantity character varying(64) NOT NULL,
  subtotal smallint,
  fee character varying(64),
  account_id character varying(128) -- identifier for account
)

[User] List categories, reply_to_id, trade_id from notifications.

[Assistant] SELECT categories, reply_to_id, trade_id FROM tradingplatform.notifications;

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

[Assistant] SELECT categories, reply_to_id, trade_id FROM tradingplatform.notifications WHERE published_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Get count of categories by attachment_url from notifications.

[Assistant] SELECT attachment_url, COUNT(categories) AS count_categories FROM tradingplatform.notifications GROUP BY attachment_url;


[User] Show me all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

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

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

[User] Show me the count of notifications grouped by parent_id.

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


[User] Show me all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Show me notifications with media_url LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE media_url LIKE 'A%';

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

[Assistant] SELECT * FROM tradingplatform.notifications WHERE media_url LIKE 'A%' ORDER BY reply_to_id DESC;


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Show me notifications with media_url LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE media_url LIKE 'A%';

[User] Show only 100 records.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE media_url LIKE 'A%' LIMIT 100;


[User] Show me reply_to_id, user_id, categories for all notifications.

[Assistant] SELECT reply_to_id, user_id, categories FROM tradingplatform.notifications;

[User] Find notifications from 2023.

[Assistant] SELECT reply_to_id, user_id, categories FROM tradingplatform.notifications WHERE published_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Only show the top 25 results.

[Assistant] SELECT reply_to_id, user_id, categories FROM tradingplatform.notifications WHERE published_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 25;


[User] Retrieve all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Find notifications older than 6 months.

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

[User] Order the output by categories ascending.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE published_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY categories ASC;


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Retrieve published_at, id, fee, subtotal showing the relationship between notifications and trades.

[Assistant] SELECT *, trades.fee, trades.subtotal FROM tradingplatform.notifications JOIN tradingplatform.trades ON notifications.trade_id = trades.id;

[User] Return just 15 rows.

[Assistant] SELECT *, trades.fee, trades.subtotal FROM tradingplatform.notifications JOIN tradingplatform.trades ON notifications.trade_id = trades.id LIMIT 15;


[User] Get published_at, user_id, attachment_url from all notifications.

[Assistant] SELECT published_at, user_id, attachment_url FROM tradingplatform.notifications;

[User] Show me notifications with trade_id LIKE 'A%'.

[Assistant] SELECT published_at, user_id, attachment_url FROM tradingplatform.notifications WHERE trade_id LIKE 'A%';

[User] Limit the results to 50 rows.

[Assistant] SELECT published_at, user_id, attachment_url FROM tradingplatform.notifications WHERE trade_id LIKE 'A%' LIMIT 50;


[User] Get all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

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

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

[User] What is the max parent_id for each media_url in notifications?

[Assistant] SELECT media_url, MAX(parent_id) AS max_parent_id FROM tradingplatform.notifications GROUP BY media_url;


[User] Get all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Show me notifications with parent_id LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE parent_id LIKE 'A%';

[User] Can you order these by trade_id descending?

[Assistant] SELECT * FROM tradingplatform.notifications WHERE parent_id LIKE 'A%' ORDER BY trade_id DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.grades (
  content_id text PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  likes varchar,
  subject character varying(64),
  tags char,
  media_url character varying(256) NOT NULL,
  thumbnail character varying(64),
  enrollment_id text NOT NULL -- reference to enrollments.location_id,
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(location_id)
)

CREATE TABLE education.departments (
  venue_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  geo_point character varying(256),
  timezone character varying(256) NOT NULL,
  operating_hours character varying(64) NOT NULL,
  location_lat varchar,
  description character varying(256),
  location_lon varchar,
  enrollment_id text -- reference to enrollments.location_id,
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(location_id)
)

CREATE TABLE education.enrollments (
  location_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  last_inspected date,
  type character varying(64),
  latitude character varying(64) NOT NULL,
  name character varying(256),
  accessibility char
)

[User] Get location_lat, timezone, location_lon from all departments.

[Assistant] SELECT location_lat, timezone, location_lon FROM education.departments;

[User] Retrieve departments where enrollment_id LIKE 'A%'.

[Assistant] SELECT location_lat, timezone, location_lon FROM education.departments WHERE enrollment_id LIKE 'A%';

[User] Show only 100 records.

[Assistant] SELECT location_lat, timezone, location_lon FROM education.departments WHERE enrollment_id LIKE 'A%' LIMIT 100;


[User] Get location_lon, timezone, location_lat from all departments.

[Assistant] SELECT location_lon, timezone, location_lat FROM education.departments;

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

[Assistant] SELECT location_lon, timezone, location_lat FROM education.departments WHERE created_at > '2023-12-01';

[User] Limit the results to 20 rows.

[Assistant] SELECT location_lon, timezone, location_lat FROM education.departments WHERE created_at > '2023-12-01' LIMIT 20;


[User] Retrieve enrollment_id, subject, tags for every grade.

[Assistant] SELECT enrollment_id, subject, tags FROM education.grades;

[User] What thumbnail, tags, type, latitude do we have for grades and their associated enrollments?

[Assistant] SELECT enrollment_id, subject, tags, enrollments.type, enrollments.latitude FROM education.grades JOIN education.enrollments ON grades.enrollment_id = enrollments.location_id;

[User] Count the number of grades in each subject category.

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


[User] What are the media_url, enrollment_id, published_at of each grade?

[Assistant] SELECT media_url, enrollment_id, published_at FROM education.grades;

[User] List published_at, likes, accessibility, name for each grade along with their enrollment information.

[Assistant] SELECT media_url, enrollment_id, published_at, enrollments.accessibility, enrollments.name FROM education.grades JOIN education.enrollments ON grades.enrollment_id = enrollments.location_id;

[User] How many grades are there per enrollment_id?

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


[User] List all departments.

[Assistant] SELECT * FROM education.departments;

[User] Sort the results by created_at ascending.

[Assistant] SELECT * FROM education.departments ORDER BY created_at ASC;

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

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


[User] Get subject, likes, enrollment_id from all grades.

[Assistant] SELECT subject, likes, enrollment_id FROM education.grades;

[User] What published_at, likes, last_inspected, updated_at do we have for grades and their associated enrollments?

[Assistant] SELECT subject, likes, enrollment_id, enrollments.last_inspected, enrollments.updated_at FROM education.grades JOIN education.enrollments ON grades.enrollment_id = enrollments.location_id;

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

[Assistant] SELECT subject, likes, enrollment_id, enrollments.last_inspected, enrollments.updated_at FROM education.grades JOIN education.enrollments ON grades.enrollment_id = enrollments.location_id ORDER BY subject DESC;


[User] Show me location_lat, operating_hours, enrollment_id for all departments.

[Assistant] SELECT location_lat, operating_hours, enrollment_id FROM education.departments;

[User] Retrieve description, geo_point, last_inspected, latitude showing the relationship between departments and enrollments.

[Assistant] SELECT location_lat, operating_hours, enrollment_id, enrollments.last_inspected, enrollments.latitude FROM education.departments JOIN education.enrollments ON departments.enrollment_id = enrollments.location_id;

[User] Show me min of created_at grouped by geo_point for departments.

[Assistant] SELECT geo_point, MIN(created_at) AS min_created_at FROM education.departments GROUP BY geo_point;


[User] List all departments.

[Assistant] SELECT * FROM education.departments;

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

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

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

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


[User] Display all departments.

[Assistant] SELECT * FROM education.departments;

[User] Show the results sorted by operating_hours descending.

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

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

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


[User] Get geo_point, operating_hours, timezone from all departments.

[Assistant] SELECT geo_point, operating_hours, timezone FROM education.departments;

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

[Assistant] SELECT geo_point, operating_hours, timezone FROM education.departments WHERE geo_point LIKE 'A%';

[User] Show the results sorted by description ascending.

[Assistant] SELECT geo_point, operating_hours, timezone FROM education.departments WHERE geo_point LIKE 'A%' ORDER BY description 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 healthcare.departments (
  sku text PRIMARY KEY -- unique identifier,
  created_at date,
  image_url char,
  title character varying(256),
  name character varying(64) NOT NULL,
  featured_rank character varying(256),
  quantity char NOT NULL,
  backorder character varying(256),
  discount numeric
)

CREATE TABLE healthcare.doctors (
  venue_id character varying(64) NOT NULL -- unique identifier,
  last_inspected date,
  updated_at timestamp,
  operating_hours varchar,
  parking_available text,
  latitude char,
  location_lon varchar,
  category varchar,
  department_id text -- reference to departments.sku,
  prescription_id integer -- reference to prescriptions.product_id,
  FOREIGN KEY (department_id) REFERENCES departments(sku),
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(product_id)
)

CREATE TABLE healthcare.prescriptions (
  product_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  discount bigint NOT NULL,
  rating character varying(64),
  popularity_score char
)

[User] Retrieve last_inspected, prescription_id, department_id for every doctor.

[Assistant] SELECT last_inspected, prescription_id, department_id FROM healthcare.doctors;

[User] List doctors that have category LIKE 'A%'.

[Assistant] SELECT last_inspected, prescription_id, department_id FROM healthcare.doctors WHERE category LIKE 'A%';

[User] Limit the results to 15 rows.

[Assistant] SELECT last_inspected, prescription_id, department_id FROM healthcare.doctors WHERE category LIKE 'A%' LIMIT 15;


[User] Retrieve all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

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

[User] Return just 50 rows.

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


[User] Retrieve all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Show me doctors that were modified within the last hour.

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

[User] Sort the results by category descending.

[Assistant] SELECT * FROM healthcare.doctors WHERE last_inspected >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY category DESC;


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Get operating_hours, parking_available, quantity, name by joining doctors with departments.

[Assistant] SELECT *, departments.quantity, departments.name FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.sku;

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

[Assistant] SELECT *, departments.quantity, departments.name FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.sku ORDER BY last_inspected ASC;


[User] Get operating_hours, venue_id, last_inspected from all doctors.

[Assistant] SELECT operating_hours, venue_id, last_inspected FROM healthcare.doctors;

[User] Retrieve parking_available, venue_id, image_url, created_at showing the relationship between doctors and departments.

[Assistant] SELECT operating_hours, venue_id, last_inspected, departments.image_url, departments.created_at FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.sku;

[User] Limit the results to 50 rows.

[Assistant] SELECT operating_hours, venue_id, last_inspected, departments.image_url, departments.created_at FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.sku LIMIT 50;


[User] Show me all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Show me location_lon, updated_at, backorder, created_at from doctors and their related departments.

[Assistant] SELECT *, departments.backorder, departments.created_at FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.sku;

[User] Limit the results to 25 rows.

[Assistant] SELECT *, departments.backorder, departments.created_at FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.sku LIMIT 25;


[User] List category, department_id, parking_available from doctors.

[Assistant] SELECT category, department_id, parking_available FROM healthcare.doctors;

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

[Assistant] SELECT category, department_id, parking_available FROM healthcare.doctors ORDER BY last_inspected ASC;

[User] How many doctors are there per location_lon?

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


[User] Show me all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

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

[User] What is the max latitude for each category in doctors?

[Assistant] SELECT category, MAX(latitude) AS max_latitude FROM healthcare.doctors GROUP BY category;


[User] Show me latitude, parking_available, category for all doctors.

[Assistant] SELECT latitude, parking_available, category FROM healthcare.doctors;

[User] Get operating_hours, updated_at, quantity, discount by joining doctors with departments.

[Assistant] SELECT latitude, parking_available, category, departments.quantity, departments.discount FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.sku;

[User] Get the distribution of doctors across different category values.

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


[User] List all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] What latitude, prescription_id, backorder, created_at do we have for doctors and their associated departments?

[Assistant] SELECT *, departments.backorder, departments.created_at FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.sku;

[User] Get max of last_inspected by last_inspected from doctors.

[Assistant] SELECT last_inspected, MAX(last_inspected) AS max_last_inspected FROM healthcare.doctors GROUP BY last_inspected;


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 (
  id integer PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  processed_at timestamp,
  total integer,
  exchange_rate text,
  account_id varchar -- identifier for account,
  approval_status character varying(64) NOT NULL,
  buyer_id varchar -- identifier for buyer,
  payment_method text NOT NULL,
  currency text,
  audit_id text NOT NULL -- reference to audits.invoice_id,
  FOREIGN KEY (audit_id) REFERENCES audits(invoice_id)
)

CREATE TABLE finance.audits (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  cancelled_at date,
  amount integer,
  currency varchar,
  payment_status char,
  seller_id character varying(64) NOT NULL,
  quantity varchar
)

[User] Retrieve buyer_id, currency, audit_id for every transaction.

[Assistant] SELECT buyer_id, currency, audit_id FROM finance.transactions;

[User] Get traded_at, account_id, amount, currency by joining transactions with audits.

[Assistant] SELECT buyer_id, currency, audit_id, audits.amount, audits.currency FROM finance.transactions JOIN finance.audits ON transactions.audit_id = audits.invoice_id;

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

[Assistant] SELECT buyer_id, currency, audit_id, audits.amount, audits.currency FROM finance.transactions JOIN finance.audits ON transactions.audit_id = audits.invoice_id ORDER BY account_id DESC;


[User] Show me audit_id, traded_at, payment_method for all transactions.

[Assistant] SELECT audit_id, traded_at, payment_method FROM finance.transactions;

[User] Order the output by exchange_rate descending.

[Assistant] SELECT audit_id, traded_at, payment_method FROM finance.transactions ORDER BY exchange_rate DESC;

[User] Return just 10 rows.

[Assistant] SELECT audit_id, traded_at, payment_method FROM finance.transactions ORDER BY exchange_rate DESC LIMIT 10;


[User] Get account_id, approval_status, payment_method from all transactions.

[Assistant] SELECT account_id, approval_status, payment_method FROM finance.transactions;

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

[Assistant] SELECT account_id, approval_status, payment_method FROM finance.transactions ORDER BY audit_id ASC;

[User] Order the output by processed_at descending.

[Assistant] SELECT account_id, approval_status, payment_method FROM finance.transactions ORDER BY processed_at DESC;


[User] Get all transactions.

[Assistant] SELECT * FROM finance.transactions;

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

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

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

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


[User] Get traded_at, total, buyer_id from all transactions.

[Assistant] SELECT traded_at, total, buyer_id FROM finance.transactions;

[User] Get account_id, exchange_rate, updated_at, quantity by joining transactions with audits.

[Assistant] SELECT traded_at, total, buyer_id, audits.updated_at, audits.quantity FROM finance.transactions JOIN finance.audits ON transactions.audit_id = audits.invoice_id;

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

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


[User] Get all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Sort the results by exchange_rate ascending.

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

[User] Only show the top 25 results.

[Assistant] SELECT * FROM finance.transactions ORDER BY exchange_rate ASC LIMIT 25;


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

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

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

[User] Tally up transactions by account_id.

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


[User] Get payment_method, traded_at, audit_id from all transactions.

[Assistant] SELECT payment_method, traded_at, audit_id FROM finance.transactions;

[User] Show the results sorted by payment_method ascending.

[Assistant] SELECT payment_method, traded_at, audit_id FROM finance.transactions ORDER BY payment_method ASC;

[User] Get average of traded_at by buyer_id from transactions.

[Assistant] SELECT buyer_id, AVERAGE(traded_at) AS average_traded_at FROM finance.transactions GROUP BY buyer_id;


[User] Retrieve all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Show me processed_at, traded_at, cancelled_at, payment_status from transactions and their related audits.

[Assistant] SELECT *, audits.cancelled_at, audits.payment_status FROM finance.transactions JOIN finance.audits ON transactions.audit_id = audits.invoice_id;

[User] Sort the results by total ascending.

[Assistant] SELECT *, audits.cancelled_at, audits.payment_status FROM finance.transactions JOIN finance.audits ON transactions.audit_id = audits.invoice_id ORDER BY total ASC;


[User] Get all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Order the output by audit_id ascending.

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

[User] Limit the results to 10 rows.

[Assistant] SELECT * FROM finance.transactions ORDER BY audit_id ASC LIMIT 10;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.users (
  user_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at timestamp,
  phone text,
  bio text,
  age char,
  profile_picture_url character varying(256),
  full_name character varying(64),
  first_name char,
  comment_id text NOT NULL -- reference to comments.message_id,
  FOREIGN KEY (comment_id) REFERENCES comments(message_id)
)

CREATE TABLE socialmedia.comments (
  message_id text PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at date,
  score text,
  media_url text,
  user_id character varying(64) -- identifier for user
)

[User] Retrieve all users.

[Assistant] SELECT * FROM socialmedia.users;

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

[Assistant] SELECT * FROM socialmedia.users ORDER BY age DESC;

[User] Sort the results by phone ascending.

[Assistant] SELECT * FROM socialmedia.users ORDER BY phone ASC;


[User] Get created_at, updated_at, first_name from all users.

[Assistant] SELECT created_at, updated_at, first_name FROM socialmedia.users;

[User] Sort the results by age descending.

[Assistant] SELECT created_at, updated_at, first_name FROM socialmedia.users ORDER BY age DESC;

[User] Sort the results by created_at ascending.

[Assistant] SELECT created_at, updated_at, first_name FROM socialmedia.users ORDER BY created_at ASC;


[User] Get all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Can you order these by updated_at ascending?

[Assistant] SELECT * FROM socialmedia.users ORDER BY updated_at ASC;

[User] Show the results sorted by created_at ascending.

[Assistant] SELECT * FROM socialmedia.users ORDER BY created_at ASC;


[User] List all users.

[Assistant] SELECT * FROM socialmedia.users;

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

[Assistant] SELECT * FROM socialmedia.users WHERE profile_picture_url LIKE 'A%';

[User] Get max of first_name by updated_at from users.

[Assistant] SELECT updated_at, MAX(first_name) AS max_first_name FROM socialmedia.users GROUP BY updated_at;


[User] What are the updated_at, created_at, bio of each user?

[Assistant] SELECT updated_at, created_at, bio FROM socialmedia.users;

[User] What age, full_name, updated_at, created_at do we have for users and their associated comments?

[Assistant] SELECT updated_at, created_at, bio, comments.updated_at, comments.created_at FROM socialmedia.users JOIN socialmedia.comments ON users.comment_id = comments.message_id;

[User] Show me sum of created_at grouped by profile_picture_url for users.

[Assistant] SELECT profile_picture_url, SUM(created_at) AS sum_created_at FROM socialmedia.users GROUP BY profile_picture_url;


[User] List all users.

[Assistant] SELECT * FROM socialmedia.users;

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

[Assistant] SELECT * FROM socialmedia.users ORDER BY created_at ASC;

[User] Show only 25 records.

[Assistant] SELECT * FROM socialmedia.users ORDER BY created_at ASC LIMIT 25;


[User] Get all users.

[Assistant] SELECT * FROM socialmedia.users;

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

[Assistant] SELECT * FROM socialmedia.users WHERE comment_id LIKE 'A%';

[User] Can you order these by comment_id descending?

[Assistant] SELECT * FROM socialmedia.users WHERE comment_id LIKE 'A%' ORDER BY comment_id DESC;


[User] What are the full_name, updated_at, created_at of each user?

[Assistant] SELECT full_name, updated_at, created_at FROM socialmedia.users;

[User] Find users from last week.

[Assistant] SELECT full_name, updated_at, created_at FROM socialmedia.users WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

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

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


[User] Get age, comment_id, bio from all users.

[Assistant] SELECT age, comment_id, bio FROM socialmedia.users;

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

[Assistant] SELECT age, comment_id, bio FROM socialmedia.users WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Show me min of full_name grouped by age for users.

[Assistant] SELECT age, MIN(full_name) AS min_full_name FROM socialmedia.users GROUP BY age;


[User] Display all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Sort the results by phone descending.

[Assistant] SELECT * FROM socialmedia.users ORDER BY phone DESC;

[User] Get count of phone by comment_id from users.

[Assistant] SELECT comment_id, COUNT(phone) AS count_phone FROM socialmedia.users GROUP BY comment_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.likes (
  id character varying(64) NOT NULL -- unique identifier,
  joined_at date,
  created_at date,
  token varchar,
  membership_level char,
  nationality character varying(256),
  group_id text -- reference to groups.venue_id,
  FOREIGN KEY (group_id) REFERENCES groups(venue_id)
)

CREATE TABLE socialmedia.groups (
  venue_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  location_lon char,
  geo_point char,
  address_line2 char,
  address_line1 varchar
)

[User] Get all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Retrieve likes where nationality LIKE 'A%'.

[Assistant] SELECT * FROM socialmedia.likes WHERE nationality LIKE 'A%';

[User] Show only 5 records.

[Assistant] SELECT * FROM socialmedia.likes WHERE nationality LIKE 'A%' LIMIT 5;


[User] What are the id, nationality, token of each like?

[Assistant] SELECT id, nationality, token FROM socialmedia.likes;

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

[Assistant] SELECT id, nationality, token FROM socialmedia.likes WHERE joined_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Tally up likes by token.

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


[User] Retrieve all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Get all likes from last week.

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

[User] Show me count of created_at grouped by joined_at for likes.

[Assistant] SELECT joined_at, COUNT(created_at) AS count_created_at FROM socialmedia.likes GROUP BY joined_at;


[User] List all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] What nationality, joined_at, address_line2, location_lon do we have for likes and their associated groups?

[Assistant] SELECT *, groups.address_line2, groups.location_lon FROM socialmedia.likes JOIN socialmedia.groups ON likes.group_id = groups.venue_id;

[User] Get the distribution of likes across different group_id values.

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


[User] Retrieve all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Show the results sorted by membership_level descending.

[Assistant] SELECT * FROM socialmedia.likes ORDER BY membership_level DESC;

[User] Order the output by group_id ascending.

[Assistant] SELECT * FROM socialmedia.likes ORDER BY group_id ASC;


[User] List all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Can you order these by created_at descending?

[Assistant] SELECT * FROM socialmedia.likes ORDER BY created_at DESC;

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

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


[User] Display all likes.

[Assistant] SELECT * FROM socialmedia.likes;

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

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

[User] Restrict the output to 15 items.

[Assistant] SELECT * FROM socialmedia.likes WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 15;


[User] What are the group_id, nationality, token of each like?

[Assistant] SELECT group_id, nationality, token FROM socialmedia.likes;

[User] Retrieve token, membership_level, address_line1, geo_point showing the relationship between likes and groups.

[Assistant] SELECT group_id, nationality, token, groups.address_line1, groups.geo_point FROM socialmedia.likes JOIN socialmedia.groups ON likes.group_id = groups.venue_id;

[User] Tally up likes by token.

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


[User] Get membership_level, created_at, id from all likes.

[Assistant] SELECT membership_level, created_at, id FROM socialmedia.likes;

[User] Show the results sorted by created_at ascending.

[Assistant] SELECT membership_level, created_at, id FROM socialmedia.likes ORDER BY created_at ASC;

[User] Show the results sorted by token ascending.

[Assistant] SELECT membership_level, created_at, id FROM socialmedia.likes ORDER BY token ASC;


[User] List id, membership_level, token from likes.

[Assistant] SELECT id, membership_level, token FROM socialmedia.likes;

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

[Assistant] SELECT id, membership_level, token FROM socialmedia.likes ORDER BY group_id DESC;

[User] Sort the results by group_id ascending.

[Assistant] SELECT id, membership_level, token FROM socialmedia.likes ORDER BY group_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 education.students (
  user_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  gender character varying(128),
  birth_date timestamp,
  is_verified bit -- indicates if verified is true,
  city char,
  assignment_id text NOT NULL -- reference to assignments.invoice_id,
  FOREIGN KEY (assignment_id) REFERENCES assignments(invoice_id)
)

CREATE TABLE education.teachers (
  comment_id text PRIMARY KEY -- unique identifier,
  edited_at date,
  image_url text NOT NULL,
  thumbnail varchar NOT NULL,
  format character varying(256),
  assignment_id text NOT NULL -- reference to assignments.invoice_id,
  FOREIGN KEY (assignment_id) REFERENCES assignments(invoice_id)
)

CREATE TABLE education.assignments (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  traded_at timestamp,
  delivery_status character varying(256),
  product_id varchar,
  price decimal,
  seller_id character varying(128) NOT NULL -- identifier for seller,
  teacher_id text -- reference to teachers.comment_id,
  FOREIGN KEY (teacher_id) REFERENCES teachers(comment_id)
)

CREATE TABLE education.courses (
  item_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  stock_level text,
  views character varying(64),
  name character varying(256),
  student_id integer -- reference to students.user_id,
  assignment_id text NOT NULL -- reference to assignments.invoice_id,
  FOREIGN KEY (student_id) REFERENCES students(user_id),
  FOREIGN KEY (assignment_id) REFERENCES assignments(invoice_id)
)

[User] Retrieve all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] Order the output by image_url descending.

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

[User] Only show the top 15 results.

[Assistant] SELECT * FROM education.teachers ORDER BY image_url DESC 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 tradingplatform.notifications (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  cancelled_at timestamp without time zone,
  created_at timestamp without time zone,
  status text NOT NULL,
  total smallint NOT NULL,
  discount smallint NOT NULL,
  metadat_id text NOT NULL -- reference to metadata.transaction_id,
  FOREIGN KEY (metadat_id) REFERENCES metadata(transaction_id)
)

CREATE TABLE tradingplatform.metadata (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  payment_date timestamp,
  invoice_number character varying(64),
  reconciliation_status varchar,
  status char,
  approval_status varchar
)

[User] Show me all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

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

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

[User] Order the output by total descending.

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


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Retrieve total, created_at, invoice_number, status showing the relationship between notifications and metadata.

[Assistant] SELECT *, metadata.invoice_number, metadata.status FROM tradingplatform.notifications JOIN tradingplatform.metadata ON notifications.metadat_id = metadata.transaction_id;

[User] Tally up notifications by cancelled_at.

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


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Show me notifications with metadat_id LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE metadat_id LIKE 'A%';

[User] Show the results sorted by discount ascending.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE metadat_id LIKE 'A%' ORDER BY discount ASC;


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Show me created_at, total, approval_status, payment_date from notifications and their related metadata.

[Assistant] SELECT *, metadata.approval_status, metadata.payment_date FROM tradingplatform.notifications JOIN tradingplatform.metadata ON notifications.metadat_id = metadata.transaction_id;

[User] Order the output by discount descending.

[Assistant] SELECT *, metadata.approval_status, metadata.payment_date FROM tradingplatform.notifications JOIN tradingplatform.metadata ON notifications.metadat_id = metadata.transaction_id ORDER BY discount DESC;


[User] What are the metadat_id, cancelled_at, status of each notification?

[Assistant] SELECT metadat_id, cancelled_at, status FROM tradingplatform.notifications;

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

[Assistant] SELECT metadat_id, cancelled_at, status FROM tradingplatform.notifications WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Group notifications by cancelled_at and show the count of created_at.

[Assistant] SELECT cancelled_at, COUNT(created_at) AS count_created_at FROM tradingplatform.notifications GROUP BY cancelled_at;


[User] Retrieve created_at, metadat_id, total for every notification.

[Assistant] SELECT created_at, metadat_id, total FROM tradingplatform.notifications;

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

[Assistant] SELECT created_at, metadat_id, total FROM tradingplatform.notifications WHERE cancelled_at > '2023-12-01';

[User] Tally up notifications by discount.

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


[User] List discount, cancelled_at, created_at from notifications.

[Assistant] SELECT discount, cancelled_at, created_at FROM tradingplatform.notifications;

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

[Assistant] SELECT discount, cancelled_at, created_at FROM tradingplatform.notifications WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Count the number of notifications in each discount category.

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


[User] Get metadat_id, total, created_at from all notifications.

[Assistant] SELECT metadat_id, total, created_at FROM tradingplatform.notifications;

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

[Assistant] SELECT metadat_id, total, created_at FROM tradingplatform.notifications WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Show only 100 records.

[Assistant] SELECT metadat_id, total, created_at FROM tradingplatform.notifications WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 100;


[User] Show me all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Show the results sorted by cancelled_at descending.

[Assistant] SELECT * FROM tradingplatform.notifications ORDER BY cancelled_at DESC;

[User] Get sum of status by total from notifications.

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


[User] Retrieve cancelled_at, status, discount for every notification.

[Assistant] SELECT cancelled_at, status, discount FROM tradingplatform.notifications;

[User] Show the results sorted by created_at descending.

[Assistant] SELECT cancelled_at, status, discount FROM tradingplatform.notifications ORDER BY created_at DESC;

[User] Tally up notifications by created_at.

[Assistant] SELECT created_at, COUNT(*) AS count FROM tradingplatform.notifications 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 realestate.clients (
  user_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  username char NOT NULL,
  last_name char,
  password_hash text,
  avatar text,
  store_id text -- reference to stores.venue_id,
  FOREIGN KEY (store_id) REFERENCES stores(venue_id)
)

CREATE TABLE realestate.stores (
  venue_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  last_inspected date,
  postal_code character varying(64),
  address_line1 character varying(256) NOT NULL,
  state char NOT NULL
)

CREATE TABLE realestate.reservations (
  transaction_id text PRIMARY KEY -- unique identifier,
  cancelled_at date,
  payment_method text,
  customer_id char -- identifier for customer,
  card_type character varying(64),
  currency char,
  payment_status varchar NOT NULL,
  buyer_id character varying(256) NOT NULL -- identifier for buyer,
  status character varying(128),
  client_id integer -- reference to clients.user_id,
  FOREIGN KEY (client_id) REFERENCES clients(user_id)
)

[User] List last_name, username, password_hash from clients.

[Assistant] SELECT last_name, username, password_hash FROM realestate.clients;

[User] Can you order these by avatar descending?

[Assistant] SELECT last_name, username, password_hash FROM realestate.clients ORDER BY avatar DESC;

[User] Get sum of last_name by store_id from clients.

[Assistant] SELECT store_id, SUM(last_name) AS sum_last_name FROM realestate.clients GROUP BY store_id;


[User] Show me all reservations.

[Assistant] SELECT * FROM realestate.reservations;

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

[Assistant] SELECT * FROM realestate.reservations WHERE cancelled_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Show me the count of reservations grouped by buyer_id.

[Assistant] SELECT buyer_id, COUNT(*) AS count FROM realestate.reservations GROUP BY buyer_id ORDER BY count DESC;


[User] Retrieve all clients.

[Assistant] SELECT * FROM realestate.clients;

[User] What last_name, username, address_line1, postal_code do we have for clients and their associated stores?

[Assistant] SELECT *, stores.address_line1, stores.postal_code FROM realestate.clients JOIN realestate.stores ON clients.store_id = stores.venue_id;

[User] Group clients by store_id and show the min of username.

[Assistant] SELECT store_id, MIN(username) AS min_username FROM realestate.clients GROUP BY store_id;


[User] List username, password_hash, store_id from clients.

[Assistant] SELECT username, password_hash, store_id FROM realestate.clients;

[User] Show the results sorted by username ascending.

[Assistant] SELECT username, password_hash, store_id FROM realestate.clients ORDER BY username ASC;

[User] How many clients are there per updated_at?

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


[User] List all reservations.

[Assistant] SELECT * FROM realestate.reservations;

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

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

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

[Assistant] SELECT * FROM realestate.reservations WHERE cancelled_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY customer_id ASC;


[User] Show me username, password_hash, updated_at for all clients.

[Assistant] SELECT username, password_hash, updated_at FROM realestate.clients;

[User] What store_id, password_hash, postal_code, address_line1 do we have for clients and their associated stores?

[Assistant] SELECT username, password_hash, updated_at, stores.postal_code, stores.address_line1 FROM realestate.clients JOIN realestate.stores ON clients.store_id = stores.venue_id;

[User] Show the results sorted by password_hash ascending.

[Assistant] SELECT username, password_hash, updated_at, stores.postal_code, stores.address_line1 FROM realestate.clients JOIN realestate.stores ON clients.store_id = stores.venue_id ORDER BY password_hash ASC;


[User] Get all reservations.

[Assistant] SELECT * FROM realestate.reservations;

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

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

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

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


[User] Retrieve all clients.

[Assistant] SELECT * FROM realestate.clients;

[User] Order the output by avatar descending.

[Assistant] SELECT * FROM realestate.clients ORDER BY avatar DESC;

[User] Show me count of updated_at grouped by store_id for clients.

[Assistant] SELECT store_id, COUNT(updated_at) AS count_updated_at FROM realestate.clients GROUP BY store_id;


[User] Show me last_name, store_id, updated_at for all clients.

[Assistant] SELECT last_name, store_id, updated_at FROM realestate.clients;

[User] What last_name, password_hash, state, address_line1 do we have for clients and their associated stores?

[Assistant] SELECT last_name, store_id, updated_at, stores.state, stores.address_line1 FROM realestate.clients JOIN realestate.stores ON clients.store_id = stores.venue_id;

[User] Show me average of username grouped by last_name for clients.

[Assistant] SELECT last_name, AVERAGE(username) AS average_username FROM realestate.clients GROUP BY last_name;