[User] Show me all students.

[Assistant] SELECT * FROM travel.students;

[User] List updated_at, purchase_id, fee, cancelled_at for each student along with their purchase information.

[Assistant] SELECT *, purchases.fee, purchases.cancelled_at FROM travel.students JOIN travel.purchases ON students.purchase_id = purchases.id;

[User] Order the output by is_active ascending.

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

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

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

[User] Retrieve all locations.

[Assistant] SELECT * FROM travel.locations;

[User] Order the output by student_id descending.

[Assistant] SELECT * FROM travel.locations ORDER BY student_id DESC;

[User] Count the number of locations in each state category.

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


[User] What are the purchase_id, state, address_id of each location?

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

[User] Sort the results by accessibility descending.

[Assistant] SELECT purchase_id, state, address_id FROM travel.locations ORDER BY accessibility DESC;

[User] Restrict the output to 25 items.

[Assistant] SELECT purchase_id, state, address_id FROM travel.locations ORDER BY accessibility DESC LIMIT 25;


[User] Show me all students.

[Assistant] SELECT * FROM travel.students;

[User] List students that have birth_date > '2023-01-01'.

[Assistant] SELECT * FROM travel.students WHERE birth_date > '2023-01-01';

[User] Return just 20 rows.

[Assistant] SELECT * FROM travel.students WHERE birth_date > '2023-01-01' LIMIT 20;


[User] Display all students.

[Assistant] SELECT * FROM travel.students;

[User] Show the results sorted by bio descending.

[Assistant] SELECT * FROM travel.students ORDER BY bio DESC;

[User] Sort the results by website descending.

[Assistant] SELECT * FROM travel.students ORDER BY website DESC;


[User] Retrieve last_inspected, student_id, state for every location.

[Assistant] SELECT last_inspected, student_id, state FROM travel.locations;

[User] Find locations where address_line2 LIKE 'A%'.

[Assistant] SELECT last_inspected, student_id, state FROM travel.locations WHERE address_line2 LIKE 'A%';

[User] Restrict the output to 100 items.

[Assistant] SELECT last_inspected, student_id, state FROM travel.locations WHERE address_line2 LIKE 'A%' LIMIT 100;


[User] List all locations.

[Assistant] SELECT * FROM travel.locations;

[User] Sort the results by student_id descending.

[Assistant] SELECT * FROM travel.locations ORDER BY student_id DESC;

[User] How many locations are there per category?

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


[User] Show me all locations.

[Assistant] SELECT * FROM travel.locations;

[User] Order the output by last_inspected descending.

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

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.departments (
  barcode character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  subcategory character varying(128) NOT NULL,
  featured_rank char NOT NULL,
  description character varying(128),
  msrp varchar NOT NULL,
  patient_id integer NOT NULL -- reference to patients.id,
  FOREIGN KEY (patient_id) REFERENCES patients(id)
)

CREATE TABLE healthcare.patients (
  id integer PRIMARY KEY -- unique identifier,
  joined_at date,
  age character varying(64),
  timezone character varying(128) NOT NULL,
  membership_level char,
  avatar character varying(128) NOT NULL,
  first_name character varying(256)
)

[User] Display all departments.

[Assistant] SELECT * FROM healthcare.departments;

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

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

[User] Show me the count of departments grouped by description.

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


[User] Show me all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Find departments between January and March.

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

[User] Only show the top 50 results.

[Assistant] SELECT * FROM healthcare.departments WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 50;


[User] Get all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Order the output by featured_rank descending.

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

[User] Order the output by patient_id descending.

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


[User] Show me all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Show the results sorted by msrp ascending.

[Assistant] SELECT * FROM healthcare.departments ORDER BY msrp ASC;

[User] Order the output by featured_rank ascending.

[Assistant] SELECT * FROM healthcare.departments ORDER BY featured_rank ASC;


[User] List description, subcategory, barcode from departments.

[Assistant] SELECT description, subcategory, barcode FROM healthcare.departments;

[User] Retrieve created_at, msrp, joined_at, membership_level showing the relationship between departments and patients.

[Assistant] SELECT description, subcategory, barcode, patients.joined_at, patients.membership_level FROM healthcare.departments JOIN healthcare.patients ON departments.patient_id = patients.id;

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

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


[User] What are the subcategory, patient_id, created_at of each department?

[Assistant] SELECT subcategory, patient_id, created_at FROM healthcare.departments;

[User] Find departments where patient_id > 82.

[Assistant] SELECT subcategory, patient_id, created_at FROM healthcare.departments WHERE patient_id > 82;

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

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


[User] Show me all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Retrieve description, barcode, age, first_name showing the relationship between departments and patients.

[Assistant] SELECT *, patients.age, patients.first_name FROM healthcare.departments JOIN healthcare.patients ON departments.patient_id = patients.id;

[User] Group departments by msrp and show the sum of msrp.

[Assistant] SELECT msrp, SUM(msrp) AS sum_msrp FROM healthcare.departments GROUP BY msrp;


[User] List all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Get subcategory, patient_id, avatar, joined_at by joining departments with patients.

[Assistant] SELECT *, patients.avatar, patients.joined_at FROM healthcare.departments JOIN healthcare.patients ON departments.patient_id = patients.id;

[User] Tally up departments by featured_rank.

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


[User] List msrp, barcode, featured_rank from departments.

[Assistant] SELECT msrp, barcode, featured_rank FROM healthcare.departments;

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

[Assistant] SELECT msrp, barcode, featured_rank FROM healthcare.departments WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

[User] What is the average description for each created_at in departments?

[Assistant] SELECT created_at, AVERAGE(description) AS average_description FROM healthcare.departments GROUP BY created_at;


[User] Retrieve patient_id, description, msrp for every department.

[Assistant] SELECT patient_id, description, msrp FROM healthcare.departments;

[User] Sort the results by barcode descending.

[Assistant] SELECT patient_id, description, msrp FROM healthcare.departments ORDER BY barcode DESC;

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

[Assistant] SELECT patient_id, description, msrp FROM healthcare.departments ORDER BY description 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 (
  address_id varchar PRIMARY KEY -- unique identifier,
  last_inspected date,
  created_at timestamp,
  geo_point character varying(128),
  country character varying(128) NOT NULL,
  type character varying(128),
  operating_hours character varying(256),
  zip_code char,
  parking_available character varying(64),
  name varchar NOT NULL,
  grade_id integer -- reference to grades.content_id,
  teacher_id text -- reference to teachers.id,
  FOREIGN KEY (grade_id) REFERENCES grades(content_id),
  FOREIGN KEY (teacher_id) REFERENCES teachers(id)
)

CREATE TABLE education.students (
  customer_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  gender character varying(64),
  language varchar NOT NULL,
  last_login timestamp,
  display_name varchar NOT NULL,
  profile_picture_url varchar
)

CREATE TABLE education.grades (
  content_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  published_at timestamp without time zone,
  author_id text,
  attachment_url character varying(64),
  likes character varying(64)
)

CREATE TABLE education.teachers (
  id varchar PRIMARY KEY -- unique identifier,
  payment_date date,
  processed_at date,
  approval_status character varying(256) NOT NULL,
  exchange_rate char,
  student_id integer NOT NULL -- reference to students.customer_id,
  FOREIGN KEY (student_id) REFERENCES students(customer_id)
)

[User] List all departments.

[Assistant] SELECT * FROM education.departments;

[User] Retrieve departments where grade_id > 8.

[Assistant] SELECT * FROM education.departments WHERE grade_id > 8;

[User] Only show the top 5 results.

[Assistant] SELECT * FROM education.departments WHERE grade_id > 8 LIMIT 5;


[User] Display all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] Get all teachers from last week.

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

[User] Show only 20 records.

[Assistant] SELECT * FROM education.teachers WHERE payment_date >= CURRENT_DATE - INTERVAL '7 days' LIMIT 20;


[User] List all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

[User] Can you order these by payment_date descending?

[Assistant] SELECT * FROM education.teachers WHERE processed_at > '2023-12-01' ORDER BY payment_date DESC;


[User] Get all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] Order the output by payment_date descending.

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

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

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


[User] Show me all teachers.

[Assistant] SELECT * FROM education.teachers;

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

[Assistant] SELECT * FROM education.teachers WHERE exchange_rate LIKE 'A%';

[User] Can you order these by payment_date ascending?

[Assistant] SELECT * FROM education.teachers WHERE exchange_rate LIKE 'A%' ORDER BY payment_date 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.products (
  sku integer PRIMARY KEY -- unique identifier,
  updated_at date,
  published_at timestamp,
  views varchar,
  rating char,
  cost decimal,
  name char
)

CREATE TABLE e-commerce.shipping (
  id character varying(64) NOT NULL -- unique identifier,
  last_active timestamp,
  updated_at date,
  gender character varying(256),
  full_name character varying(64) NOT NULL,
  username character varying(64),
  language varchar NOT NULL
)

CREATE TABLE e-commerce.categories (
  order_id character varying(64) NOT NULL -- unique identifier,
  completed_at timestamp,
  buyer_id character varying(64) -- identifier for buyer,
  delivery_status char,
  approval_status character varying(128),
  currency char,
  exchange_rate character varying(128) NOT NULL,
  payment_status char NOT NULL
)

[User] List order_id, approval_status, currency from categories.

[Assistant] SELECT order_id, approval_status, currency FROM e-commerce.categories;

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

[Assistant] SELECT order_id, approval_status, currency FROM e-commerce.categories WHERE approval_status LIKE 'A%';

[User] Show the results sorted by payment_status ascending.

[Assistant] SELECT order_id, approval_status, currency FROM e-commerce.categories WHERE approval_status LIKE 'A%' ORDER BY payment_status ASC;


[User] Show me gender, full_name, updated_at for all shipping.

[Assistant] SELECT gender, full_name, updated_at FROM e-commerce.shipping;

[User] Find shipping from last week.

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

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

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


[User] Show me cost, published_at, name for all products.

[Assistant] SELECT cost, published_at, name FROM e-commerce.products;

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

[Assistant] SELECT cost, published_at, name FROM e-commerce.products WHERE name LIKE 'A%';

[User] Group products by views and show the count of published_at.

[Assistant] SELECT views, COUNT(published_at) AS count_published_at FROM e-commerce.products GROUP BY views;


[User] Show me all products.

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

[User] Find products modified within the last hour.

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

[User] Calculate average of rating for each updated_at in products.

[Assistant] SELECT updated_at, AVERAGE(rating) AS average_rating FROM e-commerce.products GROUP BY updated_at;


[User] Retrieve all categories.

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

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

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

[User] Get the distribution of categories across different order_id values.

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


[User] Get currency, payment_status, delivery_status from all categories.

[Assistant] SELECT currency, payment_status, delivery_status FROM e-commerce.categories;

[User] List categories that have payment_status LIKE 'A%'.

[Assistant] SELECT currency, payment_status, delivery_status FROM e-commerce.categories WHERE payment_status LIKE 'A%';

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

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


[User] Retrieve all shipping.

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

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

[Assistant] SELECT * FROM e-commerce.shipping ORDER BY language DESC;

[User] Only show the top 25 results.

[Assistant] SELECT * FROM e-commerce.shipping ORDER BY language DESC LIMIT 25;


[User] Retrieve all shipping.

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

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

[Assistant] SELECT * FROM e-commerce.shipping ORDER BY language DESC;

[User] Restrict the output to 20 items.

[Assistant] SELECT * FROM e-commerce.shipping ORDER BY language DESC LIMIT 20;


[User] Retrieve payment_status, exchange_rate, delivery_status for every categorie.

[Assistant] SELECT payment_status, exchange_rate, delivery_status FROM e-commerce.categories;

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

[Assistant] SELECT payment_status, exchange_rate, delivery_status FROM e-commerce.categories WHERE completed_at > '2023-12-01';

[User] Return just 5 rows.

[Assistant] SELECT payment_status, exchange_rate, delivery_status FROM e-commerce.categories WHERE completed_at > '2023-12-01' LIMIT 5;


[User] List all products.

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

[User] Order the output by name ascending.

[Assistant] SELECT * FROM e-commerce.products ORDER BY name ASC;

[User] How many products are there per cost?

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.appointments (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  traded_at date,
  cancelled_at timestamp without time zone,
  buyer_id varchar -- identifier for buyer,
  card_type character varying(64) NOT NULL,
  user_id character varying(64) -- identifier for user,
  subtotal decimal NOT NULL,
  price smallint,
  payment_status char NOT NULL
)

CREATE TABLE healthcare.prescriptions (
  address_id character varying(64) NOT NULL -- unique identifier,
  last_inspected date,
  created_at timestamp without time zone,
  accessibility character varying(64),
  operating_hours character varying(256),
  address_line1 text
)

CREATE TABLE healthcare.billing (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  payment_method character varying(128) NOT NULL,
  total bigint NOT NULL,
  currency text,
  seller_id varchar NOT NULL -- identifier for seller,
  buyer_id char -- identifier for buyer
)

[User] Get updated_at, seller_id, currency from all billing.

[Assistant] SELECT updated_at, seller_id, currency FROM healthcare.billing;

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

[Assistant] SELECT updated_at, seller_id, currency FROM healthcare.billing WHERE payment_method LIKE 'A%';

[User] How many billing are there per updated_at?

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


[User] Get payment_method, currency, total from all billing.

[Assistant] SELECT payment_method, currency, total FROM healthcare.billing;

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

[Assistant] SELECT payment_method, currency, total FROM healthcare.billing WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Only show the top 15 results.

[Assistant] SELECT payment_method, currency, total FROM healthcare.billing WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 15;


[User] Retrieve all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Can you order these by address_line1 ascending?

[Assistant] SELECT * FROM healthcare.prescriptions ORDER BY address_line1 ASC;

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

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


[User] Get all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Can you order these by address_line1 ascending?

[Assistant] SELECT * FROM healthcare.prescriptions ORDER BY address_line1 ASC;

[User] Return just 25 rows.

[Assistant] SELECT * FROM healthcare.prescriptions ORDER BY address_line1 ASC LIMIT 25;


[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Get billing that match buyer_id LIKE 'A%'.

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

[User] Count the number of billing in each buyer_id category.

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


[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

[Assistant] SELECT * FROM healthcare.billing ORDER BY seller_id ASC;

[User] How many billing are there per buyer_id?

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


[User] Get all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Can you order these by last_inspected descending?

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

[User] Limit the results to 15 rows.

[Assistant] SELECT * FROM healthcare.prescriptions ORDER BY last_inspected DESC LIMIT 15;


[User] Get all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] Show me min of payment_method grouped by payment_method for billing.

[Assistant] SELECT payment_method, MIN(payment_method) AS min_payment_method FROM healthcare.billing GROUP BY payment_method;


[User] Show me all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Find appointments from 2023.

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

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

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


[User] What are the payment_method, updated_at, seller_id of each billing?

[Assistant] SELECT payment_method, updated_at, seller_id FROM healthcare.billing;

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

[Assistant] SELECT payment_method, updated_at, seller_id FROM healthcare.billing WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] What is the count updated_at for each updated_at in billing?

[Assistant] SELECT updated_at, COUNT(updated_at) AS count_updated_at FROM healthcare.billing GROUP BY updated_at;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.transactions (
  invoice_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  currency text NOT NULL,
  product_id character varying(128) NOT NULL,
  seller_id character varying(128) NOT NULL,
  customer_id character varying(256) NOT NULL,
  subtotal bigint NOT NULL,
  payment_status character varying(256),
  loan_id text NOT NULL -- reference to loans.id,
  FOREIGN KEY (loan_id) REFERENCES loans(id)
)

CREATE TABLE finance.accounts (
  id varchar PRIMARY KEY -- unique identifier,
  due_date timestamp without time zone,
  payee_id character varying(64),
  invoice_number varchar,
  payer_id character varying(256),
  loan_id text -- reference to loans.id,
  FOREIGN KEY (loan_id) REFERENCES loans(id)
)

CREATE TABLE finance.loans (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at date,
  operating_hours text,
  description varchar NOT NULL,
  zip_code character varying(256),
  timezone char,
  latitude varchar,
  accessibility varchar,
  address_line2 character varying(128),
  account_id text -- reference to accounts.id,
  FOREIGN KEY (account_id) REFERENCES accounts(id)
)

CREATE TABLE finance.investments (
  id text PRIMARY KEY -- unique identifier,
  last_inspected date,
  geo_point text NOT NULL,
  capacity varchar,
  operating_hours char,
  type character varying(256),
  address_line1 char
)

[User] Get due_date, payer_id, invoice_number from all accounts.

[Assistant] SELECT due_date, payer_id, invoice_number FROM finance.accounts;

[User] Can you order these by payee_id descending?

[Assistant] SELECT due_date, payer_id, invoice_number FROM finance.accounts ORDER BY payee_id DESC;

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

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


[User] Get all loans.

[Assistant] SELECT * FROM finance.loans;

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

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

[User] Can you order these by address_line2 descending?

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


[User] Display all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Order the output by payment_status descending.

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

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

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


[User] Display all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Show me customer_id, updated_at, latitude, zip_code from transactions and their related loans.

[Assistant] SELECT *, loans.latitude, loans.zip_code FROM finance.transactions JOIN finance.loans ON transactions.loan_id = loans.id;

[User] Tally up transactions by loan_id.

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


[User] Retrieve payee_id, loan_id, invoice_number for every account.

[Assistant] SELECT payee_id, loan_id, invoice_number FROM finance.accounts;

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

[Assistant] SELECT payee_id, loan_id, invoice_number FROM finance.accounts ORDER BY due_date DESC;

[User] Limit the results to 50 rows.

[Assistant] SELECT payee_id, loan_id, invoice_number FROM finance.accounts ORDER BY due_date DESC LIMIT 50;


[User] List all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Show me loans with account_id LIKE 'A%'.

[Assistant] SELECT * FROM finance.loans WHERE account_id LIKE 'A%';

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.users (
  customer_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  joined_at date,
  language char,
  avatar char,
  display_name character varying(128),
  phone character varying(64),
  is_active bit,
  trade_id text NOT NULL -- reference to trades.invoice_id,
  FOREIGN KEY (trade_id) REFERENCES trades(invoice_id)
)

CREATE TABLE tradingplatform.metadata (
  id integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  joined_at timestamp,
  last_login timestamp without time zone,
  status character varying(64),
  trade_id text NOT NULL -- reference to trades.invoice_id,
  FOREIGN KEY (trade_id) REFERENCES trades(invoice_id)
)

CREATE TABLE tradingplatform.trades (
  invoice_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  created_at timestamp,
  payment_status character varying(256),
  total bigint,
  currency varchar,
  user_id text NOT NULL -- reference to users.customer_id,
  FOREIGN KEY (user_id) REFERENCES users(customer_id)
)

[User] What are the created_at, status, trade_id of each metadata?

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

[User] Retrieve last_login, trade_id, user_id, processed_at showing the relationship between metadata and trades.

[Assistant] SELECT created_at, status, trade_id, trades.user_id, trades.processed_at FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.invoice_id;

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

[Assistant] SELECT created_at, status, trade_id, trades.user_id, trades.processed_at FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.invoice_id ORDER BY last_login DESC;


[User] Show me created_at, user_id, total for all trades.

[Assistant] SELECT created_at, user_id, total FROM tradingplatform.trades;

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

[Assistant] SELECT created_at, user_id, total FROM tradingplatform.trades WHERE processed_at > '2023-01-01';

[User] Show the results sorted by total descending.

[Assistant] SELECT created_at, user_id, total FROM tradingplatform.trades WHERE processed_at > '2023-01-01' ORDER BY total DESC;


[User] List avatar, display_name, phone from users.

[Assistant] SELECT avatar, display_name, phone FROM tradingplatform.users;

[User] Show me trade_id, language, user_id, currency from users and their related trades.

[Assistant] SELECT avatar, display_name, phone, trades.user_id, trades.currency FROM tradingplatform.users JOIN tradingplatform.trades ON users.trade_id = trades.invoice_id;

[User] Sort the results by trade_id ascending.

[Assistant] SELECT avatar, display_name, phone, trades.user_id, trades.currency FROM tradingplatform.users JOIN tradingplatform.trades ON users.trade_id = trades.invoice_id ORDER BY trade_id ASC;


[User] Display all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

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

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

[User] How many trades are there per processed_at?

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


[User] Get phone, updated_at, trade_id from all users.

[Assistant] SELECT phone, updated_at, trade_id FROM tradingplatform.users;

[User] What avatar, trade_id, created_at, currency do we have for users and their associated trades?

[Assistant] SELECT phone, updated_at, trade_id, trades.created_at, trades.currency FROM tradingplatform.users JOIN tradingplatform.trades ON users.trade_id = trades.invoice_id;

[User] Group users by updated_at and show the average of joined_at.

[Assistant] SELECT updated_at, AVERAGE(joined_at) AS average_joined_at FROM tradingplatform.users GROUP BY updated_at;


[User] List all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

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

[Assistant] SELECT * FROM tradingplatform.trades WHERE processed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Group trades by currency and show the max of payment_status.

[Assistant] SELECT currency, MAX(payment_status) AS max_payment_status FROM tradingplatform.trades GROUP BY currency;


[User] Retrieve created_at, status, trade_id for every metadata.

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

[User] Retrieve last_login, joined_at, processed_at, total showing the relationship between metadata and trades.

[Assistant] SELECT created_at, status, trade_id, trades.processed_at, trades.total FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.invoice_id;

[User] Limit the results to 25 rows.

[Assistant] SELECT created_at, status, trade_id, trades.processed_at, trades.total FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.invoice_id LIMIT 25;


[User] Get all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

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

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

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

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


[User] List all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Sort the results by last_login descending.

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

[User] What is the count created_at for each trade_id in metadata?

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


[User] Get all users.

[Assistant] SELECT * FROM tradingplatform.users;

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

[Assistant] SELECT * FROM tradingplatform.users WHERE avatar LIKE 'A%';

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

[Assistant] SELECT trade_id, MAX(updated_at) AS max_updated_at FROM tradingplatform.users GROUP BY trade_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.trades (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  processed_at timestamp without time zone,
  card_type character varying(256),
  product_id character varying(256) -- identifier for product,
  exchange_rate char,
  customer_id text NOT NULL -- identifier for customer,
  wallet_id integer NOT NULL -- reference to wallets.account_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(account_id)
)

CREATE TABLE tradingplatform.wallets (
  account_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  balance numeric(38,14) NOT NULL,
  reconciliation_status character varying(128),
  customer_id character varying(128),
  payee_id character varying(128) NOT NULL,
  vendor_id varchar -- identifier for vendor,
  user_id character varying(128) -- identifier for user
)

CREATE TABLE tradingplatform.metadata (
  product_id integer PRIMARY KEY -- unique identifier,
  expires_at date,
  brand character varying(128),
  available character varying(256) NOT NULL,
  manufacturer text,
  thumbnail_url character varying(128),
  popularity_score character varying(64),
  wallet_id integer NOT NULL -- reference to wallets.account_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(account_id)
)

[User] Retrieve wallet_id, customer_id, exchange_rate for every trade.

[Assistant] SELECT wallet_id, customer_id, exchange_rate FROM tradingplatform.trades;

[User] List trades that have processed_at > '2023-01-01'.

[Assistant] SELECT wallet_id, customer_id, exchange_rate FROM tradingplatform.trades WHERE processed_at > '2023-01-01';

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

[Assistant] SELECT wallet_id, customer_id, exchange_rate FROM tradingplatform.trades WHERE processed_at > '2023-01-01' ORDER BY processed_at ASC;


[User] Show me card_type, created_at, wallet_id for all trades.

[Assistant] SELECT card_type, created_at, wallet_id FROM tradingplatform.trades;

[User] Sort the results by wallet_id descending.

[Assistant] SELECT card_type, created_at, wallet_id FROM tradingplatform.trades ORDER BY wallet_id DESC;

[User] Limit the results to 15 rows.

[Assistant] SELECT card_type, created_at, wallet_id FROM tradingplatform.trades ORDER BY wallet_id DESC LIMIT 15;


[User] List all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

[User] Retrieve processed_at, invoice_id, updated_at, customer_id showing the relationship between trades and wallets.

[Assistant] SELECT *, wallets.updated_at, wallets.customer_id FROM tradingplatform.trades JOIN tradingplatform.wallets ON trades.wallet_id = wallets.account_id;

[User] Order the output by product_id descending.

[Assistant] SELECT *, wallets.updated_at, wallets.customer_id FROM tradingplatform.trades JOIN tradingplatform.wallets ON trades.wallet_id = wallets.account_id ORDER BY product_id DESC;


[User] Show me all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Show me manufacturer, expires_at, reconciliation_status, customer_id from metadata and their related wallets.

[Assistant] SELECT *, wallets.reconciliation_status, wallets.customer_id FROM tradingplatform.metadata JOIN tradingplatform.wallets ON metadata.wallet_id = wallets.account_id;

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

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


[User] Retrieve expires_at, brand, available for every metadata.

[Assistant] SELECT expires_at, brand, available FROM tradingplatform.metadata;

[User] List metadata that have available LIKE 'A%'.

[Assistant] SELECT expires_at, brand, available FROM tradingplatform.metadata WHERE available LIKE 'A%';

[User] Restrict the output to 5 items.

[Assistant] SELECT expires_at, brand, available FROM tradingplatform.metadata WHERE available LIKE 'A%' LIMIT 5;


[User] List all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

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

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

[User] Show me the count of trades grouped by invoice_id.

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


[User] Display all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] List metadata with dates from last week.

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

[User] Show the results sorted by expires_at ascending.

[Assistant] SELECT * FROM tradingplatform.metadata WHERE expires_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY expires_at ASC;


[User] Get all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Get all metadata created yesterday.

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

[User] Only show the top 50 results.

[Assistant] SELECT * FROM tradingplatform.metadata WHERE expires_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 50;


[User] Display all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Retrieve metadata where wallet_id > 80.

[Assistant] SELECT * FROM tradingplatform.metadata WHERE wallet_id > 80;

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

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


[User] List all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

[User] Sort the results by created_at ascending.

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

[User] Group trades by wallet_id and show the count of invoice_id.

[Assistant] SELECT wallet_id, COUNT(invoice_id) AS count_invoice_id FROM tradingplatform.trades GROUP BY wallet_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 inventory.addresses (
  venue_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  postal_code character varying(128),
  location_lat character varying(64),
  address_line1 character varying(256) NOT NULL,
  good_id text -- reference to goods.product_id,
  FOREIGN KEY (good_id) REFERENCES goods(product_id)
)

CREATE TABLE inventory.goods (
  product_id text PRIMARY KEY -- unique identifier,
  published_at timestamp,
  created_at date,
  subcategory character varying(128) NOT NULL,
  cost numeric NOT NULL,
  views character varying(128) NOT NULL
)

CREATE TABLE inventory.reservations (
  payment_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  traded_at date,
  card_type character varying(256),
  tax decimal,
  approval_status character varying(256),
  payment_method text,
  fee text
)

[User] Show me good_id, venue_id, postal_code for all addresses.

[Assistant] SELECT good_id, venue_id, postal_code FROM inventory.addresses;

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

[Assistant] SELECT good_id, venue_id, postal_code FROM inventory.addresses ORDER BY venue_id ASC;

[User] What is the max postal_code for each venue_id in addresses?

[Assistant] SELECT venue_id, MAX(postal_code) AS max_postal_code FROM inventory.addresses GROUP BY venue_id;


[User] Show me all addresses.

[Assistant] SELECT * FROM inventory.addresses;

[User] Find addresses where location_lat LIKE 'A%'.

[Assistant] SELECT * FROM inventory.addresses WHERE location_lat LIKE 'A%';

[User] Calculate max of address_line1 for each created_at in addresses.

[Assistant] SELECT created_at, MAX(address_line1) AS max_address_line1 FROM inventory.addresses GROUP BY created_at;


[User] Show me all addresses.

[Assistant] SELECT * FROM inventory.addresses;

[User] Order the output by good_id ascending.

[Assistant] SELECT * FROM inventory.addresses ORDER BY good_id ASC;

[User] Tally up addresses by venue_id.

[Assistant] SELECT venue_id, COUNT(*) AS count FROM inventory.addresses GROUP BY venue_id ORDER BY count DESC;


[User] Get good_id, created_at, address_line1 from all addresses.

[Assistant] SELECT good_id, created_at, address_line1 FROM inventory.addresses;

[User] Get addresses that match good_id LIKE 'A%'.

[Assistant] SELECT good_id, created_at, address_line1 FROM inventory.addresses WHERE good_id LIKE 'A%';

[User] Can you order these by created_at ascending?

[Assistant] SELECT good_id, created_at, address_line1 FROM inventory.addresses WHERE good_id LIKE 'A%' ORDER BY created_at ASC;


[User] Show me all addresses.

[Assistant] SELECT * FROM inventory.addresses;

[User] Retrieve addresses where postal_code LIKE 'A%'.

[Assistant] SELECT * FROM inventory.addresses WHERE postal_code LIKE 'A%';

[User] Order the output by postal_code ascending.

[Assistant] SELECT * FROM inventory.addresses WHERE postal_code LIKE 'A%' ORDER BY postal_code ASC;


[User] Show me created_at, good_id, address_line1 for all addresses.

[Assistant] SELECT created_at, good_id, address_line1 FROM inventory.addresses;

[User] Find addresses where good_id LIKE 'A%'.

[Assistant] SELECT created_at, good_id, address_line1 FROM inventory.addresses WHERE good_id LIKE 'A%';

[User] How many addresses are there per location_lat?

[Assistant] SELECT location_lat, COUNT(*) AS count FROM inventory.addresses GROUP BY location_lat ORDER BY count DESC;


[User] Display all addresses.

[Assistant] SELECT * FROM inventory.addresses;

[User] Retrieve location_lat, good_id, cost, subcategory showing the relationship between addresses and goods.

[Assistant] SELECT *, goods.cost, goods.subcategory FROM inventory.addresses JOIN inventory.goods ON addresses.good_id = goods.product_id;

[User] Return just 10 rows.

[Assistant] SELECT *, goods.cost, goods.subcategory FROM inventory.addresses JOIN inventory.goods ON addresses.good_id = goods.product_id LIMIT 10;


[User] Display all addresses.

[Assistant] SELECT * FROM inventory.addresses;

[User] What address_line1, created_at, created_at, subcategory do we have for addresses and their associated goods?

[Assistant] SELECT *, goods.created_at, goods.subcategory FROM inventory.addresses JOIN inventory.goods ON addresses.good_id = goods.product_id;

[User] Return just 50 rows.

[Assistant] SELECT *, goods.created_at, goods.subcategory FROM inventory.addresses JOIN inventory.goods ON addresses.good_id = goods.product_id LIMIT 50;


[User] Show me all addresses.

[Assistant] SELECT * FROM inventory.addresses;

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

[Assistant] SELECT * FROM inventory.addresses ORDER BY created_at ASC;

[User] Limit the results to 25 rows.

[Assistant] SELECT * FROM inventory.addresses ORDER BY created_at ASC LIMIT 25;


[User] Get all addresses.

[Assistant] SELECT * FROM inventory.addresses;

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

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

[User] Show the results sorted by venue_id ascending.

[Assistant] SELECT * FROM inventory.addresses WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY venue_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 (
  product_id text PRIMARY KEY -- unique identifier,
  expires_at timestamp,
  featured_rank varchar,
  msrp varchar NOT NULL,
  video_url character varying(256) -- identifier for video_url,
  description char,
  subcategory text,
  review_id text -- reference to reviews.comment_id,
  FOREIGN KEY (review_id) REFERENCES reviews(comment_id)
)

CREATE TABLE government.reviews (
  comment_id text PRIMARY KEY -- unique identifier,
  edited_at date,
  subject character varying(128),
  image_url character varying(256),
  shares char,
  tags varchar NOT NULL,
  format text NOT NULL
)

[User] Get review_id, expires_at, featured_rank from all items.

[Assistant] SELECT review_id, expires_at, featured_rank FROM government.items;

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

[Assistant] SELECT review_id, expires_at, featured_rank FROM government.items ORDER BY expires_at ASC;

[User] Show me count of description grouped by expires_at for items.

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


[User] Show me review_id, featured_rank, description for all items.

[Assistant] SELECT review_id, featured_rank, description FROM government.items;

[User] List msrp, subcategory, edited_at, format for each item along with their review information.

[Assistant] SELECT review_id, featured_rank, description, reviews.edited_at, reviews.format FROM government.items JOIN government.reviews ON items.review_id = reviews.comment_id;

[User] How many items are there per subcategory?

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


[User] Retrieve all items.

[Assistant] SELECT * FROM government.items;

[User] Can you order these by video_url ascending?

[Assistant] SELECT * FROM government.items ORDER BY video_url ASC;

[User] Calculate average of expires_at for each subcategory in items.

[Assistant] SELECT subcategory, AVERAGE(expires_at) AS average_expires_at FROM government.items GROUP BY subcategory;


[User] Display all items.

[Assistant] SELECT * FROM government.items;

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

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

[User] Return just 25 rows.

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


[User] Get all items.

[Assistant] SELECT * FROM government.items;

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

[Assistant] SELECT * FROM government.items WHERE expires_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Group items by featured_rank and show the max of featured_rank.

[Assistant] SELECT featured_rank, MAX(featured_rank) AS max_featured_rank FROM government.items GROUP BY featured_rank;


[User] Retrieve review_id, description, subcategory for every item.

[Assistant] SELECT review_id, description, subcategory FROM government.items;

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

[Assistant] SELECT review_id, description, subcategory FROM government.items WHERE video_url LIKE 'A%';

[User] What is the min featured_rank for each msrp in items?

[Assistant] SELECT msrp, MIN(featured_rank) AS min_featured_rank FROM government.items GROUP BY msrp;


[User] Display all items.

[Assistant] SELECT * FROM government.items;

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

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

[User] Order the output by video_url descending.

[Assistant] SELECT * FROM government.items WHERE msrp LIKE 'A%' ORDER BY video_url DESC;


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

[Assistant] SELECT subcategory, description, msrp FROM government.items;

[User] List description, review_id, edited_at, subject for each item along with their review information.

[Assistant] SELECT subcategory, description, msrp, reviews.edited_at, reviews.subject FROM government.items JOIN government.reviews ON items.review_id = reviews.comment_id;

[User] Show me average of description grouped by review_id for items.

[Assistant] SELECT review_id, AVERAGE(description) AS average_description FROM government.items GROUP BY review_id;


[User] Retrieve all items.

[Assistant] SELECT * FROM government.items;

[User] Retrieve items where featured_rank LIKE 'A%'.

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

[User] Calculate average of description for each msrp in items.

[Assistant] SELECT msrp, AVERAGE(description) AS average_description FROM government.items GROUP BY msrp;


[User] List all items.

[Assistant] SELECT * FROM government.items;

[User] Retrieve video_url, expires_at, subject, tags showing the relationship between items and reviews.

[Assistant] SELECT *, reviews.subject, reviews.tags FROM government.items JOIN government.reviews ON items.review_id = reviews.comment_id;

[User] Get count of review_id by video_url from items.

[Assistant] SELECT video_url, COUNT(review_id) AS count_review_id FROM government.items GROUP BY video_url;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.shipping (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  completed_at date,
  status char,
  payment_status text NOT NULL,
  buyer_id char,
  subtotal integer,
  amount bigint,
  card_type varchar,
  delivery_status char NOT NULL,
  categorie_id text NOT NULL -- reference to categories.id,
  order_id text -- reference to orders.payment_id,
  FOREIGN KEY (categorie_id) REFERENCES categories(id),
  FOREIGN KEY (order_id) REFERENCES orders(payment_id)
)

CREATE TABLE e-commerce.categories (
  id text PRIMARY KEY -- unique identifier,
  cancelled_at timestamp without time zone,
  tax bigint,
  buyer_id character varying(128) NOT NULL,
  amount integer,
  approval_status varchar
)

CREATE TABLE e-commerce.orders (
  payment_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  currency character varying(64) NOT NULL,
  price integer,
  payment_status character varying(128),
  subtotal integer,
  categorie_id text NOT NULL -- reference to categories.id,
  FOREIGN KEY (categorie_id) REFERENCES categories(id)
)

[User] Show me categorie_id, buyer_id, status for all shipping.

[Assistant] SELECT categorie_id, buyer_id, status FROM e-commerce.shipping;

[User] Order the output by order_id ascending.

[Assistant] SELECT categorie_id, buyer_id, status FROM e-commerce.shipping ORDER BY order_id ASC;

[User] Return just 20 rows.

[Assistant] SELECT categorie_id, buyer_id, status FROM e-commerce.shipping ORDER BY order_id ASC LIMIT 20;


[User] Retrieve all orders.

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

[User] Show me processed_at, categorie_id, buyer_id, cancelled_at from orders and their related categories.

[Assistant] SELECT *, categories.buyer_id, categories.cancelled_at FROM e-commerce.orders JOIN e-commerce.categories ON orders.categorie_id = categories.id;

[User] Can you order these by price ascending?

[Assistant] SELECT *, categories.buyer_id, categories.cancelled_at FROM e-commerce.orders JOIN e-commerce.categories ON orders.categorie_id = categories.id ORDER BY price ASC;


[User] Get processed_at, payment_status, categorie_id from all orders.

[Assistant] SELECT processed_at, payment_status, categorie_id FROM e-commerce.orders;

[User] Get all orders older than 6 months.

[Assistant] SELECT processed_at, payment_status, categorie_id FROM e-commerce.orders WHERE processed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] How many orders are there per price?

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


[User] Show me payment_status, subtotal, categorie_id for all orders.

[Assistant] SELECT payment_status, subtotal, categorie_id FROM e-commerce.orders;

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

[Assistant] SELECT payment_status, subtotal, categorie_id FROM e-commerce.orders WHERE payment_status LIKE 'A%';

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

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


[User] List price, categorie_id, currency from orders.

[Assistant] SELECT price, categorie_id, currency FROM e-commerce.orders;

[User] Show me orders with subtotal > 39.

[Assistant] SELECT price, categorie_id, currency FROM e-commerce.orders WHERE subtotal > 39;

[User] Show only 15 records.

[Assistant] SELECT price, categorie_id, currency FROM e-commerce.orders WHERE subtotal > 39 LIMIT 15;


[User] Get status, order_id, updated_at from all shipping.

[Assistant] SELECT status, order_id, updated_at FROM e-commerce.shipping;

[User] List shipping that have categorie_id LIKE 'A%'.

[Assistant] SELECT status, order_id, updated_at FROM e-commerce.shipping WHERE categorie_id LIKE 'A%';

[User] What is the min subtotal for each status in shipping?

[Assistant] SELECT status, MIN(subtotal) AS min_subtotal FROM e-commerce.shipping GROUP BY status;


[User] What are the buyer_id, order_id, delivery_status of each shipping?

[Assistant] SELECT buyer_id, order_id, delivery_status FROM e-commerce.shipping;

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

[Assistant] SELECT buyer_id, order_id, delivery_status FROM e-commerce.shipping WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Show only 5 records.

[Assistant] SELECT buyer_id, order_id, delivery_status FROM e-commerce.shipping WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 5;


[User] Display all shipping.

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

[User] Get card_type, payment_status, amount, approval_status by joining shipping with categories.

[Assistant] SELECT *, categories.amount, categories.approval_status FROM e-commerce.shipping JOIN e-commerce.categories ON shipping.categorie_id = categories.id;

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

[Assistant] SELECT *, categories.amount, categories.approval_status FROM e-commerce.shipping JOIN e-commerce.categories ON shipping.categorie_id = categories.id ORDER BY categorie_id DESC;


[User] Display all shipping.

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

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

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

[User] Limit the results to 50 rows.

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


[User] Get updated_at, card_type, delivery_status from all shipping.

[Assistant] SELECT updated_at, card_type, delivery_status FROM e-commerce.shipping;

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

[Assistant] SELECT updated_at, card_type, delivery_status FROM e-commerce.shipping WHERE delivery_status LIKE 'A%';

[User] Sort the results by order_id descending.

[Assistant] SELECT updated_at, card_type, delivery_status FROM e-commerce.shipping WHERE delivery_status LIKE 'A%' ORDER BY order_id DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.transactions (
  payment_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  card_type char,
  customer_id varchar,
  total bigint NOT NULL,
  buyer_id text,
  account_id text -- reference to accounts.account_id,
  FOREIGN KEY (account_id) REFERENCES accounts(account_id)
)

CREATE TABLE finance.accounts (
  account_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  due_date date,
  category varchar,
  invoice_number character varying(128) NOT NULL,
  amount smallint NOT NULL,
  currency character varying(64),
  approval_status character varying(128),
  reconciliation_status character varying(256) NOT NULL,
  balance decimal NOT NULL
)

CREATE TABLE finance.audits (
  content_id text PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  updated_at timestamp,
  image_url character varying(128),
  parent_id text,
  media_url character varying(256),
  title varchar
)

CREATE TABLE finance.loans (
  sku character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  image_url varchar,
  tax_rate character varying(64),
  stock_level character varying(64) NOT NULL,
  account_id text -- reference to accounts.account_id,
  FOREIGN KEY (account_id) REFERENCES accounts(account_id)
)

[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] List total, card_type, updated_at, amount for each transaction along with their account information.

[Assistant] SELECT *, accounts.updated_at, accounts.amount FROM finance.transactions JOIN finance.accounts ON transactions.account_id = accounts.account_id;

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

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


[User] Get all loans.

[Assistant] SELECT * FROM finance.loans;

[User] What sku, updated_at, category, updated_at do we have for loans and their associated accounts?

[Assistant] SELECT *, accounts.category, accounts.updated_at FROM finance.loans JOIN finance.accounts ON loans.account_id = accounts.account_id;

[User] Show me sum of stock_level grouped by tax_rate for loans.

[Assistant] SELECT tax_rate, SUM(stock_level) AS sum_stock_level FROM finance.loans GROUP BY tax_rate;


[User] List buyer_id, payment_id, account_id from transactions.

[Assistant] SELECT buyer_id, payment_id, account_id FROM finance.transactions;

[User] Show the results sorted by customer_id ascending.

[Assistant] SELECT buyer_id, payment_id, account_id FROM finance.transactions ORDER BY customer_id ASC;

[User] Can you order these by card_type descending?

[Assistant] SELECT buyer_id, payment_id, account_id FROM finance.transactions ORDER BY card_type DESC;


[User] Get total, updated_at, account_id from all transactions.

[Assistant] SELECT total, updated_at, account_id FROM finance.transactions;

[User] Sort the results by buyer_id ascending.

[Assistant] SELECT total, updated_at, account_id FROM finance.transactions ORDER BY buyer_id ASC;

[User] Get max of buyer_id by customer_id from transactions.

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


[User] Retrieve all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Get updated_at, tax_rate, invoice_number, category by joining loans with accounts.

[Assistant] SELECT *, accounts.invoice_number, accounts.category FROM finance.loans JOIN finance.accounts ON loans.account_id = accounts.account_id;

[User] Can you order these by updated_at ascending?

[Assistant] SELECT *, accounts.invoice_number, accounts.category FROM finance.loans JOIN finance.accounts ON loans.account_id = accounts.account_id ORDER BY updated_at ASC;


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

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

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

[User] Show the results sorted by card_type ascending.

[Assistant] SELECT * FROM finance.transactions WHERE updated_at > '2023-01-01' ORDER BY card_type ASC;


[User] Get card_type, total, customer_id from all transactions.

[Assistant] SELECT card_type, total, customer_id FROM finance.transactions;

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

[Assistant] SELECT card_type, total, customer_id FROM finance.transactions WHERE updated_at > '2023-01-01';

[User] Limit the results to 5 rows.

[Assistant] SELECT card_type, total, customer_id FROM finance.transactions WHERE updated_at > '2023-01-01' LIMIT 5;


[User] What are the sku, stock_level, tax_rate of each loan?

[Assistant] SELECT sku, stock_level, tax_rate FROM finance.loans;

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

[Assistant] SELECT sku, stock_level, tax_rate FROM finance.loans WHERE image_url LIKE 'A%';

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

[Assistant] SELECT sku, stock_level, tax_rate FROM finance.loans WHERE image_url LIKE 'A%' ORDER BY tax_rate 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 restaurant.goods (
  item_id text PRIMARY KEY -- unique identifier,
  expires_at timestamp without time zone,
  popularity_score char,
  media_url char
)

CREATE TABLE restaurant.customers (
  id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  last_name char,
  state character varying(128),
  profile_picture_url varchar,
  birth_date date NOT NULL,
  good_id text -- reference to goods.item_id,
  FOREIGN KEY (good_id) REFERENCES goods(item_id)
)

[User] Retrieve all customers.

[Assistant] SELECT * FROM restaurant.customers;

[User] What profile_picture_url, last_name, expires_at, popularity_score do we have for customers and their associated goods?

[Assistant] SELECT *, goods.expires_at, goods.popularity_score FROM restaurant.customers JOIN restaurant.goods ON customers.good_id = goods.item_id;

[User] Show me sum of state grouped by created_at for customers.

[Assistant] SELECT created_at, SUM(state) AS sum_state FROM restaurant.customers GROUP BY created_at;


[User] Retrieve profile_picture_url, state, created_at for every customer.

[Assistant] SELECT profile_picture_url, state, created_at FROM restaurant.customers;

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

[Assistant] SELECT profile_picture_url, state, created_at FROM restaurant.customers WHERE birth_date <= CURRENT_DATE - INTERVAL '6 months';

[User] Only show the top 50 results.

[Assistant] SELECT profile_picture_url, state, created_at FROM restaurant.customers WHERE birth_date <= CURRENT_DATE - INTERVAL '6 months' LIMIT 50;


[User] Get id, profile_picture_url, good_id from all customers.

[Assistant] SELECT id, profile_picture_url, good_id FROM restaurant.customers;

[User] Get profile_picture_url, good_id, expires_at, media_url by joining customers with goods.

[Assistant] SELECT id, profile_picture_url, good_id, goods.expires_at, goods.media_url FROM restaurant.customers JOIN restaurant.goods ON customers.good_id = goods.item_id;

[User] Restrict the output to 50 items.

[Assistant] SELECT id, profile_picture_url, good_id, goods.expires_at, goods.media_url FROM restaurant.customers JOIN restaurant.goods ON customers.good_id = goods.item_id LIMIT 50;


[User] Get all customers.

[Assistant] SELECT * FROM restaurant.customers;

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

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

[User] Order the output by id descending.

[Assistant] SELECT * FROM restaurant.customers WHERE created_at > '2023-01-01' ORDER BY id DESC;


[User] Retrieve all customers.

[Assistant] SELECT * FROM restaurant.customers;

[User] Show me profile_picture_url, id, popularity_score, media_url from customers and their related goods.

[Assistant] SELECT *, goods.popularity_score, goods.media_url FROM restaurant.customers JOIN restaurant.goods ON customers.good_id = goods.item_id;

[User] Return just 50 rows.

[Assistant] SELECT *, goods.popularity_score, goods.media_url FROM restaurant.customers JOIN restaurant.goods ON customers.good_id = goods.item_id LIMIT 50;


[User] List id, good_id, profile_picture_url from customers.

[Assistant] SELECT id, good_id, profile_picture_url FROM restaurant.customers;

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

[Assistant] SELECT id, good_id, profile_picture_url FROM restaurant.customers WHERE good_id LIKE 'A%';

[User] What is the sum birth_date for each birth_date in customers?

[Assistant] SELECT birth_date, SUM(birth_date) AS sum_birth_date FROM restaurant.customers GROUP BY birth_date;


[User] Get all customers.

[Assistant] SELECT * FROM restaurant.customers;

[User] Find customers where birth_date > '2023-01-01'.

[Assistant] SELECT * FROM restaurant.customers WHERE birth_date > '2023-01-01';

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

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


[User] What are the birth_date, id, state of each customer?

[Assistant] SELECT birth_date, id, state FROM restaurant.customers;

[User] What profile_picture_url, created_at, media_url, popularity_score do we have for customers and their associated goods?

[Assistant] SELECT birth_date, id, state, goods.media_url, goods.popularity_score FROM restaurant.customers JOIN restaurant.goods ON customers.good_id = goods.item_id;

[User] Group customers by profile_picture_url and show the min of state.

[Assistant] SELECT profile_picture_url, MIN(state) AS min_state FROM restaurant.customers GROUP BY profile_picture_url;


[User] Show me all customers.

[Assistant] SELECT * FROM restaurant.customers;

[User] List last_name, birth_date, popularity_score, media_url for each customer along with their good information.

[Assistant] SELECT *, goods.popularity_score, goods.media_url FROM restaurant.customers JOIN restaurant.goods ON customers.good_id = goods.item_id;

[User] How many customers are there per last_name?

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


[User] Display all customers.

[Assistant] SELECT * FROM restaurant.customers;

[User] Sort the results by good_id descending.

[Assistant] SELECT * FROM restaurant.customers ORDER BY good_id DESC;

[User] How many customers are there per birth_date?

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.posts (
  comment_id character varying(64) NOT NULL -- unique identifier,
  published_at date,
  edited_at timestamp,
  rating varchar NOT NULL,
  tags varchar NOT NULL,
  user_id character varying(64),
  description char NOT NULL,
  image_url character varying(128),
  content character varying(128),
  parent_id character varying(128) -- identifier for parent,
  like_id text NOT NULL -- reference to likes.id,
  FOREIGN KEY (like_id) REFERENCES likes(id)
)

CREATE TABLE socialmedia.followers (
  id character varying(64) NOT NULL -- unique identifier,
  expires_at timestamp,
  published_at timestamp without time zone,
  backorder character varying(256) NOT NULL,
  cost numeric,
  tax_rate character varying(256),
  thumbnail_url character varying(256),
  video_url character varying(128),
  currency varchar
)

CREATE TABLE socialmedia.likes (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  username text,
  timezone character varying(64),
  is_verified boolean -- indicates if verified is true,
  city text NOT NULL
)

[User] Get tags, description, published_at from all posts.

[Assistant] SELECT tags, description, published_at FROM socialmedia.posts;

[User] Show the results sorted by parent_id ascending.

[Assistant] SELECT tags, description, published_at FROM socialmedia.posts ORDER BY parent_id ASC;

[User] Calculate average of edited_at for each edited_at in posts.

[Assistant] SELECT edited_at, AVERAGE(edited_at) AS average_edited_at FROM socialmedia.posts GROUP BY edited_at;


[User] Get all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] Get like_id, parent_id, city, username by joining posts with likes.

[Assistant] SELECT *, likes.city, likes.username FROM socialmedia.posts JOIN socialmedia.likes ON posts.like_id = likes.id;

[User] Group posts by parent_id and show the min of description.

[Assistant] SELECT parent_id, MIN(description) AS min_description FROM socialmedia.posts GROUP BY parent_id;


[User] Get all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] List user_id, tags, is_verified, city for each post along with their like information.

[Assistant] SELECT *, likes.is_verified, likes.city FROM socialmedia.posts JOIN socialmedia.likes ON posts.like_id = likes.id;

[User] Count the number of posts in each description category.

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


[User] Show me all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] List posts with dates from last week.

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

[User] Order the output by user_id descending.

[Assistant] SELECT * FROM socialmedia.posts WHERE published_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY user_id DESC;


[User] Show me all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] Show me posts with published_at > '2023-01-01'.

[Assistant] SELECT * FROM socialmedia.posts WHERE published_at > '2023-01-01';

[User] Get the distribution of posts across different comment_id values.

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


[User] Get image_url, comment_id, rating from all posts.

[Assistant] SELECT image_url, comment_id, rating FROM socialmedia.posts;

[User] List parent_id, user_id, updated_at, timezone for each post along with their like information.

[Assistant] SELECT image_url, comment_id, rating, likes.updated_at, likes.timezone FROM socialmedia.posts JOIN socialmedia.likes ON posts.like_id = likes.id;

[User] How many posts are there per image_url?

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


[User] List all posts.

[Assistant] SELECT * FROM socialmedia.posts;

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

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

[User] Show only 5 records.

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


[User] What are the description, published_at, like_id of each post?

[Assistant] SELECT description, published_at, like_id FROM socialmedia.posts;

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

[Assistant] SELECT description, published_at, like_id FROM socialmedia.posts WHERE edited_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Group posts by parent_id and show the min of description.

[Assistant] SELECT parent_id, MIN(description) AS min_description FROM socialmedia.posts GROUP BY parent_id;


[User] Retrieve all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] Can you order these by rating ascending?

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

[User] Count the number of posts in each like_id category.

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


[User] List all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] List edited_at, user_id, is_verified, timezone for each post along with their like information.

[Assistant] SELECT *, likes.is_verified, likes.timezone FROM socialmedia.posts JOIN socialmedia.likes ON posts.like_id = likes.id;

[User] Show the results sorted by tags descending.

[Assistant] SELECT *, likes.is_verified, likes.timezone FROM socialmedia.posts JOIN socialmedia.likes ON posts.like_id = likes.id ORDER BY tags 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 transportation.items (
  sku text PRIMARY KEY -- unique identifier,
  expires_at timestamp without time zone,
  created_at timestamp,
  rating char NOT NULL,
  msrp text,
  description character varying(128) NOT NULL,
  popularity_score character varying(64) NOT NULL,
  subcategory varchar
)

CREATE TABLE transportation.finances (
  id character varying(64) NOT NULL -- unique identifier,
  payment_date date,
  verification_status character varying(256) NOT NULL,
  description text,
  vendor_id varchar,
  notes character varying(64),
  status text NOT NULL,
  approval_status char,
  reference_number varchar,
  item_id text NOT NULL -- reference to items.sku,
  FOREIGN KEY (item_id) REFERENCES items(sku)
)

CREATE TABLE transportation.reservations (
  payment_id text PRIMARY KEY -- unique identifier,
  completed_at date,
  discount numeric,
  buyer_id character varying(128) -- identifier for buyer,
  approval_status character varying(128),
  product_id character varying(256) -- identifier for product
)

[User] Get notes, approval_status, reference_number from all finances.

[Assistant] SELECT notes, approval_status, reference_number FROM transportation.finances;

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

[Assistant] SELECT notes, approval_status, reference_number FROM transportation.finances ORDER BY item_id ASC;

[User] Show me the count of finances grouped by item_id.

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


[User] Retrieve id, reference_number, payment_date for every finance.

[Assistant] SELECT id, reference_number, payment_date FROM transportation.finances;

[User] Retrieve finances where reference_number LIKE 'A%'.

[Assistant] SELECT id, reference_number, payment_date FROM transportation.finances WHERE reference_number LIKE 'A%';

[User] Can you order these by approval_status ascending?

[Assistant] SELECT id, reference_number, payment_date FROM transportation.finances WHERE reference_number LIKE 'A%' ORDER BY approval_status ASC;


[User] What are the description, status, id of each finance?

[Assistant] SELECT description, status, id FROM transportation.finances;

[User] Show the results sorted by status descending.

[Assistant] SELECT description, status, id FROM transportation.finances ORDER BY status DESC;

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

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


[User] Get id, verification_status, payment_date from all finances.

[Assistant] SELECT id, verification_status, payment_date FROM transportation.finances;

[User] Show me vendor_id, id, popularity_score, msrp from finances and their related items.

[Assistant] SELECT id, verification_status, payment_date, items.popularity_score, items.msrp FROM transportation.finances JOIN transportation.items ON finances.item_id = items.sku;

[User] Sort the results by approval_status ascending.

[Assistant] SELECT id, verification_status, payment_date, items.popularity_score, items.msrp FROM transportation.finances JOIN transportation.items ON finances.item_id = items.sku ORDER BY approval_status ASC;


[User] Show me all finances.

[Assistant] SELECT * FROM transportation.finances;

[User] Retrieve notes, approval_status, popularity_score, rating showing the relationship between finances and items.

[Assistant] SELECT *, items.popularity_score, items.rating FROM transportation.finances JOIN transportation.items ON finances.item_id = items.sku;

[User] Get max of verification_status by description from finances.

[Assistant] SELECT description, MAX(verification_status) AS max_verification_status FROM transportation.finances GROUP BY description;


[User] Show me item_id, approval_status, notes for all finances.

[Assistant] SELECT item_id, approval_status, notes FROM transportation.finances;

[User] What status, id, popularity_score, description do we have for finances and their associated items?

[Assistant] SELECT item_id, approval_status, notes, items.popularity_score, items.description FROM transportation.finances JOIN transportation.items ON finances.item_id = items.sku;

[User] Tally up finances by verification_status.

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


[User] Show me description, vendor_id, payment_date for all finances.

[Assistant] SELECT description, vendor_id, payment_date FROM transportation.finances;

[User] Show me id, payment_date, popularity_score, subcategory from finances and their related items.

[Assistant] SELECT description, vendor_id, payment_date, items.popularity_score, items.subcategory FROM transportation.finances JOIN transportation.items ON finances.item_id = items.sku;

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

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


[User] Get all finances.

[Assistant] SELECT * FROM transportation.finances;

[User] Show the results sorted by status ascending.

[Assistant] SELECT * FROM transportation.finances ORDER BY status ASC;

[User] Tally up finances by notes.

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


[User] Show me description, payment_date, verification_status for all finances.

[Assistant] SELECT description, payment_date, verification_status FROM transportation.finances;

[User] Show me finances with id LIKE 'A%'.

[Assistant] SELECT description, payment_date, verification_status FROM transportation.finances WHERE id LIKE 'A%';

[User] Limit the results to 20 rows.

[Assistant] SELECT description, payment_date, verification_status FROM transportation.finances WHERE id LIKE 'A%' LIMIT 20;


[User] List item_id, verification_status, id from finances.

[Assistant] SELECT item_id, verification_status, id FROM transportation.finances;

[User] Get vendor_id, reference_number, popularity_score, rating by joining finances with items.

[Assistant] SELECT item_id, verification_status, id, items.popularity_score, items.rating FROM transportation.finances JOIN transportation.items ON finances.item_id = items.sku;

[User] What is the min reference_number for each notes in finances?

[Assistant] SELECT notes, MIN(reference_number) AS min_reference_number FROM transportation.finances GROUP BY notes;


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.followers (
  id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp without time zone,
  updated_at timestamp,
  views text,
  author_id character varying(128) -- identifier for author,
  media_url char,
  user_id text -- reference to users.customer_id,
  like_id text NOT NULL -- reference to likes.id,
  FOREIGN KEY (user_id) REFERENCES users(customer_id),
  FOREIGN KEY (like_id) REFERENCES likes(id)
)

CREATE TABLE socialmedia.users (
  customer_id varchar PRIMARY KEY -- unique identifier,
  last_active date,
  joined_at date,
  api_key char,
  token char NOT NULL,
  city varchar,
  display_name char,
  is_verified boolean
)

CREATE TABLE socialmedia.likes (
  id text PRIMARY KEY -- unique identifier,
  published_at timestamp,
  edited_at date,
  image_url character varying(256),
  views text,
  media_url character varying(256),
  thumbnail character varying(64) NOT NULL
)

CREATE TABLE socialmedia.comments (
  post_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  published_at timestamp without time zone,
  parent_id character varying(128) -- identifier for parent,
  tags text,
  attachment_url character varying(128)
)

CREATE TABLE socialmedia.groups (
  address_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  coordinates character varying(128),
  state character varying(256),
  type character varying(64)
)

[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show the results sorted by media_url descending.

[Assistant] SELECT * FROM socialmedia.followers ORDER BY media_url DESC;

[User] Limit the results to 15 rows.

[Assistant] SELECT * FROM socialmedia.followers ORDER BY media_url DESC LIMIT 15;


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

[User] Show only 15 records.

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


[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Find followers where like_id LIKE 'A%'.

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

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

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


[User] What are the user_id, views, author_id of each follower?

[Assistant] SELECT user_id, views, author_id FROM socialmedia.followers;

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

[Assistant] SELECT user_id, views, author_id FROM socialmedia.followers ORDER BY views ASC;

[User] Show the results sorted by like_id descending.

[Assistant] SELECT user_id, views, author_id FROM socialmedia.followers ORDER BY like_id DESC;


[User] What are the views, updated_at, edited_at of each follower?

[Assistant] SELECT views, updated_at, edited_at FROM socialmedia.followers;

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

[Assistant] SELECT views, updated_at, edited_at FROM socialmedia.followers ORDER BY user_id DESC;

[User] Limit the results to 5 rows.

[Assistant] SELECT views, updated_at, edited_at FROM socialmedia.followers ORDER BY user_id DESC LIMIT 5;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.followers (
  id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  accessibility text,
  address_line2 character varying(64),
  category character varying(256),
  country varchar NOT NULL,
  street character varying(128) NOT NULL
)

CREATE TABLE socialmedia.likes (
  message_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  created_at date,
  image_url character varying(64),
  parent_id character varying(128) NOT NULL,
  text varchar,
  author_id character varying(64) NOT NULL -- identifier for author,
  follower_id text -- reference to followers.id,
  FOREIGN KEY (follower_id) REFERENCES followers(id)
)

[User] Retrieve all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Show the results sorted by created_at descending.

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

[User] Get count of text by follower_id from likes.

[Assistant] SELECT follower_id, COUNT(text) AS count_text FROM socialmedia.likes GROUP BY follower_id;


[User] List all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Find likes where follower_id LIKE 'A%'.

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

[User] Show the results sorted by author_id descending.

[Assistant] SELECT * FROM socialmedia.likes WHERE follower_id LIKE 'A%' ORDER BY author_id DESC;


[User] Display all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] What follower_id, parent_id, address_line2, category do we have for likes and their associated followers?

[Assistant] SELECT *, followers.address_line2, followers.category FROM socialmedia.likes JOIN socialmedia.followers ON likes.follower_id = followers.id;

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

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


[User] Get all likes.

[Assistant] SELECT * FROM socialmedia.likes;

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

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

[User] Only show the top 20 results.

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


[User] Show me image_url, updated_at, text for all likes.

[Assistant] SELECT image_url, updated_at, text FROM socialmedia.likes;

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

[Assistant] SELECT image_url, updated_at, text FROM socialmedia.likes WHERE created_at > '2023-01-01';

[User] How many likes are there per follower_id?

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


[User] List parent_id, text, created_at from likes.

[Assistant] SELECT parent_id, text, created_at FROM socialmedia.likes;

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

[Assistant] SELECT parent_id, text, created_at FROM socialmedia.likes ORDER BY follower_id DESC;

[User] Can you order these by text descending?

[Assistant] SELECT parent_id, text, created_at FROM socialmedia.likes ORDER BY text DESC;


[User] Get all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Order the output by created_at descending.

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

[User] Order the output by parent_id descending.

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


[User] Display all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Retrieve text, author_id, category, accessibility showing the relationship between likes and followers.

[Assistant] SELECT *, followers.category, followers.accessibility FROM socialmedia.likes JOIN socialmedia.followers ON likes.follower_id = followers.id;

[User] Get sum of created_at by message_id from likes.

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


[User] Retrieve all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Find likes where image_url LIKE 'A%'.

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

[User] Calculate sum of text for each parent_id in likes.

[Assistant] SELECT parent_id, SUM(text) AS sum_text FROM socialmedia.likes GROUP BY parent_id;


[User] Retrieve created_at, parent_id, updated_at for every like.

[Assistant] SELECT created_at, parent_id, updated_at FROM socialmedia.likes;

[User] List likes with dates from last week.

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

[User] Show the results sorted by message_id ascending.

[Assistant] SELECT created_at, parent_id, updated_at FROM socialmedia.likes WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY message_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 humanresources.finances (
  id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  updated_at timestamp without time zone,
  approval_status varchar NOT NULL,
  exchange_rate varchar NOT NULL,
  description char,
  amount numeric(38,14)
)

CREATE TABLE humanresources.content (
  content_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  user_id character varying(128) NOT NULL,
  score char,
  text character varying(128),
  tags char,
  visibility character varying(128),
  format varchar,
  message character varying(64) NOT NULL,
  finance_id text NOT NULL -- reference to finances.id,
  FOREIGN KEY (finance_id) REFERENCES finances(id)
)

[User] Get user_id, updated_at, score from all content.

[Assistant] SELECT user_id, updated_at, score FROM humanresources.content;

[User] Can you order these by score descending?

[Assistant] SELECT user_id, updated_at, score FROM humanresources.content ORDER BY score DESC;

[User] Restrict the output to 5 items.

[Assistant] SELECT user_id, updated_at, score FROM humanresources.content ORDER BY score DESC LIMIT 5;


[User] Get all content.

[Assistant] SELECT * FROM humanresources.content;

[User] Show me content with message LIKE 'A%'.

[Assistant] SELECT * FROM humanresources.content WHERE message LIKE 'A%';

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

[Assistant] SELECT * FROM humanresources.content WHERE message LIKE 'A%' ORDER BY content_id DESC;


[User] What are the user_id, content_id, tags of each content?

[Assistant] SELECT user_id, content_id, tags FROM humanresources.content;

[User] Get content_id, score, approval_status, updated_at by joining content with finances.

[Assistant] SELECT user_id, content_id, tags, finances.approval_status, finances.updated_at FROM humanresources.content JOIN humanresources.finances ON content.finance_id = finances.id;

[User] Order the output by content_id descending.

[Assistant] SELECT user_id, content_id, tags, finances.approval_status, finances.updated_at FROM humanresources.content JOIN humanresources.finances ON content.finance_id = finances.id ORDER BY content_id DESC;


[User] Get all content.

[Assistant] SELECT * FROM humanresources.content;

[User] List content that have finance_id LIKE 'A%'.

[Assistant] SELECT * FROM humanresources.content WHERE finance_id LIKE 'A%';

[User] What is the max user_id for each finance_id in content?

[Assistant] SELECT finance_id, MAX(user_id) AS max_user_id FROM humanresources.content GROUP BY finance_id;


[User] Show me format, user_id, finance_id for all content.

[Assistant] SELECT format, user_id, finance_id FROM humanresources.content;

[User] Retrieve content where tags LIKE 'A%'.

[Assistant] SELECT format, user_id, finance_id FROM humanresources.content WHERE tags LIKE 'A%';

[User] Only show the top 20 results.

[Assistant] SELECT format, user_id, finance_id FROM humanresources.content WHERE tags LIKE 'A%' LIMIT 20;


[User] Show me all content.

[Assistant] SELECT * FROM humanresources.content;

[User] Sort the results by visibility ascending.

[Assistant] SELECT * FROM humanresources.content ORDER BY visibility ASC;

[User] Tally up content by tags.

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


[User] Show me all content.

[Assistant] SELECT * FROM humanresources.content;

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

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

[User] How many content are there per user_id?

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


[User] Get all content.

[Assistant] SELECT * FROM humanresources.content;

[User] Retrieve content where format LIKE 'A%'.

[Assistant] SELECT * FROM humanresources.content WHERE format LIKE 'A%';

[User] Sort the results by content_id ascending.

[Assistant] SELECT * FROM humanresources.content WHERE format LIKE 'A%' ORDER BY content_id ASC;


[User] Retrieve text, tags, format for every content.

[Assistant] SELECT text, tags, format FROM humanresources.content;

[User] Show me content with content_id LIKE 'A%'.

[Assistant] SELECT text, tags, format FROM humanresources.content WHERE content_id LIKE 'A%';

[User] Calculate sum of updated_at for each visibility in content.

[Assistant] SELECT visibility, SUM(updated_at) AS sum_updated_at FROM humanresources.content GROUP BY visibility;


[User] What are the user_id, message, score of each content?

[Assistant] SELECT user_id, message, score FROM humanresources.content;

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

[Assistant] SELECT user_id, message, score FROM humanresources.content WHERE updated_at > '2023-12-01';

[User] Calculate average of finance_id for each message in content.

[Assistant] SELECT message, AVERAGE(finance_id) AS average_finance_id FROM humanresources.content GROUP BY message;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.audits (
  account_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  exchange_rate text NOT NULL,
  approval_status char NOT NULL,
  category character varying(256) NOT NULL,
  notes character varying(64),
  customer_id text -- reference to customers.user_id,
  FOREIGN KEY (customer_id) REFERENCES customers(user_id)
)

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

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

[User] Show me all audits.

[Assistant] SELECT * FROM finance.audits;

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

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

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

[Assistant] SELECT * FROM finance.audits WHERE processed_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY customer_id DESC;


[User] Show me all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Can you order these by approval_status descending?

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

[User] Show me the count of audits grouped by approval_status.

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


[User] Retrieve notes, customer_id, approval_status for every audit.

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

[User] List audits that have customer_id LIKE 'A%'.

[Assistant] SELECT notes, customer_id, approval_status FROM finance.audits WHERE customer_id LIKE 'A%';

[User] Calculate count of processed_at for each category in audits.

[Assistant] SELECT category, COUNT(processed_at) AS count_processed_at FROM finance.audits GROUP BY category;


[User] Retrieve customer_id, notes, approval_status for every audit.

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

[User] Show the results sorted by category ascending.

[Assistant] SELECT customer_id, notes, approval_status FROM finance.audits ORDER BY category ASC;

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

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


[User] What are the subtotal, audit_id, customer_id of each payment?

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

[User] Retrieve buyer_id, seller_id, category, approval_status showing the relationship between payments and audits.

[Assistant] SELECT subtotal, audit_id, customer_id, audits.category, audits.approval_status FROM finance.payments JOIN finance.audits ON payments.audit_id = audits.account_id;

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

[Assistant] SELECT seller_id, MAX(seller_id) AS max_seller_id FROM finance.payments GROUP BY seller_id;