[User] List customer_id, payment_date, verification_status from accounts.

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

[User] Show me transaction_id, payment_date, account_status, zip_code from accounts and their related customers.

[Assistant] SELECT customer_id, payment_date, verification_status, customers.account_status, customers.zip_code FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.employee_id;

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

[Assistant] SELECT customer_id, payment_date, verification_status, customers.account_status, customers.zip_code FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.employee_id ORDER BY verification_status 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.customers (
  id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  language character varying(256),
  profile_picture_url varchar NOT NULL,
  salt character varying(64) NOT NULL,
  status character varying(64) NOT NULL,
  bio character varying(256) NOT NULL,
  billin_id text NOT NULL -- reference to billing.invoice_id,
  review_id integer -- reference to reviews.comment_id,
  FOREIGN KEY (billin_id) REFERENCES billing(invoice_id),
  FOREIGN KEY (review_id) REFERENCES reviews(comment_id)
)

CREATE TABLE logistics.billing (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  due_date timestamp without time zone,
  reconciliation_status character varying(128) NOT NULL,
  vendor_id character varying(128) NOT NULL,
  credit character varying(128),
  description character varying(256),
  category text,
  review_id integer -- reference to reviews.comment_id,
  FOREIGN KEY (review_id) REFERENCES reviews(comment_id)
)

CREATE TABLE logistics.reviews (
  comment_id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  likes character varying(128),
  keywords character varying(64),
  text character varying(256) NOT NULL,
  format character varying(64),
  visibility char,
  body character varying(128) NOT NULL,
  billin_id text NOT NULL -- reference to billing.invoice_id,
  FOREIGN KEY (billin_id) REFERENCES billing(invoice_id)
)

[User] List all billing.

[Assistant] SELECT * FROM logistics.billing;

[User] Get credit, review_id, likes, body by joining billing with reviews.

[Assistant] SELECT *, reviews.likes, reviews.body FROM logistics.billing JOIN logistics.reviews ON billing.review_id = reviews.comment_id;

[User] How many billing are there per description?

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


[User] Retrieve due_date, description, category for every billing.

[Assistant] SELECT due_date, description, category FROM logistics.billing;

[User] Show the results sorted by credit descending.

[Assistant] SELECT due_date, description, category FROM logistics.billing ORDER BY credit DESC;

[User] Group billing by review_id and show the max of category.

[Assistant] SELECT review_id, MAX(category) AS max_category FROM logistics.billing GROUP BY review_id;


[User] Display all reviews.

[Assistant] SELECT * FROM logistics.reviews;

[User] Show the results sorted by body ascending.

[Assistant] SELECT * FROM logistics.reviews ORDER BY body ASC;

[User] What is the sum edited_at for each likes in reviews?

[Assistant] SELECT likes, SUM(edited_at) AS sum_edited_at FROM logistics.reviews GROUP BY likes;


[User] List all billing.

[Assistant] SELECT * FROM logistics.billing;

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

[Assistant] SELECT * FROM logistics.billing ORDER BY credit DESC;

[User] Limit the results to 20 rows.

[Assistant] SELECT * FROM logistics.billing ORDER BY credit DESC LIMIT 20;


[User] Show me all reviews.

[Assistant] SELECT * FROM logistics.reviews;

[User] Order the output by billin_id descending.

[Assistant] SELECT * FROM logistics.reviews ORDER BY billin_id DESC;

[User] Sort the results by likes descending.

[Assistant] SELECT * FROM logistics.reviews ORDER BY likes DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.customers (
  person_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  joined_at date,
  age char,
  timezone varchar,
  is_verified bit -- indicates if verified is true,
  account_status varchar,
  username character varying(128) NOT NULL,
  payment_id text -- reference to payments.payment_id,
  FOREIGN KEY (payment_id) REFERENCES payments(payment_id)
)

CREATE TABLE finance.payments (
  payment_id text PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  tax bigint,
  payment_method character varying(128),
  exchange_rate char,
  customer_id integer -- reference to customers.person_id,
  FOREIGN KEY (customer_id) REFERENCES customers(person_id)
)

CREATE TABLE finance.transactions (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  buyer_id varchar NOT NULL -- identifier for buyer,
  product_id character varying(256) -- identifier for product,
  currency char NOT NULL,
  approval_status character varying(64),
  payment_id text NOT NULL -- reference to payments.payment_id,
  FOREIGN KEY (payment_id) REFERENCES payments(payment_id)
)

[User] Get all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Sort the results by approval_status ascending.

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

[User] Calculate min of approval_status for each approval_status in transactions.

[Assistant] SELECT approval_status, MIN(approval_status) AS min_approval_status FROM finance.transactions GROUP BY approval_status;


[User] Show me all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Tally up customers by username.

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


[User] What are the approval_status, buyer_id, currency of each transaction?

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

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

[Assistant] SELECT approval_status, buyer_id, currency FROM finance.transactions WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Can you order these by updated_at descending?

[Assistant] SELECT approval_status, buyer_id, currency FROM finance.transactions WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY updated_at DESC;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Can you order these by payment_id ascending?

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

[User] Calculate average of username for each username in customers.

[Assistant] SELECT username, AVERAGE(username) AS average_username FROM finance.customers GROUP BY username;


[User] What are the username, timezone, joined_at of each customer?

[Assistant] SELECT username, timezone, joined_at FROM finance.customers;

[User] Can you order these by username ascending?

[Assistant] SELECT username, timezone, joined_at FROM finance.customers ORDER BY username ASC;

[User] Sort the results by account_status ascending.

[Assistant] SELECT username, timezone, joined_at FROM finance.customers ORDER BY account_status ASC;


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Order the output by payment_id ascending.

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

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

[Assistant] SELECT currency, AVERAGE(approval_status) AS average_approval_status FROM finance.transactions GROUP BY currency;


[User] Get payment_method, tax, traded_at from all payments.

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

[User] Show me traded_at, payment_method, timezone, age from payments and their related customers.

[Assistant] SELECT payment_method, tax, traded_at, customers.timezone, customers.age FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.person_id;

[User] Show only 20 records.

[Assistant] SELECT payment_method, tax, traded_at, customers.timezone, customers.age FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.person_id LIMIT 20;


[User] Display all transactions.

[Assistant] SELECT * FROM finance.transactions;

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

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

[User] Sort the results by product_id descending.

[Assistant] SELECT * FROM finance.transactions WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY product_id DESC;


[User] List all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Sort the results by payment_method descending.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.order_items (
  id character varying(64) NOT NULL -- unique identifier,
  traded_at timestamp without time zone,
  price numeric,
  payment_status text,
  user_id character varying(128) NOT NULL,
  currency character varying(128) NOT NULL,
  payment_method varchar
)

CREATE TABLE e-commerce.categories (
  address_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  category varchar,
  geo_point character varying(128) NOT NULL,
  name char,
  parking_available character varying(128) NOT NULL,
  user_id integer -- reference to users.person_id,
  FOREIGN KEY (user_id) REFERENCES users(person_id)
)

CREATE TABLE e-commerce.users (
  person_id integer PRIMARY KEY -- unique identifier,
  joined_at date,
  created_at timestamp without time zone,
  birth_date timestamp,
  token character varying(64),
  status character varying(256) NOT NULL,
  gender character varying(256),
  first_name char
)

[User] Retrieve all categories.

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

[User] Get categories that match address_id LIKE 'A%'.

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

[User] Return just 10 rows.

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


[User] Get all categories.

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

[User] Can you order these by updated_at descending?

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

[User] Calculate average of parking_available for each address_id in categories.

[Assistant] SELECT address_id, AVERAGE(parking_available) AS average_parking_available FROM e-commerce.categories GROUP BY address_id;


[User] Retrieve all categories.

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

[User] Get categories that match geo_point LIKE 'A%'.

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

[User] How many categories are there per address_id?

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


[User] Get updated_at, address_id, parking_available from all categories.

[Assistant] SELECT updated_at, address_id, parking_available FROM e-commerce.categories;

[User] Show the results sorted by user_id descending.

[Assistant] SELECT updated_at, address_id, parking_available FROM e-commerce.categories ORDER BY user_id DESC;

[User] Can you order these by updated_at ascending?

[Assistant] SELECT updated_at, address_id, parking_available FROM e-commerce.categories ORDER BY updated_at ASC;


[User] Get category, name, updated_at from all categories.

[Assistant] SELECT category, name, updated_at FROM e-commerce.categories;

[User] Show the results sorted by geo_point ascending.

[Assistant] SELECT category, name, updated_at FROM e-commerce.categories ORDER BY geo_point ASC;

[User] What is the min user_id for each user_id in categories?

[Assistant] SELECT user_id, MIN(user_id) AS min_user_id FROM e-commerce.categories GROUP BY user_id;


[User] Get parking_available, geo_point, name from all categories.

[Assistant] SELECT parking_available, geo_point, name FROM e-commerce.categories;

[User] Retrieve updated_at, category, created_at, joined_at showing the relationship between categories and users.

[Assistant] SELECT parking_available, geo_point, name, users.created_at, users.joined_at FROM e-commerce.categories JOIN e-commerce.users ON categories.user_id = users.person_id;

[User] Show the results sorted by name ascending.

[Assistant] SELECT parking_available, geo_point, name, users.created_at, users.joined_at FROM e-commerce.categories JOIN e-commerce.users ON categories.user_id = users.person_id ORDER BY name ASC;


[User] Retrieve geo_point, user_id, address_id for every categorie.

[Assistant] SELECT geo_point, user_id, address_id FROM e-commerce.categories;

[User] Find categories between January and March.

[Assistant] SELECT geo_point, user_id, address_id FROM e-commerce.categories WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Show only 10 records.

[Assistant] SELECT geo_point, user_id, address_id FROM e-commerce.categories WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 10;


[User] What are the name, updated_at, user_id of each categorie?

[Assistant] SELECT name, updated_at, user_id FROM e-commerce.categories;

[User] Order the output by user_id ascending.

[Assistant] SELECT name, updated_at, user_id FROM e-commerce.categories ORDER BY user_id ASC;

[User] How many categories are there per address_id?

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


[User] Show me category, user_id, updated_at for all categories.

[Assistant] SELECT category, user_id, updated_at FROM e-commerce.categories;

[User] List geo_point, name, gender, joined_at for each categorie along with their user information.

[Assistant] SELECT category, user_id, updated_at, users.gender, users.joined_at FROM e-commerce.categories JOIN e-commerce.users ON categories.user_id = users.person_id;

[User] Show me the count of categories grouped by name.

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


[User] Get all categories.

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

[User] Show me categories with parking_available LIKE 'A%'.

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

[User] Group categories by user_id and show the sum of category.

[Assistant] SELECT user_id, SUM(category) AS sum_category FROM e-commerce.categories GROUP BY user_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.accounts (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  updated_at timestamp without time zone,
  verification_status character varying(64) NOT NULL,
  reference_number character varying(256),
  approval_status character varying(256) NOT NULL
)

CREATE TABLE finance.transactions (
  payment_id character varying(64) NOT NULL -- unique identifier,
  processed_at timestamp without time zone,
  buyer_id character varying(128),
  currency character varying(128),
  payment_method character varying(256)
)

CREATE TABLE finance.payments (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  payment_method character varying(64),
  total smallint,
  delivery_status varchar,
  approval_status varchar,
  product_id character varying(256) -- identifier for product,
  amount bigint NOT NULL
)

[User] Get all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Order the output by updated_at descending.

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

[User] Sort the results by amount ascending.

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


[User] Get all transactions.

[Assistant] SELECT * FROM finance.transactions;

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

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

[User] Order the output by payment_id ascending.

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


[User] Retrieve all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

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

[User] Can you order these by approval_status ascending?

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


[User] List approval_status, verification_status, invoice_id from accounts.

[Assistant] SELECT approval_status, verification_status, invoice_id FROM finance.accounts;

[User] Order the output by updated_at descending.

[Assistant] SELECT approval_status, verification_status, invoice_id FROM finance.accounts ORDER BY updated_at DESC;

[User] Can you order these by updated_at descending?

[Assistant] SELECT approval_status, verification_status, invoice_id FROM finance.accounts ORDER BY updated_at DESC;


[User] Retrieve all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] List transactions that have payment_method LIKE 'A%'.

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

[User] Get min of processed_at by payment_id from transactions.

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


[User] Get all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Find transactions from 2023.

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

[User] Tally up transactions by currency.

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


[User] Show me currency, processed_at, payment_method for all transactions.

[Assistant] SELECT currency, processed_at, payment_method FROM finance.transactions;

[User] List transactions with dates from last week.

[Assistant] SELECT currency, processed_at, payment_method FROM finance.transactions WHERE processed_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Calculate count of payment_method for each currency in transactions.

[Assistant] SELECT currency, COUNT(payment_method) AS count_payment_method FROM finance.transactions GROUP BY currency;


[User] Get all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

[Assistant] SELECT * FROM finance.accounts WHERE verification_status LIKE 'A%';

[User] Calculate count of updated_at for each verification_status in accounts.

[Assistant] SELECT verification_status, COUNT(updated_at) AS count_updated_at FROM finance.accounts GROUP BY verification_status;


[User] Get verification_status, approval_status, updated_at from all accounts.

[Assistant] SELECT verification_status, approval_status, updated_at FROM finance.accounts;

[User] Sort the results by updated_at descending.

[Assistant] SELECT verification_status, approval_status, updated_at FROM finance.accounts ORDER BY updated_at DESC;

[User] Calculate min of created_at for each verification_status in accounts.

[Assistant] SELECT verification_status, MIN(created_at) AS min_created_at FROM finance.accounts GROUP BY verification_status;


[User] Show me delivery_status, transaction_id, total for all payments.

[Assistant] SELECT delivery_status, transaction_id, total FROM finance.payments;

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

[Assistant] SELECT delivery_status, transaction_id, total FROM finance.payments WHERE updated_at > '2023-01-01';

[User] Group payments by delivery_status and show the max of transaction_id.

[Assistant] SELECT delivery_status, MAX(transaction_id) AS max_transaction_id FROM finance.payments GROUP BY delivery_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 finance.payments (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  updated_at timestamp without time zone,
  currency character varying(256),
  status character varying(256),
  audit_id text -- reference to audits.id,
  FOREIGN KEY (audit_id) REFERENCES audits(id)
)

CREATE TABLE finance.accounts (
  account_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  due_date timestamp,
  description text NOT NULL,
  status character varying(256) NOT NULL,
  debit varchar,
  customer_id text NOT NULL -- identifier for customer,
  investment_id text NOT NULL -- reference to investments.customer_id,
  FOREIGN KEY (investment_id) REFERENCES investments(customer_id)
)

CREATE TABLE finance.audits (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  visibility character varying(64) NOT NULL,
  thumbnail character varying(64),
  image_url character varying(256) NOT NULL,
  likes text NOT NULL,
  author_id text NOT NULL -- identifier for author,
  parent_id character varying(256),
  payment_id text NOT NULL -- reference to payments.transaction_id,
  FOREIGN KEY (payment_id) REFERENCES payments(transaction_id)
)

CREATE TABLE finance.investments (
  customer_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  country char,
  timezone varchar NOT NULL,
  address character varying(64),
  email char,
  audit_id text NOT NULL -- reference to audits.id,
  FOREIGN KEY (audit_id) REFERENCES audits(id)
)

[User] List all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

[Assistant] SELECT * FROM finance.accounts WHERE debit LIKE 'A%';

[User] Restrict the output to 50 items.

[Assistant] SELECT * FROM finance.accounts WHERE debit LIKE 'A%' LIMIT 50;


[User] Display all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Can you order these by email ascending?

[Assistant] SELECT * FROM finance.investments ORDER BY email ASC;

[User] Can you order these by country ascending?

[Assistant] SELECT * FROM finance.investments ORDER BY country 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.orders (
  order_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  total bigint,
  discount decimal NOT NULL,
  buyer_id char NOT NULL,
  exchange_rate character varying(256) NOT NULL,
  approval_status varchar,
  log_id text -- reference to logs.comment_id,
  FOREIGN KEY (log_id) REFERENCES logs(comment_id)
)

CREATE TABLE tradingplatform.logs (
  comment_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  message text,
  author_id varchar,
  image_url character varying(256),
  shares character varying(64),
  score varchar,
  trade_id text -- reference to trades.transaction_id,
  order_id text -- reference to orders.order_id,
  FOREIGN KEY (trade_id) REFERENCES trades(transaction_id),
  FOREIGN KEY (order_id) REFERENCES orders(order_id)
)

CREATE TABLE tradingplatform.trades (
  transaction_id text PRIMARY KEY -- unique identifier,
  traded_at date,
  cancelled_at date,
  payment_method varchar,
  card_type character varying(256) NOT NULL,
  price bigint
)

[User] Get all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

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

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

[User] Show only 5 records.

[Assistant] SELECT * FROM tradingplatform.logs ORDER BY updated_at ASC LIMIT 5;


[User] List all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

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

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

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

[Assistant] SELECT * FROM tradingplatform.logs WHERE updated_at > '2023-12-01' ORDER BY updated_at DESC;


[User] List log_id, buyer_id, discount from orders.

[Assistant] SELECT log_id, buyer_id, discount FROM tradingplatform.orders;

[User] List orders that have discount > 14.

[Assistant] SELECT log_id, buyer_id, discount FROM tradingplatform.orders WHERE discount > 14;

[User] Can you order these by total descending?

[Assistant] SELECT log_id, buyer_id, discount FROM tradingplatform.orders WHERE discount > 14 ORDER BY total DESC;


[User] Show me score, trade_id, message for all logs.

[Assistant] SELECT score, trade_id, message FROM tradingplatform.logs;

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

[Assistant] SELECT score, trade_id, message FROM tradingplatform.logs WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

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

[Assistant] SELECT updated_at, COUNT(score) AS count_score FROM tradingplatform.logs GROUP BY updated_at;


[User] Get exchange_rate, buyer_id, approval_status from all orders.

[Assistant] SELECT exchange_rate, buyer_id, approval_status FROM tradingplatform.orders;

[User] Get all orders older than 6 months.

[Assistant] SELECT exchange_rate, buyer_id, approval_status FROM tradingplatform.orders WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Return just 20 rows.

[Assistant] SELECT exchange_rate, buyer_id, approval_status FROM tradingplatform.orders WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 20;


[User] Show me all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Get all orders older than 6 months.

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

[User] What is the max buyer_id for each total in orders?

[Assistant] SELECT total, MAX(buyer_id) AS max_buyer_id FROM tradingplatform.orders GROUP BY total;


[User] What are the total, discount, exchange_rate of each order?

[Assistant] SELECT total, discount, exchange_rate FROM tradingplatform.orders;

[User] Get all orders between January and March.

[Assistant] SELECT total, discount, exchange_rate FROM tradingplatform.orders WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Count the number of orders in each total category.

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


[User] Show me order_id, updated_at, trade_id for all logs.

[Assistant] SELECT order_id, updated_at, trade_id FROM tradingplatform.logs;

[User] Can you order these by order_id descending?

[Assistant] SELECT order_id, updated_at, trade_id FROM tradingplatform.logs ORDER BY order_id DESC;

[User] Order the output by trade_id ascending.

[Assistant] SELECT order_id, updated_at, trade_id FROM tradingplatform.logs ORDER BY trade_id ASC;


[User] List all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Sort the results by approval_status descending.

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

[User] Get max of log_id by exchange_rate from orders.

[Assistant] SELECT exchange_rate, MAX(log_id) AS max_log_id FROM tradingplatform.orders GROUP BY exchange_rate;


[User] List all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

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

[User] Sort the results by buyer_id ascending.

[Assistant] SELECT * FROM tradingplatform.orders WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY buyer_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.assignments (
  id varchar PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  created_at date,
  display_name char,
  avatar character varying(64),
  membership_level varchar
)

CREATE TABLE education.grades (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  due_date timestamp without time zone,
  approval_status text NOT NULL,
  notes character varying(128),
  description character varying(256),
  currency character varying(64),
  payee_id character varying(128),
  reference_number text
)

[User] Get all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Can you order these by last_active descending?

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

[User] Can you order these by avatar ascending?

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


[User] List avatar, created_at, last_active from assignments.

[Assistant] SELECT avatar, created_at, last_active FROM education.assignments;

[User] Order the output by display_name descending.

[Assistant] SELECT avatar, created_at, last_active FROM education.assignments ORDER BY display_name DESC;

[User] Sort the results by display_name descending.

[Assistant] SELECT avatar, created_at, last_active FROM education.assignments ORDER BY display_name DESC;


[User] Get last_active, created_at, avatar from all assignments.

[Assistant] SELECT last_active, created_at, avatar FROM education.assignments;

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

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

[User] Restrict the output to 5 items.

[Assistant] SELECT last_active, created_at, avatar FROM education.assignments WHERE created_at > '2023-01-01' LIMIT 5;


[User] Show me all grades.

[Assistant] SELECT * FROM education.grades;

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

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

[User] Sort the results by transaction_id ascending.

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


[User] What are the membership_level, display_name, created_at of each assignment?

[Assistant] SELECT membership_level, display_name, created_at FROM education.assignments;

[User] Can you order these by created_at ascending?

[Assistant] SELECT membership_level, display_name, created_at FROM education.assignments ORDER BY created_at ASC;

[User] Limit the results to 100 rows.

[Assistant] SELECT membership_level, display_name, created_at FROM education.assignments ORDER BY created_at ASC LIMIT 100;


[User] Get all grades.

[Assistant] SELECT * FROM education.grades;

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

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

[User] Order the output by currency descending.

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


[User] List all grades.

[Assistant] SELECT * FROM education.grades;

[User] Find grades where due_date > '2023-01-01'.

[Assistant] SELECT * FROM education.grades WHERE due_date > '2023-01-01';

[User] Show the results sorted by approval_status ascending.

[Assistant] SELECT * FROM education.grades WHERE due_date > '2023-01-01' ORDER BY approval_status ASC;


[User] Display all grades.

[Assistant] SELECT * FROM education.grades;

[User] Show me grades with notes LIKE 'A%'.

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

[User] Show only 15 records.

[Assistant] SELECT * FROM education.grades WHERE notes LIKE 'A%' LIMIT 15;


[User] List all assignments.

[Assistant] SELECT * FROM education.assignments;

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

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

[User] Return just 5 rows.

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


[User] Display all grades.

[Assistant] SELECT * FROM education.grades;

[User] List grades with dates from 2023.

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

[User] How many grades are there per notes?

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE humanresources.items (
  product_id integer PRIMARY KEY -- unique identifier,
  created_at date,
  published_at date,
  brand text NOT NULL,
  views char,
  manufacturer text,
  available character varying(64) NOT NULL,
  currency varchar NOT NULL,
  review_id integer -- reference to reviews.post_id,
  FOREIGN KEY (review_id) REFERENCES reviews(post_id)
)

CREATE TABLE humanresources.reviews (
  post_id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  score text,
  views character varying(128),
  attachment_url varchar NOT NULL,
  author_id character varying(64) -- identifier for author,
  image_url text NOT NULL,
  user_id character varying(128) -- identifier for user
)

CREATE TABLE humanresources.users (
  customer_id character varying(64) NOT NULL -- unique identifier,
  joined_at timestamp without time zone,
  timezone char,
  salt character varying(256) NOT NULL,
  email character varying(128),
  state char,
  review_id integer -- reference to reviews.post_id,
  FOREIGN KEY (review_id) REFERENCES reviews(post_id)
)

[User] Retrieve all items.

[Assistant] SELECT * FROM humanresources.items;

[User] Order the output by published_at descending.

[Assistant] SELECT * FROM humanresources.items ORDER BY published_at DESC;

[User] Return just 5 rows.

[Assistant] SELECT * FROM humanresources.items ORDER BY published_at DESC LIMIT 5;


[User] List review_id, customer_id, state from users.

[Assistant] SELECT review_id, customer_id, state FROM humanresources.users;

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

[Assistant] SELECT review_id, customer_id, state FROM humanresources.users WHERE joined_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] How many users are there per customer_id?

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


[User] List all items.

[Assistant] SELECT * FROM humanresources.items;

[User] Get review_id, published_at, user_id, views by joining items with reviews.

[Assistant] SELECT *, reviews.user_id, reviews.views FROM humanresources.items JOIN humanresources.reviews ON items.review_id = reviews.post_id;

[User] Limit the results to 5 rows.

[Assistant] SELECT *, reviews.user_id, reviews.views FROM humanresources.items JOIN humanresources.reviews ON items.review_id = reviews.post_id LIMIT 5;


[User] List all users.

[Assistant] SELECT * FROM humanresources.users;

[User] List users with dates from last week.

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

[User] Can you order these by email ascending?

[Assistant] SELECT * FROM humanresources.users WHERE joined_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY email ASC;


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

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

[User] List brand, manufacturer, author_id, user_id for each item along with their review information.

[Assistant] SELECT published_at, manufacturer, brand, reviews.author_id, reviews.user_id FROM humanresources.items JOIN humanresources.reviews ON items.review_id = reviews.post_id;

[User] Group items by review_id and show the average of manufacturer.

[Assistant] SELECT review_id, AVERAGE(manufacturer) AS average_manufacturer FROM humanresources.items GROUP BY review_id;


[User] List timezone, salt, joined_at from users.

[Assistant] SELECT timezone, salt, joined_at FROM humanresources.users;

[User] Get timezone, email, edited_at, attachment_url by joining users with reviews.

[Assistant] SELECT timezone, salt, joined_at, reviews.edited_at, reviews.attachment_url FROM humanresources.users JOIN humanresources.reviews ON users.review_id = reviews.post_id;

[User] Calculate min of joined_at for each email in users.

[Assistant] SELECT email, MIN(joined_at) AS min_joined_at FROM humanresources.users GROUP BY email;


[User] What are the salt, timezone, customer_id of each user?

[Assistant] SELECT salt, timezone, customer_id FROM humanresources.users;

[User] What review_id, salt, score, image_url do we have for users and their associated reviews?

[Assistant] SELECT salt, timezone, customer_id, reviews.score, reviews.image_url FROM humanresources.users JOIN humanresources.reviews ON users.review_id = reviews.post_id;

[User] Tally up users by review_id.

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


[User] Retrieve salt, email, state for every user.

[Assistant] SELECT salt, email, state FROM humanresources.users;

[User] Sort the results by salt ascending.

[Assistant] SELECT salt, email, state FROM humanresources.users ORDER BY salt ASC;

[User] Show only 20 records.

[Assistant] SELECT salt, email, state FROM humanresources.users ORDER BY salt ASC LIMIT 20;


[User] Get all users.

[Assistant] SELECT * FROM humanresources.users;

[User] List users with dates from 2023.

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

[User] Get min of customer_id by email from users.

[Assistant] SELECT email, MIN(customer_id) AS min_customer_id FROM humanresources.users GROUP BY email;


[User] Get all items.

[Assistant] SELECT * FROM humanresources.items;

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

[Assistant] SELECT * FROM humanresources.items ORDER BY manufacturer DESC;

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

[Assistant] SELECT available, COUNT(*) AS count FROM humanresources.items GROUP BY available 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 humanresources.venues (
  venue_id text PRIMARY KEY -- unique identifier,
  last_inspected date,
  created_at date,
  zip_code character varying(256),
  parking_available varchar,
  capacity character varying(256),
  city character varying(256),
  accessibility char NOT NULL,
  type varchar,
  transaction_id text NOT NULL -- reference to transactions.payment_id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(payment_id)
)

CREATE TABLE humanresources.merchandise (
  item_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  expires_at timestamp without time zone,
  price numeric,
  title character varying(128),
  name character varying(128),
  subcategory character varying(128) NOT NULL,
  venue_id text -- reference to venues.venue_id,
  FOREIGN KEY (venue_id) REFERENCES venues(venue_id)
)

CREATE TABLE humanresources.transactions (
  payment_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  processed_at timestamp without time zone,
  buyer_id char,
  product_id char NOT NULL,
  price bigint NOT NULL,
  account_id character varying(64) NOT NULL -- identifier for account,
  card_type character varying(128),
  tax smallint NOT NULL,
  discount bigint NOT NULL,
  merchandis_id text NOT NULL -- reference to merchandise.item_id,
  FOREIGN KEY (merchandis_id) REFERENCES merchandise(item_id)
)

[User] Show me all merchandise.

[Assistant] SELECT * FROM humanresources.merchandise;

[User] Find merchandise between January and March.

[Assistant] SELECT * FROM humanresources.merchandise WHERE expires_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Only show the top 5 results.

[Assistant] SELECT * FROM humanresources.merchandise WHERE expires_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 5;


[User] Retrieve all transactions.

[Assistant] SELECT * FROM humanresources.transactions;

[User] Find transactions from 2023.

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

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

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


[User] List all merchandise.

[Assistant] SELECT * FROM humanresources.merchandise;

[User] List merchandise with dates from 2023.

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

[User] Get the distribution of merchandise across different name values.

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


[User] Display all venues.

[Assistant] SELECT * FROM humanresources.venues;

[User] Can you order these by zip_code descending?

[Assistant] SELECT * FROM humanresources.venues ORDER BY zip_code DESC;

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

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


[User] Retrieve all venues.

[Assistant] SELECT * FROM humanresources.venues;

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

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

[User] Limit the results to 5 rows.

[Assistant] SELECT * FROM humanresources.venues WHERE last_inspected > '2023-12-01' LIMIT 5;


[User] Display all merchandise.

[Assistant] SELECT * FROM humanresources.merchandise;

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

[Assistant] SELECT * FROM humanresources.merchandise ORDER BY price ASC;

[User] Only show the top 50 results.

[Assistant] SELECT * FROM humanresources.merchandise ORDER BY price ASC LIMIT 50;


[User] What are the price, tax, processed_at of each transaction?

[Assistant] SELECT price, tax, processed_at FROM humanresources.transactions;

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

[Assistant] SELECT price, tax, processed_at FROM humanresources.transactions WHERE card_type LIKE 'A%';

[User] How many transactions are there per processed_at?

[Assistant] SELECT processed_at, COUNT(*) AS count FROM humanresources.transactions GROUP BY processed_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 tradingplatform.logs (
  post_id text PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  description varchar,
  keywords character varying(256) NOT NULL,
  author_id character varying(256) -- identifier for author,
  thumbnail character varying(64) NOT NULL,
  asset_id integer -- reference to assets.item_id,
  FOREIGN KEY (asset_id) REFERENCES assets(item_id)
)

CREATE TABLE tradingplatform.assets (
  item_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  expires_at timestamp,
  popularity_score text,
  views text NOT NULL,
  backorder character varying(128),
  image_url varchar
)

CREATE TABLE tradingplatform.wallets (
  id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  due_date timestamp without time zone,
  payer_id character varying(64),
  customer_id character varying(256) NOT NULL,
  notes character varying(256),
  description char,
  approval_status char,
  asset_id integer -- reference to assets.item_id,
  FOREIGN KEY (asset_id) REFERENCES assets(item_id)
)

[User] Show me keywords, description, published_at for all logs.

[Assistant] SELECT keywords, description, published_at FROM tradingplatform.logs;

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

[Assistant] SELECT keywords, description, published_at FROM tradingplatform.logs ORDER BY published_at DESC;

[User] Group logs by author_id and show the count of keywords.

[Assistant] SELECT author_id, COUNT(keywords) AS count_keywords FROM tradingplatform.logs GROUP BY author_id;


[User] Retrieve all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Show the results sorted by description descending.

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

[User] Only show the top 5 results.

[Assistant] SELECT * FROM tradingplatform.logs ORDER BY description DESC LIMIT 5;


[User] Get all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

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

[Assistant] SELECT * FROM tradingplatform.logs WHERE description LIKE 'A%';

[User] Show me average of asset_id grouped by thumbnail for logs.

[Assistant] SELECT thumbnail, AVERAGE(asset_id) AS average_asset_id FROM tradingplatform.logs GROUP BY thumbnail;


[User] Show me all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Order the output by due_date descending.

[Assistant] SELECT * FROM tradingplatform.wallets ORDER BY due_date DESC;

[User] Show me average of created_at grouped by description for wallets.

[Assistant] SELECT description, AVERAGE(created_at) AS average_created_at FROM tradingplatform.wallets GROUP BY description;


[User] Get id, due_date, asset_id from all wallets.

[Assistant] SELECT id, due_date, asset_id FROM tradingplatform.wallets;

[User] Get all wallets from last week.

[Assistant] SELECT id, due_date, asset_id FROM tradingplatform.wallets WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Show only 10 records.

[Assistant] SELECT id, due_date, asset_id FROM tradingplatform.wallets WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 10;


[User] Get notes, customer_id, id from all wallets.

[Assistant] SELECT notes, customer_id, id FROM tradingplatform.wallets;

[User] Sort the results by payer_id ascending.

[Assistant] SELECT notes, customer_id, id FROM tradingplatform.wallets ORDER BY payer_id ASC;

[User] Return just 100 rows.

[Assistant] SELECT notes, customer_id, id FROM tradingplatform.wallets ORDER BY payer_id ASC LIMIT 100;


[User] List all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Get customer_id, id, image_url, created_at by joining wallets with assets.

[Assistant] SELECT *, assets.image_url, assets.created_at FROM tradingplatform.wallets JOIN tradingplatform.assets ON wallets.asset_id = assets.item_id;

[User] Show the results sorted by due_date ascending.

[Assistant] SELECT *, assets.image_url, assets.created_at FROM tradingplatform.wallets JOIN tradingplatform.assets ON wallets.asset_id = assets.item_id ORDER BY due_date ASC;


[User] Show me all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

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

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

[User] Show the results sorted by published_at ascending.

[Assistant] SELECT * FROM tradingplatform.logs WHERE published_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY published_at ASC;


[User] Display all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Find wallets where id LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.wallets WHERE id LIKE 'A%';

[User] Show me sum of payer_id grouped by notes for wallets.

[Assistant] SELECT notes, SUM(payer_id) AS sum_payer_id FROM tradingplatform.wallets GROUP BY notes;


[User] List all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

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

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

[User] Group logs by description and show the count of asset_id.

[Assistant] SELECT description, COUNT(asset_id) AS count_asset_id FROM tradingplatform.logs GROUP BY description;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.orders (
  order_id integer PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  seller_id text -- identifier for seller,
  approval_status character varying(256),
  payment_method character varying(256),
  card_type character varying(256),
  buyer_id text NOT NULL,
  wallet_id text -- reference to wallets.transaction_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(transaction_id)
)

CREATE TABLE tradingplatform.wallets (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  due_date timestamp,
  payee_id character varying(256) -- identifier for payee,
  invoice_number character varying(64),
  balance numeric(38,14) NOT NULL,
  order_id integer -- reference to orders.order_id,
  FOREIGN KEY (order_id) REFERENCES orders(order_id)
)

[User] Show me all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Sort the results by wallet_id descending.

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

[User] Only show the top 20 results.

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY wallet_id DESC LIMIT 20;


[User] Display all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

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

[User] What is the count wallet_id for each buyer_id in orders?

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


[User] Get buyer_id, seller_id, payment_method from all orders.

[Assistant] SELECT buyer_id, seller_id, payment_method FROM tradingplatform.orders;

[User] List buyer_id, traded_at, payee_id, invoice_number for each order along with their wallet information.

[Assistant] SELECT buyer_id, seller_id, payment_method, wallets.payee_id, wallets.invoice_number FROM tradingplatform.orders JOIN tradingplatform.wallets ON orders.wallet_id = wallets.transaction_id;

[User] Restrict the output to 5 items.

[Assistant] SELECT buyer_id, seller_id, payment_method, wallets.payee_id, wallets.invoice_number FROM tradingplatform.orders JOIN tradingplatform.wallets ON orders.wallet_id = wallets.transaction_id LIMIT 5;


[User] List all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

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

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

[User] Count the number of wallets in each invoice_number category.

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


[User] Retrieve all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Get wallets that match payee_id LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.wallets WHERE payee_id LIKE 'A%';

[User] Return just 5 rows.

[Assistant] SELECT * FROM tradingplatform.wallets WHERE payee_id LIKE 'A%' LIMIT 5;


[User] Get all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Order the output by wallet_id descending.

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

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY wallet_id DESC LIMIT 10;


[User] Show me buyer_id, traded_at, payment_method for all orders.

[Assistant] SELECT buyer_id, traded_at, payment_method FROM tradingplatform.orders;

[User] What card_type, payment_method, due_date, balance do we have for orders and their associated wallets?

[Assistant] SELECT buyer_id, traded_at, payment_method, wallets.due_date, wallets.balance FROM tradingplatform.orders JOIN tradingplatform.wallets ON orders.wallet_id = wallets.transaction_id;

[User] Sort the results by seller_id descending.

[Assistant] SELECT buyer_id, traded_at, payment_method, wallets.due_date, wallets.balance FROM tradingplatform.orders JOIN tradingplatform.wallets ON orders.wallet_id = wallets.transaction_id ORDER BY seller_id DESC;


[User] Display all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Order the output by balance ascending.

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

[User] Show the results sorted by payee_id descending.

[Assistant] SELECT * FROM tradingplatform.wallets ORDER BY payee_id DESC;


[User] List all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Sort the results by invoice_number ascending.

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

[User] Count the number of wallets in each invoice_number category.

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


[User] Display all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

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

[User] Return just 25 rows.

[Assistant] SELECT * FROM tradingplatform.orders WHERE buyer_id LIKE 'A%' 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 socialmedia.posts (
  comment_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  author_id varchar,
  parent_id text,
  format text,
  user_id text -- identifier for user,
  rating text NOT NULL,
  event_id text NOT NULL -- reference to events.store_id,
  FOREIGN KEY (event_id) REFERENCES events(store_id)
)

CREATE TABLE socialmedia.likes (
  comment_id varchar PRIMARY KEY -- unique identifier,
  edited_at date,
  updated_at timestamp,
  shares character varying(64),
  author_id character varying(256),
  rating text,
  media_url varchar,
  keywords varchar NOT NULL,
  post_id text -- reference to posts.comment_id,
  FOREIGN KEY (post_id) REFERENCES posts(comment_id)
)

CREATE TABLE socialmedia.events (
  store_id text PRIMARY KEY -- unique identifier,
  last_inspected timestamp without time zone,
  updated_at date,
  location_lat character varying(256),
  location_lon text NOT NULL,
  name character varying(128) NOT NULL,
  postal_code char NOT NULL
)

CREATE TABLE socialmedia.users (
  person_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  birth_date date NOT NULL,
  last_name text,
  first_name character varying(128)
)

[User] Get all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Show the results sorted by media_url ascending.

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

[User] Calculate max of rating for each updated_at in likes.

[Assistant] SELECT updated_at, MAX(rating) AS max_rating FROM socialmedia.likes GROUP BY updated_at;


[User] Show me all likes.

[Assistant] SELECT * FROM socialmedia.likes;

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

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

[User] Show me sum of media_url grouped by edited_at for likes.

[Assistant] SELECT edited_at, SUM(media_url) AS sum_media_url FROM socialmedia.likes GROUP BY edited_at;


[User] Retrieve all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] Order the output by user_id ascending.

[Assistant] SELECT * FROM socialmedia.posts ORDER BY user_id ASC;

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

[Assistant] SELECT * FROM socialmedia.posts ORDER BY parent_id DESC;


[User] Retrieve updated_at, author_id, media_url for every like.

[Assistant] SELECT updated_at, author_id, media_url FROM socialmedia.likes;

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

[Assistant] SELECT updated_at, author_id, media_url FROM socialmedia.likes WHERE media_url LIKE 'A%';

[User] Return just 50 rows.

[Assistant] SELECT updated_at, author_id, media_url FROM socialmedia.likes WHERE media_url LIKE 'A%' LIMIT 50;


[User] List all posts.

[Assistant] SELECT * FROM socialmedia.posts;

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

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

[User] Limit the results to 50 rows.

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


[User] Get format, author_id, rating from all posts.

[Assistant] SELECT format, author_id, rating FROM socialmedia.posts;

[User] Get parent_id, rating, postal_code, updated_at by joining posts with events.

[Assistant] SELECT format, author_id, rating, events.postal_code, events.updated_at FROM socialmedia.posts JOIN socialmedia.events ON posts.event_id = events.store_id;

[User] Only show the top 20 results.

[Assistant] SELECT format, author_id, rating, events.postal_code, events.updated_at FROM socialmedia.posts JOIN socialmedia.events ON posts.event_id = events.store_id LIMIT 20;


[User] List updated_at, author_id, edited_at from likes.

[Assistant] SELECT updated_at, author_id, edited_at FROM socialmedia.likes;

[User] Find likes between January and March.

[Assistant] SELECT updated_at, author_id, edited_at FROM socialmedia.likes WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

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

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


[User] What are the format, created_at, rating of each post?

[Assistant] SELECT format, created_at, rating FROM socialmedia.posts;

[User] Order the output by event_id ascending.

[Assistant] SELECT format, created_at, rating FROM socialmedia.posts ORDER BY event_id ASC;

[User] Show the results sorted by created_at descending.

[Assistant] SELECT format, created_at, rating FROM socialmedia.posts ORDER BY created_at DESC;


[User] List parent_id, author_id, event_id from posts.

[Assistant] SELECT parent_id, author_id, event_id FROM socialmedia.posts;

[User] Find posts from last week.

[Assistant] SELECT parent_id, author_id, event_id FROM socialmedia.posts WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Only show the top 10 results.

[Assistant] SELECT parent_id, author_id, event_id FROM socialmedia.posts WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 10;


[User] Show me all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Show me likes with shares LIKE 'A%'.

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

[User] Show me the count of likes grouped by updated_at.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.products (
  id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  manufacturer text NOT NULL,
  featured_rank text NOT NULL,
  reserved character varying(256),
  tax_rate varchar,
  price smallint,
  review_id integer NOT NULL -- reference to reviews.content_id,
  order_item_id text -- reference to order_items.user_id,
  FOREIGN KEY (review_id) REFERENCES reviews(content_id),
  FOREIGN KEY (order_item_id) REFERENCES order_items(user_id)
)

CREATE TABLE e-commerce.order_items (
  user_id text PRIMARY KEY -- unique identifier,
  last_active date,
  display_name character varying(256),
  last_name character varying(64) NOT NULL,
  age character varying(256),
  country char,
  product_id text NOT NULL -- reference to products.id,
  FOREIGN KEY (product_id) REFERENCES products(id)
)

CREATE TABLE e-commerce.reviews (
  content_id integer PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  edited_at timestamp without time zone,
  rating text,
  reply_to_id varchar NOT NULL,
  media_url varchar,
  format text NOT NULL,
  keywords character varying(256) NOT NULL,
  user_id character varying(64),
  views varchar
)

[User] Display all order_items.

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

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

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

[User] How many order_items are there per last_name?

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


[User] Get all products.

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

[User] Show the results sorted by manufacturer descending.

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

[User] Show me the count of products grouped by featured_rank.

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


[User] Retrieve all order_items.

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

[User] Show the results sorted by display_name ascending.

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

[User] Order the output by last_active descending.

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


[User] Retrieve all order_items.

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

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

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

[User] Show me average of last_active grouped by country for order_items.

[Assistant] SELECT country, AVERAGE(last_active) AS average_last_active FROM e-commerce.order_items GROUP BY country;


[User] Display all products.

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

[User] Retrieve review_id, order_item_id, published_at, format showing the relationship between products and reviews.

[Assistant] SELECT *, reviews.published_at, reviews.format FROM e-commerce.products JOIN e-commerce.reviews ON products.review_id = reviews.content_id;

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

[Assistant] SELECT *, reviews.published_at, reviews.format FROM e-commerce.products JOIN e-commerce.reviews ON products.review_id = reviews.content_id ORDER BY featured_rank ASC;


[User] List all order_items.

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

[User] Get display_name, age, published_at, tax_rate by joining order_items with products.

[Assistant] SELECT *, products.published_at, products.tax_rate FROM e-commerce.order_items JOIN e-commerce.products ON order_items.product_id = products.id;

[User] Get the distribution of order_items across different age values.

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


[User] Retrieve all order_items.

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

[User] Show me product_id, last_name, price, featured_rank from order_items and their related products.

[Assistant] SELECT *, products.price, products.featured_rank FROM e-commerce.order_items JOIN e-commerce.products ON order_items.product_id = products.id;

[User] Order the output by last_name ascending.

[Assistant] SELECT *, products.price, products.featured_rank FROM e-commerce.order_items JOIN e-commerce.products ON order_items.product_id = products.id ORDER BY last_name ASC;


[User] List all order_items.

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

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

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

[User] Return just 10 rows.

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


[User] Get all products.

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

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

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

[User] Tally up products by published_at.

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


[User] List all order_items.

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

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

[Assistant] SELECT * FROM e-commerce.order_items WHERE last_active >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] What is the average age for each last_active in order_items?

[Assistant] SELECT last_active, AVERAGE(age) AS average_age FROM e-commerce.order_items GROUP BY last_active;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.enrollments (
  invoice_id text PRIMARY KEY -- unique identifier,
  completed_at timestamp,
  tax decimal,
  account_id character varying(128) NOT NULL,
  payment_status character varying(64) NOT NULL,
  grade_id text NOT NULL -- reference to grades.product_id,
  FOREIGN KEY (grade_id) REFERENCES grades(product_id)
)

CREATE TABLE education.grades (
  product_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  image_url character varying(64) NOT NULL,
  discount decimal,
  reserved character varying(64)
)

[User] List account_id, payment_status, grade_id from enrollments.

[Assistant] SELECT account_id, payment_status, grade_id FROM education.enrollments;

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

[Assistant] SELECT account_id, payment_status, grade_id FROM education.enrollments WHERE completed_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Show me min of grade_id grouped by grade_id for enrollments.

[Assistant] SELECT grade_id, MIN(grade_id) AS min_grade_id FROM education.enrollments GROUP BY grade_id;


[User] List all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Get all enrollments created yesterday.

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

[User] Return just 10 rows.

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


[User] List completed_at, tax, payment_status from enrollments.

[Assistant] SELECT completed_at, tax, payment_status FROM education.enrollments;

[User] Get all enrollments older than 6 months.

[Assistant] SELECT completed_at, tax, payment_status FROM education.enrollments WHERE completed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Sort the results by payment_status descending.

[Assistant] SELECT completed_at, tax, payment_status FROM education.enrollments WHERE completed_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY payment_status DESC;


[User] List all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Show the results sorted by account_id ascending.

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

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

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


[User] List all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Retrieve tax, completed_at, image_url, reserved showing the relationship between enrollments and grades.

[Assistant] SELECT *, grades.image_url, grades.reserved FROM education.enrollments JOIN education.grades ON enrollments.grade_id = grades.product_id;

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

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


[User] Show me account_id, grade_id, tax for all enrollments.

[Assistant] SELECT account_id, grade_id, tax FROM education.enrollments;

[User] Get payment_status, grade_id, reserved, discount by joining enrollments with grades.

[Assistant] SELECT account_id, grade_id, tax, grades.reserved, grades.discount FROM education.enrollments JOIN education.grades ON enrollments.grade_id = grades.product_id;

[User] Calculate count of tax for each tax in enrollments.

[Assistant] SELECT tax, COUNT(tax) AS count_tax FROM education.enrollments GROUP BY tax;


[User] List tax, payment_status, grade_id from enrollments.

[Assistant] SELECT tax, payment_status, grade_id FROM education.enrollments;

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

[Assistant] SELECT tax, payment_status, grade_id FROM education.enrollments WHERE completed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Only show the top 15 results.

[Assistant] SELECT tax, payment_status, grade_id FROM education.enrollments WHERE completed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 15;


[User] Retrieve payment_status, grade_id, tax for every enrollment.

[Assistant] SELECT payment_status, grade_id, tax FROM education.enrollments;

[User] Sort the results by payment_status ascending.

[Assistant] SELECT payment_status, grade_id, tax FROM education.enrollments ORDER BY payment_status ASC;

[User] Restrict the output to 50 items.

[Assistant] SELECT payment_status, grade_id, tax FROM education.enrollments ORDER BY payment_status ASC LIMIT 50;


[User] Get completed_at, grade_id, tax from all enrollments.

[Assistant] SELECT completed_at, grade_id, tax FROM education.enrollments;

[User] Show me completed_at, tax, discount, image_url from enrollments and their related grades.

[Assistant] SELECT completed_at, grade_id, tax, grades.discount, grades.image_url FROM education.enrollments JOIN education.grades ON enrollments.grade_id = grades.product_id;

[User] Return just 100 rows.

[Assistant] SELECT completed_at, grade_id, tax, grades.discount, grades.image_url FROM education.enrollments JOIN education.grades ON enrollments.grade_id = grades.product_id LIMIT 100;


[User] Get all enrollments.

[Assistant] SELECT * FROM education.enrollments;

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

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

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

[Assistant] SELECT * FROM education.enrollments WHERE completed_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY account_id ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE government.items (
  sku integer PRIMARY KEY -- unique identifier,
  expires_at timestamp,
  description char,
  category char,
  views character varying(256),
  facilitie_id text -- reference to facilities.location_id,
  FOREIGN KEY (facilitie_id) REFERENCES facilities(location_id)
)

CREATE TABLE government.facilities (
  location_id varchar PRIMARY KEY -- unique identifier,
  last_inspected date,
  longitude varchar NOT NULL,
  capacity varchar,
  street varchar,
  address_line1 character varying(64)
)

[User] Retrieve all items.

[Assistant] SELECT * FROM government.items;

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

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

[User] Limit the results to 50 rows.

[Assistant] SELECT * FROM government.items WHERE expires_at > '2023-12-01' LIMIT 50;


[User] Show me views, facilitie_id, category for all items.

[Assistant] SELECT views, facilitie_id, category FROM government.items;

[User] Show the results sorted by category ascending.

[Assistant] SELECT views, facilitie_id, category FROM government.items ORDER BY category ASC;

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

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


[User] Retrieve all items.

[Assistant] SELECT * FROM government.items;

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

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

[User] Get count of facilitie_id by description from items.

[Assistant] SELECT description, COUNT(facilitie_id) AS count_facilitie_id FROM government.items GROUP BY description;


[User] Retrieve all items.

[Assistant] SELECT * FROM government.items;

[User] Show the results sorted by category descending.

[Assistant] SELECT * FROM government.items ORDER BY category DESC;

[User] Restrict the output to 100 items.

[Assistant] SELECT * FROM government.items ORDER BY category DESC LIMIT 100;


[User] Show me facilitie_id, description, views for all items.

[Assistant] SELECT facilitie_id, description, views FROM government.items;

[User] What description, expires_at, address_line1, capacity do we have for items and their associated facilities?

[Assistant] SELECT facilitie_id, description, views, facilities.address_line1, facilities.capacity FROM government.items JOIN government.facilities ON items.facilitie_id = facilities.location_id;

[User] How many items are there per facilitie_id?

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


[User] Show me description, facilitie_id, category for all items.

[Assistant] SELECT description, facilitie_id, category FROM government.items;

[User] Retrieve description, facilitie_id, address_line1, last_inspected showing the relationship between items and facilities.

[Assistant] SELECT description, facilitie_id, category, facilities.address_line1, facilities.last_inspected FROM government.items JOIN government.facilities ON items.facilitie_id = facilities.location_id;

[User] Order the output by category ascending.

[Assistant] SELECT description, facilitie_id, category, facilities.address_line1, facilities.last_inspected FROM government.items JOIN government.facilities ON items.facilitie_id = facilities.location_id ORDER BY category ASC;


[User] List all items.

[Assistant] SELECT * FROM government.items;

[User] Find items modified within the last hour.

[Assistant] SELECT * FROM government.items WHERE expires_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Show me min of facilitie_id grouped by expires_at for items.

[Assistant] SELECT expires_at, MIN(facilitie_id) AS min_facilitie_id FROM government.items GROUP BY expires_at;


[User] List facilitie_id, description, expires_at from items.

[Assistant] SELECT facilitie_id, description, expires_at FROM government.items;

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

[Assistant] SELECT facilitie_id, description, expires_at FROM government.items WHERE category LIKE 'A%';

[User] Sort the results by category ascending.

[Assistant] SELECT facilitie_id, description, expires_at FROM government.items WHERE category LIKE 'A%' ORDER BY category ASC;


[User] Show me all items.

[Assistant] SELECT * FROM government.items;

[User] Can you order these by description descending?

[Assistant] SELECT * FROM government.items ORDER BY description DESC;

[User] Show the results sorted by views descending.

[Assistant] SELECT * FROM government.items ORDER BY views DESC;


[User] Show me description, facilitie_id, category for all items.

[Assistant] SELECT description, facilitie_id, category FROM government.items;

[User] What description, views, street, last_inspected do we have for items and their associated facilities?

[Assistant] SELECT description, facilitie_id, category, facilities.street, facilities.last_inspected FROM government.items JOIN government.facilities ON items.facilitie_id = facilities.location_id;

[User] Order the output by category descending.

[Assistant] SELECT description, facilitie_id, category, facilities.street, facilities.last_inspected FROM government.items JOIN government.facilities ON items.facilitie_id = facilities.location_id ORDER BY category 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 (
  invoice_id integer PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  processed_at date,
  customer_id character varying(64),
  delivery_status character varying(64),
  payment_status character varying(64)
)

CREATE TABLE tradingplatform.wallets (
  id character varying(64) NOT NULL -- unique identifier,
  due_date date,
  customer_id text -- identifier for customer,
  verification_status varchar NOT NULL,
  debit character varying(128),
  payer_id character varying(128),
  notification_id integer -- reference to notifications.invoice_id,
  FOREIGN KEY (notification_id) REFERENCES notifications(invoice_id)
)

[User] Get verification_status, payer_id, notification_id from all wallets.

[Assistant] SELECT verification_status, payer_id, notification_id FROM tradingplatform.wallets;

[User] Find wallets where notification_id > 70.

[Assistant] SELECT verification_status, payer_id, notification_id FROM tradingplatform.wallets WHERE notification_id > 70;

[User] Limit the results to 50 rows.

[Assistant] SELECT verification_status, payer_id, notification_id FROM tradingplatform.wallets WHERE notification_id > 70 LIMIT 50;


[User] Get all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Find wallets where due_date > '2023-01-01'.

[Assistant] SELECT * FROM tradingplatform.wallets WHERE due_date > '2023-01-01';

[User] Limit the results to 20 rows.

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


[User] Show me all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Can you order these by debit ascending?

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

[User] Count the number of wallets in each due_date category.

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


[User] List verification_status, id, due_date from wallets.

[Assistant] SELECT verification_status, id, due_date FROM tradingplatform.wallets;

[User] Order the output by id descending.

[Assistant] SELECT verification_status, id, due_date FROM tradingplatform.wallets ORDER BY id DESC;

[User] Group wallets by notification_id and show the count of due_date.

[Assistant] SELECT notification_id, COUNT(due_date) AS count_due_date FROM tradingplatform.wallets GROUP BY notification_id;


[User] What are the payer_id, id, due_date of each wallet?

[Assistant] SELECT payer_id, id, due_date FROM tradingplatform.wallets;

[User] List wallets that have notification_id > 60.

[Assistant] SELECT payer_id, id, due_date FROM tradingplatform.wallets WHERE notification_id > 60;

[User] Sort the results by customer_id ascending.

[Assistant] SELECT payer_id, id, due_date FROM tradingplatform.wallets WHERE notification_id > 60 ORDER BY customer_id ASC;


[User] What are the customer_id, id, payer_id of each wallet?

[Assistant] SELECT customer_id, id, payer_id FROM tradingplatform.wallets;

[User] Find wallets modified within the last hour.

[Assistant] SELECT customer_id, id, payer_id FROM tradingplatform.wallets WHERE due_date >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] What is the sum due_date for each id in wallets?

[Assistant] SELECT id, SUM(due_date) AS sum_due_date FROM tradingplatform.wallets GROUP BY id;


[User] Retrieve verification_status, payer_id, id for every wallet.

[Assistant] SELECT verification_status, payer_id, id FROM tradingplatform.wallets;

[User] List wallets that have id LIKE 'A%'.

[Assistant] SELECT verification_status, payer_id, id FROM tradingplatform.wallets WHERE id LIKE 'A%';

[User] Get average of payer_id by id from wallets.

[Assistant] SELECT id, AVERAGE(payer_id) AS average_payer_id FROM tradingplatform.wallets GROUP BY id;


[User] Get all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

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

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

[User] Show me average of payer_id grouped by debit for wallets.

[Assistant] SELECT debit, AVERAGE(payer_id) AS average_payer_id FROM tradingplatform.wallets GROUP BY debit;


[User] Show me debit, customer_id, due_date for all wallets.

[Assistant] SELECT debit, customer_id, due_date FROM tradingplatform.wallets;

[User] What id, verification_status, processed_at, payment_status do we have for wallets and their associated notifications?

[Assistant] SELECT debit, customer_id, due_date, notifications.processed_at, notifications.payment_status FROM tradingplatform.wallets JOIN tradingplatform.notifications ON wallets.notification_id = notifications.invoice_id;

[User] Calculate sum of customer_id for each payer_id in wallets.

[Assistant] SELECT payer_id, SUM(customer_id) AS sum_customer_id FROM tradingplatform.wallets GROUP BY payer_id;


[User] List all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Retrieve payer_id, debit, customer_id, traded_at showing the relationship between wallets and notifications.

[Assistant] SELECT *, notifications.customer_id, notifications.traded_at FROM tradingplatform.wallets JOIN tradingplatform.notifications ON wallets.notification_id = notifications.invoice_id;

[User] How many wallets are there per debit?

[Assistant] SELECT debit, COUNT(*) AS count FROM tradingplatform.wallets GROUP BY debit 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.departments (
  account_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  reference_number character varying(64),
  status text,
  approval_status character varying(64),
  vendor_id char -- identifier for vendor,
  reconciliation_status char NOT NULL,
  course_id text -- reference to courses.id,
  FOREIGN KEY (course_id) REFERENCES courses(id)
)

CREATE TABLE education.courses (
  id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at date,
  payer_id char -- identifier for payer,
  invoice_number character varying(64),
  notes varchar NOT NULL,
  customer_id text NOT NULL -- identifier for customer,
  reconciliation_status character varying(128),
  approval_status text NOT NULL
)

CREATE TABLE education.grades (
  transaction_id integer PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  completed_at timestamp without time zone,
  seller_id character varying(64) -- identifier for seller,
  user_id text,
  price smallint,
  department_id text NOT NULL -- reference to departments.account_id,
  FOREIGN KEY (department_id) REFERENCES departments(account_id)
)

[User] Display all departments.

[Assistant] SELECT * FROM education.departments;

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

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

[User] Calculate min of created_at for each course_id in departments.

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


[User] Retrieve all grades.

[Assistant] SELECT * FROM education.grades;

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

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

[User] Can you order these by seller_id descending?

[Assistant] SELECT * FROM education.grades WHERE user_id LIKE 'A%' ORDER BY seller_id DESC;


[User] List completed_at, seller_id, user_id from grades.

[Assistant] SELECT completed_at, seller_id, user_id FROM education.grades;

[User] Get all grades between January and March.

[Assistant] SELECT completed_at, seller_id, user_id FROM education.grades WHERE cancelled_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Limit the results to 25 rows.

[Assistant] SELECT completed_at, seller_id, user_id FROM education.grades WHERE cancelled_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 25;


[User] List user_id, cancelled_at, department_id from grades.

[Assistant] SELECT user_id, cancelled_at, department_id FROM education.grades;

[User] Get grades that match cancelled_at > '2023-01-01'.

[Assistant] SELECT user_id, cancelled_at, department_id FROM education.grades WHERE cancelled_at > '2023-01-01';

[User] Show me average of cancelled_at grouped by user_id for grades.

[Assistant] SELECT user_id, AVERAGE(cancelled_at) AS average_cancelled_at FROM education.grades GROUP BY user_id;


[User] Get all grades.

[Assistant] SELECT * FROM education.grades;

[User] Find grades between January and March.

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

[User] Only show the top 20 results.

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


[User] What are the cancelled_at, user_id, completed_at of each grade?

[Assistant] SELECT cancelled_at, user_id, completed_at FROM education.grades;

[User] Retrieve user_id, seller_id, approval_status, reference_number showing the relationship between grades and departments.

[Assistant] SELECT cancelled_at, user_id, completed_at, departments.approval_status, departments.reference_number FROM education.grades JOIN education.departments ON grades.department_id = departments.account_id;

[User] Group grades by cancelled_at and show the sum of cancelled_at.

[Assistant] SELECT cancelled_at, SUM(cancelled_at) AS sum_cancelled_at FROM education.grades GROUP BY cancelled_at;


[User] List seller_id, completed_at, cancelled_at from grades.

[Assistant] SELECT seller_id, completed_at, cancelled_at FROM education.grades;

[User] Show me price, cancelled_at, approval_status, reference_number from grades and their related departments.

[Assistant] SELECT seller_id, completed_at, cancelled_at, departments.approval_status, departments.reference_number FROM education.grades JOIN education.departments ON grades.department_id = departments.account_id;

[User] Restrict the output to 20 items.

[Assistant] SELECT seller_id, completed_at, cancelled_at, departments.approval_status, departments.reference_number FROM education.grades JOIN education.departments ON grades.department_id = departments.account_id LIMIT 20;


[User] Show me all departments.

[Assistant] SELECT * FROM education.departments;

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

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

[User] How many departments are there per approval_status?

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


[User] List all grades.

[Assistant] SELECT * FROM education.grades;

[User] List grades that have cancelled_at > '2023-01-01'.

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

[User] Return just 5 rows.

[Assistant] SELECT * FROM education.grades WHERE cancelled_at > '2023-01-01' LIMIT 5;


[User] Get all grades.

[Assistant] SELECT * FROM education.grades;

[User] List grades that have seller_id LIKE 'A%'.

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

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

[Assistant] SELECT * FROM education.grades WHERE seller_id LIKE 'A%' ORDER BY cancelled_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 e-commerce.order_items (
  invoice_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  card_type char,
  amount integer,
  product_id character varying(128) NOT NULL -- identifier for product,
  payment_method varchar,
  total numeric(38,14) NOT NULL,
  categorie_id text NOT NULL -- reference to categories.id,
  FOREIGN KEY (categorie_id) REFERENCES categories(id)
)

CREATE TABLE e-commerce.categories (
  id text PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at date,
  timezone character varying(256),
  address_line2 character varying(256),
  parking_available character varying(64),
  order_item_id text NOT NULL -- reference to order_items.invoice_id,
  FOREIGN KEY (order_item_id) REFERENCES order_items(invoice_id)
)

CREATE TABLE e-commerce.inventory (
  id character varying(64) NOT NULL -- unique identifier,
  published_at date,
  created_at date,
  manufacturer varchar,
  subcategory char NOT NULL,
  msrp character varying(64),
  views varchar NOT NULL,
  cost decimal,
  stock_level text,
  categorie_id text -- reference to categories.id,
  FOREIGN KEY (categorie_id) REFERENCES categories(id)
)

[User] Show me all inventory.

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

[User] Get subcategory, cost, parking_available, updated_at by joining inventory with categories.

[Assistant] SELECT *, categories.parking_available, categories.updated_at FROM e-commerce.inventory JOIN e-commerce.categories ON inventory.categorie_id = categories.id;

[User] Calculate min of cost for each views in inventory.

[Assistant] SELECT views, MIN(cost) AS min_cost FROM e-commerce.inventory GROUP BY views;


[User] Get card_type, total, product_id from all order_items.

[Assistant] SELECT card_type, total, product_id FROM e-commerce.order_items;

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

[Assistant] SELECT card_type, total, product_id FROM e-commerce.order_items WHERE card_type LIKE 'A%';

[User] What is the average total for each categorie_id in order_items?

[Assistant] SELECT categorie_id, AVERAGE(total) AS average_total FROM e-commerce.order_items GROUP BY categorie_id;


[User] Show me timezone, updated_at, created_at for all categories.

[Assistant] SELECT timezone, updated_at, created_at FROM e-commerce.categories;

[User] Sort the results by address_line2 ascending.

[Assistant] SELECT timezone, updated_at, created_at FROM e-commerce.categories ORDER BY address_line2 ASC;

[User] Restrict the output to 10 items.

[Assistant] SELECT timezone, updated_at, created_at FROM e-commerce.categories ORDER BY address_line2 ASC LIMIT 10;


[User] List timezone, updated_at, created_at from categories.

[Assistant] SELECT timezone, updated_at, created_at FROM e-commerce.categories;

[User] What updated_at, address_line2, categorie_id, card_type do we have for categories and their associated order_items?

[Assistant] SELECT timezone, updated_at, created_at, order_items.categorie_id, order_items.card_type FROM e-commerce.categories JOIN e-commerce.order_items ON categories.order_item_id = order_items.invoice_id;

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

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


[User] Retrieve manufacturer, created_at, categorie_id for every inventory.

[Assistant] SELECT manufacturer, created_at, categorie_id FROM e-commerce.inventory;

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

[Assistant] SELECT manufacturer, created_at, categorie_id FROM e-commerce.inventory ORDER BY cost ASC;

[User] Sort the results by id descending.

[Assistant] SELECT manufacturer, created_at, categorie_id FROM e-commerce.inventory ORDER BY id DESC;


[User] Get all order_items.

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

[User] Show me order_items with product_id LIKE 'A%'.

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

[User] Sort the results by payment_method ascending.

[Assistant] SELECT * FROM e-commerce.order_items WHERE product_id LIKE 'A%' ORDER BY payment_method ASC;


[User] Show me all order_items.

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

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

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

[User] Sort the results by amount ascending.

[Assistant] SELECT * FROM e-commerce.order_items WHERE product_id LIKE 'A%' ORDER BY amount ASC;


[User] Retrieve all order_items.

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

[User] Retrieve total, categorie_id, order_item_id, address_line2 showing the relationship between order_items and categories.

[Assistant] SELECT *, categories.order_item_id, categories.address_line2 FROM e-commerce.order_items JOIN e-commerce.categories ON order_items.categorie_id = categories.id;

[User] Only show the top 20 results.

[Assistant] SELECT *, categories.order_item_id, categories.address_line2 FROM e-commerce.order_items JOIN e-commerce.categories ON order_items.categorie_id = categories.id LIMIT 20;


[User] Show me all order_items.

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

[User] Get processed_at, amount, created_at, timezone by joining order_items with categories.

[Assistant] SELECT *, categories.created_at, categories.timezone FROM e-commerce.order_items JOIN e-commerce.categories ON order_items.categorie_id = categories.id;

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

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


[User] What are the timezone, address_line2, created_at of each categorie?

[Assistant] SELECT timezone, address_line2, created_at FROM e-commerce.categories;

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

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

[User] Can you order these by timezone descending?

[Assistant] SELECT timezone, address_line2, created_at FROM e-commerce.categories WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY timezone 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 government.clients (
  user_id integer PRIMARY KEY -- unique identifier,
  created_at date,
  last_active timestamp without time zone,
  bio character varying(256),
  email text,
  website text,
  api_key char,
  age char NOT NULL,
  language text
)

CREATE TABLE government.stores (
  address_id character varying(64) NOT NULL -- unique identifier,
  last_inspected timestamp,
  accessibility character varying(256),
  location_lon character varying(64) NOT NULL,
  name varchar
)

CREATE TABLE government.goods (
  sku integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  expires_at timestamp,
  stock_level char NOT NULL,
  title character varying(64),
  subcategory varchar,
  available character varying(256)
)

[User] What are the title, expires_at, subcategory of each good?

[Assistant] SELECT title, expires_at, subcategory FROM government.goods;

[User] Show the results sorted by created_at descending.

[Assistant] SELECT title, expires_at, subcategory FROM government.goods ORDER BY created_at DESC;

[User] Tally up goods by available.

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


[User] Show me all stores.

[Assistant] SELECT * FROM government.stores;

[User] Sort the results by name ascending.

[Assistant] SELECT * FROM government.stores ORDER BY name ASC;

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

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


[User] List api_key, bio, email from clients.

[Assistant] SELECT api_key, bio, email FROM government.clients;

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

[Assistant] SELECT api_key, bio, email FROM government.clients ORDER BY bio ASC;

[User] Limit the results to 25 rows.

[Assistant] SELECT api_key, bio, email FROM government.clients ORDER BY bio ASC LIMIT 25;


[User] Show me all clients.

[Assistant] SELECT * FROM government.clients;

[User] Show me clients that were created yesterday.

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

[User] Limit the results to 5 rows.

[Assistant] SELECT * FROM government.clients WHERE created_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 5;


[User] Show me accessibility, last_inspected, address_id for all stores.

[Assistant] SELECT accessibility, last_inspected, address_id FROM government.stores;

[User] Order the output by last_inspected descending.

[Assistant] SELECT accessibility, last_inspected, address_id FROM government.stores ORDER BY last_inspected DESC;

[User] Show me the count of stores grouped by address_id.

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


[User] Show me all stores.

[Assistant] SELECT * FROM government.stores;

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

[Assistant] SELECT * FROM government.stores WHERE last_inspected > '2023-12-01';

[User] Tally up stores by location_lon.

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


[User] Display all goods.

[Assistant] SELECT * FROM government.goods;

[User] Can you order these by created_at ascending?

[Assistant] SELECT * FROM government.goods ORDER BY created_at ASC;

[User] Can you order these by expires_at descending?

[Assistant] SELECT * FROM government.goods ORDER BY expires_at DESC;