[User] Show me store_id, username, avatar for all clients.

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

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

[Assistant] SELECT store_id, username, avatar FROM realestate.clients WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE logistics.finances (
  invoice_id integer PRIMARY KEY -- unique identifier,
  created_at date,
  payee_id character varying(128) -- identifier for payee,
  credit char,
  category char,
  customer_id text -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

CREATE TABLE logistics.customers (
  employee_id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  last_login date,
  first_name text,
  last_name character varying(64) NOT NULL,
  profile_picture_url character varying(256),
  is_active bit,
  bio varchar
)

CREATE TABLE logistics.branches (
  id text PRIMARY KEY -- unique identifier,
  updated_at date,
  last_inspected date,
  type character varying(256),
  timezone char,
  city character varying(256),
  state char NOT NULL,
  customer_id text -- reference to customers.employee_id,
  finance_id integer -- reference to finances.invoice_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id),
  FOREIGN KEY (finance_id) REFERENCES finances(invoice_id)
)

[User] List timezone, type, city from branches.

[Assistant] SELECT timezone, type, city FROM logistics.branches;

[User] Can you order these by timezone ascending?

[Assistant] SELECT timezone, type, city FROM logistics.branches ORDER BY timezone ASC;

[User] How many branches are there per updated_at?

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


[User] Retrieve credit, customer_id, category for every finance.

[Assistant] SELECT credit, customer_id, category FROM logistics.finances;

[User] List credit, payee_id, last_login, bio for each finance along with their customer information.

[Assistant] SELECT credit, customer_id, category, customers.last_login, customers.bio FROM logistics.finances JOIN logistics.customers ON finances.customer_id = customers.employee_id;

[User] Order the output by payee_id descending.

[Assistant] SELECT credit, customer_id, category, customers.last_login, customers.bio FROM logistics.finances JOIN logistics.customers ON finances.customer_id = customers.employee_id ORDER BY payee_id DESC;


[User] Retrieve credit, category, customer_id for every finance.

[Assistant] SELECT credit, category, customer_id FROM logistics.finances;

[User] Get all finances created yesterday.

[Assistant] SELECT credit, category, customer_id FROM logistics.finances WHERE created_at = CURRENT_DATE - INTERVAL '1 day';

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

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


[User] Retrieve created_at, payee_id, credit for every finance.

[Assistant] SELECT created_at, payee_id, credit FROM logistics.finances;

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

[Assistant] SELECT created_at, payee_id, credit FROM logistics.finances WHERE category LIKE 'A%';

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

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


[User] Show me credit, customer_id, created_at for all finances.

[Assistant] SELECT credit, customer_id, created_at FROM logistics.finances;

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

[Assistant] SELECT credit, customer_id, created_at FROM logistics.finances WHERE created_at > '2023-01-01';

[User] Only show the top 5 results.

[Assistant] SELECT credit, customer_id, created_at FROM logistics.finances WHERE created_at > '2023-01-01' LIMIT 5;


[User] What are the last_inspected, finance_id, timezone of each branche?

[Assistant] SELECT last_inspected, finance_id, timezone FROM logistics.branches;

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

[Assistant] SELECT last_inspected, finance_id, timezone FROM logistics.branches WHERE updated_at > '2023-01-01';

[User] Get max of state by customer_id from branches.

[Assistant] SELECT customer_id, MAX(state) AS max_state FROM logistics.branches GROUP BY customer_id;


[User] What are the customer_id, credit, category of each finance?

[Assistant] SELECT customer_id, credit, category FROM logistics.finances;

[User] Get all finances from last week.

[Assistant] SELECT customer_id, credit, category FROM logistics.finances WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

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

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


[User] List all branches.

[Assistant] SELECT * FROM logistics.branches;

[User] Show me state, finance_id, joined_at, last_login from branches and their related customers.

[Assistant] SELECT *, customers.joined_at, customers.last_login FROM logistics.branches JOIN logistics.customers ON branches.customer_id = customers.employee_id;

[User] Can you order these by updated_at descending?

[Assistant] SELECT *, customers.joined_at, customers.last_login FROM logistics.branches JOIN logistics.customers ON branches.customer_id = customers.employee_id ORDER BY updated_at DESC;


[User] Retrieve all branches.

[Assistant] SELECT * FROM logistics.branches;

[User] List city, type, last_login, first_name for each branche along with their customer information.

[Assistant] SELECT *, customers.last_login, customers.first_name FROM logistics.branches JOIN logistics.customers ON branches.customer_id = customers.employee_id;

[User] Count the number of branches in each city category.

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


[User] List payee_id, customer_id, created_at from finances.

[Assistant] SELECT payee_id, customer_id, created_at FROM logistics.finances;

[User] Retrieve credit, category, bio, last_name showing the relationship between finances and customers.

[Assistant] SELECT payee_id, customer_id, created_at, customers.bio, customers.last_name FROM logistics.finances JOIN logistics.customers ON finances.customer_id = customers.employee_id;

[User] Restrict the output to 25 items.

[Assistant] SELECT payee_id, customer_id, created_at, customers.bio, customers.last_name FROM logistics.finances JOIN logistics.customers ON finances.customer_id = customers.employee_id LIMIT 25;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE banking.finances (
  account_id text PRIMARY KEY -- unique identifier,
  created_at date,
  category varchar NOT NULL,
  notes text NOT NULL,
  user_id character varying(64) NOT NULL,
  payee_id character varying(64) NOT NULL -- identifier for payee,
  approval_status char NOT NULL,
  patient_id text -- reference to patients.id,
  FOREIGN KEY (patient_id) REFERENCES patients(id)
)

CREATE TABLE banking.orders (
  id varchar PRIMARY KEY -- unique identifier,
  processed_at date,
  fee character varying(128) NOT NULL,
  subtotal numeric(38,14) NOT NULL,
  exchange_rate character varying(64) NOT NULL,
  tax bigint,
  customer_id varchar -- identifier for customer,
  payment_status character varying(64) NOT NULL,
  user_id varchar -- identifier for user
)

CREATE TABLE banking.patients (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  zip_code character varying(64),
  status character varying(256),
  country varchar,
  address char,
  city varchar,
  is_verified boolean
)

[User] Retrieve payee_id, approval_status, user_id for every finance.

[Assistant] SELECT payee_id, approval_status, user_id FROM banking.finances;

[User] Show the results sorted by user_id ascending.

[Assistant] SELECT payee_id, approval_status, user_id FROM banking.finances ORDER BY user_id ASC;

[User] Tally up finances by notes.

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


[User] Show me all finances.

[Assistant] SELECT * FROM banking.finances;

[User] Get all finances from 2023.

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

[User] Order the output by user_id ascending.

[Assistant] SELECT * FROM banking.finances WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY user_id ASC;


[User] Display all finances.

[Assistant] SELECT * FROM banking.finances;

[User] Find finances modified within the last hour.

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

[User] Show only 25 records.

[Assistant] SELECT * FROM banking.finances WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 25;


[User] Retrieve all finances.

[Assistant] SELECT * FROM banking.finances;

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

[Assistant] SELECT * FROM banking.finances ORDER BY payee_id DESC;

[User] How many finances are there per patient_id?

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


[User] List patient_id, created_at, user_id from finances.

[Assistant] SELECT patient_id, created_at, user_id FROM banking.finances;

[User] What user_id, notes, is_verified, country do we have for finances and their associated patients?

[Assistant] SELECT patient_id, created_at, user_id, patients.is_verified, patients.country FROM banking.finances JOIN banking.patients ON finances.patient_id = patients.id;

[User] Restrict the output to 5 items.

[Assistant] SELECT patient_id, created_at, user_id, patients.is_verified, patients.country FROM banking.finances JOIN banking.patients ON finances.patient_id = patients.id LIMIT 5;


[User] Display all finances.

[Assistant] SELECT * FROM banking.finances;

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

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

[User] Can you order these by user_id descending?

[Assistant] SELECT * FROM banking.finances WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY user_id DESC;


[User] Show me all finances.

[Assistant] SELECT * FROM banking.finances;

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

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

[User] Show me average of approval_status grouped by notes for finances.

[Assistant] SELECT notes, AVERAGE(approval_status) AS average_approval_status FROM banking.finances GROUP BY notes;


[User] Get category, notes, payee_id from all finances.

[Assistant] SELECT category, notes, payee_id FROM banking.finances;

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

[Assistant] SELECT category, notes, payee_id FROM banking.finances WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Order the output by payee_id descending.

[Assistant] SELECT category, notes, payee_id FROM banking.finances WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY payee_id DESC;


[User] Display all finances.

[Assistant] SELECT * FROM banking.finances;

[User] Show the results sorted by notes ascending.

[Assistant] SELECT * FROM banking.finances ORDER BY notes ASC;

[User] Tally up finances by category.

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


[User] Get all finances.

[Assistant] SELECT * FROM banking.finances;

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

[Assistant] SELECT * FROM banking.finances WHERE created_at > '2023-01-01';

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.teachers (
  address_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  last_inspected timestamp,
  parking_available text NOT NULL,
  address_line2 character varying(128) NOT NULL,
  longitude character varying(64) NOT NULL,
  accessibility character varying(256),
  latitude character varying(256) NOT NULL,
  category varchar,
  assignment_id text -- reference to assignments.person_id,
  FOREIGN KEY (assignment_id) REFERENCES assignments(person_id)
)

CREATE TABLE education.students (
  user_id varchar PRIMARY KEY -- unique identifier,
  last_active timestamp,
  website character varying(64),
  account_status varchar,
  zip_code text NOT NULL,
  api_key text,
  state char,
  salt character varying(128),
  email character varying(64),
  assignment_id text -- reference to assignments.person_id,
  FOREIGN KEY (assignment_id) REFERENCES assignments(person_id)
)

CREATE TABLE education.assignments (
  person_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  joined_at date,
  city character varying(128),
  state text,
  is_active boolean -- indicates if active is true,
  username text
)

[User] Show me address_line2, updated_at, assignment_id for all teachers.

[Assistant] SELECT address_line2, updated_at, assignment_id FROM education.teachers;

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

[Assistant] SELECT address_line2, updated_at, assignment_id FROM education.teachers WHERE last_inspected BETWEEN '2023-01-01' AND '2023-12-31';

[User] Tally up teachers by latitude.

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


[User] Get category, assignment_id, updated_at from all teachers.

[Assistant] SELECT category, assignment_id, updated_at FROM education.teachers;

[User] Order the output by parking_available descending.

[Assistant] SELECT category, assignment_id, updated_at FROM education.teachers ORDER BY parking_available DESC;

[User] What is the sum category for each category in teachers?

[Assistant] SELECT category, SUM(category) AS sum_category FROM education.teachers GROUP BY category;


[User] Display all students.

[Assistant] SELECT * FROM education.students;

[User] Order the output by account_status descending.

[Assistant] SELECT * FROM education.students ORDER BY account_status DESC;

[User] Show the results sorted by last_active descending.

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


[User] Retrieve all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

[User] Show only 100 records.

[Assistant] SELECT * FROM education.teachers WHERE last_inspected BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 100;


[User] Show me all students.

[Assistant] SELECT * FROM education.students;

[User] Get api_key, last_active, state, city by joining students with assignments.

[Assistant] SELECT *, assignments.state, assignments.city FROM education.students JOIN education.assignments ON students.assignment_id = assignments.person_id;

[User] Only show the top 10 results.

[Assistant] SELECT *, assignments.state, assignments.city FROM education.students JOIN education.assignments ON students.assignment_id = assignments.person_id LIMIT 10;


[User] Get website, state, api_key from all students.

[Assistant] SELECT website, state, api_key FROM education.students;

[User] Order the output by assignment_id ascending.

[Assistant] SELECT website, state, api_key FROM education.students ORDER BY assignment_id ASC;

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

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


[User] Get latitude, parking_available, accessibility from all teachers.

[Assistant] SELECT latitude, parking_available, accessibility FROM education.teachers;

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

[Assistant] SELECT latitude, parking_available, accessibility FROM education.teachers WHERE last_inspected >= CURRENT_DATE - INTERVAL '30 days';

[User] Show me max of address_line2 grouped by longitude for teachers.

[Assistant] SELECT longitude, MAX(address_line2) AS max_address_line2 FROM education.teachers GROUP BY longitude;


[User] Show me accessibility, assignment_id, longitude for all teachers.

[Assistant] SELECT accessibility, assignment_id, longitude FROM education.teachers;

[User] Show me teachers that were from 2023.

[Assistant] SELECT accessibility, assignment_id, longitude FROM education.teachers WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Order the output by accessibility ascending.

[Assistant] SELECT accessibility, assignment_id, longitude FROM education.teachers WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY accessibility ASC;


[User] What are the assignment_id, parking_available, category of each teacher?

[Assistant] SELECT assignment_id, parking_available, category FROM education.teachers;

[User] What longitude, parking_available, username, city do we have for teachers and their associated assignments?

[Assistant] SELECT assignment_id, parking_available, category, assignments.username, assignments.city FROM education.teachers JOIN education.assignments ON teachers.assignment_id = assignments.person_id;

[User] Show only 100 records.

[Assistant] SELECT assignment_id, parking_available, category, assignments.username, assignments.city FROM education.teachers JOIN education.assignments ON teachers.assignment_id = assignments.person_id LIMIT 100;


[User] Retrieve all students.

[Assistant] SELECT * FROM education.students;

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

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

[User] Show the results sorted by website descending.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE logistics.branches (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  description character varying(256) NOT NULL,
  zip_code character varying(256),
  capacity character varying(64),
  city character varying(64),
  longitude character varying(128),
  catalo_id text -- reference to catalog.item_id,
  FOREIGN KEY (catalo_id) REFERENCES catalog(item_id)
)

CREATE TABLE logistics.transactions (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  processed_at date,
  tax smallint NOT NULL,
  account_id varchar NOT NULL -- identifier for account,
  seller_id varchar NOT NULL -- identifier for seller,
  customer_id char -- identifier for customer,
  catalo_id text NOT NULL -- reference to catalog.item_id,
  FOREIGN KEY (catalo_id) REFERENCES catalog(item_id)
)

CREATE TABLE logistics.catalog (
  item_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  published_at timestamp without time zone,
  views char,
  video_url varchar -- identifier for video_url,
  branche_id text -- reference to branches.id,
  FOREIGN KEY (branche_id) REFERENCES branches(id)
)

[User] Retrieve processed_at, account_id, catalo_id for every transaction.

[Assistant] SELECT processed_at, account_id, catalo_id FROM logistics.transactions;

[User] Get all transactions between January and March.

[Assistant] SELECT processed_at, account_id, catalo_id FROM logistics.transactions WHERE processed_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Show the results sorted by account_id descending.

[Assistant] SELECT processed_at, account_id, catalo_id FROM logistics.transactions WHERE processed_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY account_id DESC;


[User] Show me all transactions.

[Assistant] SELECT * FROM logistics.transactions;

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

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

[User] Only show the top 5 results.

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


[User] List all catalog.

[Assistant] SELECT * FROM logistics.catalog;

[User] Order the output by published_at ascending.

[Assistant] SELECT * FROM logistics.catalog ORDER BY published_at ASC;

[User] Show me the count of catalog grouped by published_at.

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


[User] Get published_at, branche_id, views from all catalog.

[Assistant] SELECT published_at, branche_id, views FROM logistics.catalog;

[User] List catalog that have published_at > '2023-01-01'.

[Assistant] SELECT published_at, branche_id, views FROM logistics.catalog WHERE published_at > '2023-01-01';

[User] Tally up catalog by updated_at.

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


[User] Show me all branches.

[Assistant] SELECT * FROM logistics.branches;

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

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

[User] Sort the results by zip_code ascending.

[Assistant] SELECT * FROM logistics.branches WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY zip_code ASC;


[User] Get all catalog.

[Assistant] SELECT * FROM logistics.catalog;

[User] Get all catalog between January and March.

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

[User] Order the output by updated_at ascending.

[Assistant] SELECT * FROM logistics.catalog WHERE published_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY updated_at ASC;


[User] Get all catalog.

[Assistant] SELECT * FROM logistics.catalog;

[User] Sort the results by video_url ascending.

[Assistant] SELECT * FROM logistics.catalog ORDER BY video_url ASC;

[User] Get the distribution of catalog across different branche_id values.

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


[User] What are the views, branche_id, published_at of each catalog?

[Assistant] SELECT views, branche_id, published_at FROM logistics.catalog;

[User] Retrieve catalog where branche_id LIKE 'A%'.

[Assistant] SELECT views, branche_id, published_at FROM logistics.catalog WHERE branche_id LIKE 'A%';

[User] How many catalog are there per published_at?

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


[User] Get all branches.

[Assistant] SELECT * FROM logistics.branches;

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

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

[User] Group branches by zip_code and show the min of capacity.

[Assistant] SELECT zip_code, MIN(capacity) AS min_capacity FROM logistics.branches GROUP BY zip_code;


[User] List seller_id, catalo_id, customer_id from transactions.

[Assistant] SELECT seller_id, catalo_id, customer_id FROM logistics.transactions;

[User] Retrieve customer_id, processed_at, updated_at, branche_id showing the relationship between transactions and catalog.

[Assistant] SELECT seller_id, catalo_id, customer_id, catalog.updated_at, catalog.branche_id FROM logistics.transactions JOIN logistics.catalog ON transactions.catalo_id = catalog.item_id;

[User] Limit the results to 15 rows.

[Assistant] SELECT seller_id, catalo_id, customer_id, catalog.updated_at, catalog.branche_id FROM logistics.transactions JOIN logistics.catalog ON transactions.catalo_id = catalog.item_id LIMIT 15;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE gaming.content (
  post_id varchar PRIMARY KEY -- unique identifier,
  edited_at date,
  user_id character varying(64),
  categories text NOT NULL,
  reply_to_id varchar -- identifier for reply_to,
  subject char NOT NULL,
  rating character varying(256),
  parent_id character varying(64) NOT NULL -- identifier for parent,
  likes character varying(64),
  item_id text -- reference to items.sku,
  FOREIGN KEY (item_id) REFERENCES items(sku)
)

CREATE TABLE gaming.stores (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  last_inspected timestamp,
  country char,
  operating_hours character varying(256),
  name char,
  accessibility character varying(128),
  item_id text NOT NULL -- reference to items.sku,
  FOREIGN KEY (item_id) REFERENCES items(sku)
)

CREATE TABLE gaming.items (
  sku text PRIMARY KEY -- unique identifier,
  published_at timestamp,
  featured_rank text,
  video_url character varying(64),
  category character varying(256),
  price numeric NOT NULL,
  rating character varying(256),
  conten_id text -- reference to content.post_id,
  FOREIGN KEY (conten_id) REFERENCES content(post_id)
)

CREATE TABLE gaming.finances (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  updated_at date,
  notes varchar,
  description character varying(256),
  exchange_rate character varying(64),
  user_id character varying(256) NOT NULL,
  item_id text -- reference to items.sku,
  FOREIGN KEY (item_id) REFERENCES items(sku)
)

[User] Get all finances.

[Assistant] SELECT * FROM gaming.finances;

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

[Assistant] SELECT * FROM gaming.finances ORDER BY exchange_rate ASC;

[User] Can you order these by notes ascending?

[Assistant] SELECT * FROM gaming.finances ORDER BY notes ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.doctors (
  payment_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  due_date date,
  currency character varying(256),
  notes character varying(256),
  reconciliation_status character varying(64),
  category character varying(64) NOT NULL,
  vendor_id varchar NOT NULL,
  description character varying(128) NOT NULL,
  appointment_id text -- reference to appointments.post_id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(post_id)
)

CREATE TABLE healthcare.appointments (
  post_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  tags character varying(256) NOT NULL,
  keywords varchar,
  thumbnail char,
  text varchar,
  user_id character varying(128) -- identifier for user,
  doctor_id integer -- reference to doctors.payment_id,
  FOREIGN KEY (doctor_id) REFERENCES doctors(payment_id)
)

[User] List description, notes, due_date from doctors.

[Assistant] SELECT description, notes, due_date FROM healthcare.doctors;

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

[Assistant] SELECT description, notes, due_date FROM healthcare.doctors WHERE description LIKE 'A%';

[User] Only show the top 100 results.

[Assistant] SELECT description, notes, due_date FROM healthcare.doctors WHERE description LIKE 'A%' LIMIT 100;


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Show the results sorted by notes ascending.

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

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

[Assistant] SELECT due_date, COUNT(appointment_id) AS count_appointment_id FROM healthcare.doctors GROUP BY due_date;


[User] Get all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Find appointments where doctor_id > 9.

[Assistant] SELECT * FROM healthcare.appointments WHERE doctor_id > 9;

[User] Only show the top 20 results.

[Assistant] SELECT * FROM healthcare.appointments WHERE doctor_id > 9 LIMIT 20;


[User] Show me all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

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

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

[User] Can you order these by thumbnail ascending?

[Assistant] SELECT * FROM healthcare.appointments WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY thumbnail ASC;


[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Order the output by text descending.

[Assistant] SELECT * FROM healthcare.appointments ORDER BY text DESC;

[User] What is the average thumbnail for each user_id in appointments?

[Assistant] SELECT user_id, AVERAGE(thumbnail) AS average_thumbnail FROM healthcare.appointments GROUP BY user_id;


[User] Retrieve all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

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

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

[User] Tally up appointments by tags.

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


[User] Retrieve category, reconciliation_status, description for every doctor.

[Assistant] SELECT category, reconciliation_status, description FROM healthcare.doctors;

[User] Can you order these by notes ascending?

[Assistant] SELECT category, reconciliation_status, description FROM healthcare.doctors ORDER BY notes ASC;

[User] Show only 50 records.

[Assistant] SELECT category, reconciliation_status, description FROM healthcare.doctors ORDER BY notes ASC LIMIT 50;


[User] List updated_at, doctor_id, user_id from appointments.

[Assistant] SELECT updated_at, doctor_id, user_id FROM healthcare.appointments;

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

[Assistant] SELECT updated_at, doctor_id, user_id FROM healthcare.appointments WHERE updated_at > '2023-01-01';

[User] Limit the results to 5 rows.

[Assistant] SELECT updated_at, doctor_id, user_id FROM healthcare.appointments WHERE updated_at > '2023-01-01' LIMIT 5;


[User] What are the text, tags, thumbnail of each appointment?

[Assistant] SELECT text, tags, thumbnail FROM healthcare.appointments;

[User] Retrieve doctor_id, keywords, description, appointment_id showing the relationship between appointments and doctors.

[Assistant] SELECT text, tags, thumbnail, doctors.description, doctors.appointment_id FROM healthcare.appointments JOIN healthcare.doctors ON appointments.doctor_id = doctors.payment_id;

[User] Calculate max of updated_at for each updated_at in appointments.

[Assistant] SELECT updated_at, MAX(updated_at) AS max_updated_at FROM healthcare.appointments GROUP BY updated_at;


[User] Get all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

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

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

[User] Calculate max of user_id for each updated_at in appointments.

[Assistant] SELECT updated_at, MAX(user_id) AS max_user_id FROM healthcare.appointments 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 realestate.transactions (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  completed_at date,
  traded_at timestamp without time zone,
  payment_status char,
  exchange_rate text,
  delivery_status char,
  fee character varying(128) NOT NULL,
  store_id integer NOT NULL -- reference to stores.id,
  FOREIGN KEY (store_id) REFERENCES stores(id)
)

CREATE TABLE realestate.students (
  person_id integer PRIMARY KEY -- unique identifier,
  joined_at date,
  gender varchar,
  salt character varying(128),
  birth_date timestamp,
  transaction_id text -- reference to transactions.invoice_id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(invoice_id)
)

CREATE TABLE realestate.stores (
  id integer PRIMARY KEY -- unique identifier,
  created_at date,
  last_inspected date,
  location_lat char,
  country character varying(256),
  parking_available character varying(128),
  address_line1 char,
  timezone character varying(128) NOT NULL,
  transaction_id text -- reference to transactions.invoice_id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(invoice_id)
)

[User] Retrieve all students.

[Assistant] SELECT * FROM realestate.students;

[User] Sort the results by transaction_id ascending.

[Assistant] SELECT * FROM realestate.students ORDER BY transaction_id ASC;

[User] Show the results sorted by salt descending.

[Assistant] SELECT * FROM realestate.students ORDER BY salt DESC;


[User] Display all transactions.

[Assistant] SELECT * FROM realestate.transactions;

[User] Get exchange_rate, payment_status, created_at, location_lat by joining transactions with stores.

[Assistant] SELECT *, stores.created_at, stores.location_lat FROM realestate.transactions JOIN realestate.stores ON transactions.store_id = stores.id;

[User] Show me max of payment_status grouped by store_id for transactions.

[Assistant] SELECT store_id, MAX(payment_status) AS max_payment_status FROM realestate.transactions GROUP BY store_id;


[User] Get all transactions.

[Assistant] SELECT * FROM realestate.transactions;

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

[Assistant] SELECT * FROM realestate.transactions WHERE completed_at > '2023-01-01';

[User] Get max of exchange_rate by completed_at from transactions.

[Assistant] SELECT completed_at, MAX(exchange_rate) AS max_exchange_rate FROM realestate.transactions GROUP BY completed_at;


[User] Show me all transactions.

[Assistant] SELECT * FROM realestate.transactions;

[User] What traded_at, completed_at, location_lat, parking_available do we have for transactions and their associated stores?

[Assistant] SELECT *, stores.location_lat, stores.parking_available FROM realestate.transactions JOIN realestate.stores ON transactions.store_id = stores.id;

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

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


[User] List salt, joined_at, birth_date from students.

[Assistant] SELECT salt, joined_at, birth_date FROM realestate.students;

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

[Assistant] SELECT salt, joined_at, birth_date FROM realestate.students WHERE joined_at > '2023-01-01';

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

[Assistant] SELECT salt, joined_at, birth_date FROM realestate.students WHERE joined_at > '2023-01-01' ORDER BY birth_date DESC;


[User] Retrieve last_inspected, location_lat, parking_available for every store.

[Assistant] SELECT last_inspected, location_lat, parking_available FROM realestate.stores;

[User] Order the output by transaction_id descending.

[Assistant] SELECT last_inspected, location_lat, parking_available FROM realestate.stores ORDER BY transaction_id DESC;

[User] Get count of created_at by country from stores.

[Assistant] SELECT country, COUNT(created_at) AS count_created_at FROM realestate.stores GROUP BY country;


[User] List all transactions.

[Assistant] SELECT * FROM realestate.transactions;

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

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

[User] What is the count payment_status for each store_id in transactions?

[Assistant] SELECT store_id, COUNT(payment_status) AS count_payment_status FROM realestate.transactions GROUP BY store_id;


[User] Get birth_date, salt, gender from all students.

[Assistant] SELECT birth_date, salt, gender FROM realestate.students;

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

[Assistant] SELECT birth_date, salt, gender FROM realestate.students WHERE gender LIKE 'A%';

[User] How many students are there per joined_at?

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


[User] Get all transactions.

[Assistant] SELECT * FROM realestate.transactions;

[User] Order the output by delivery_status descending.

[Assistant] SELECT * FROM realestate.transactions ORDER BY delivery_status DESC;

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

[Assistant] SELECT * FROM realestate.transactions ORDER BY fee DESC;


[User] Display all transactions.

[Assistant] SELECT * FROM realestate.transactions;

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

[Assistant] SELECT * FROM realestate.transactions ORDER BY exchange_rate DESC;

[User] Can you order these by exchange_rate ascending?

[Assistant] SELECT * FROM realestate.transactions ORDER BY exchange_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 e-commerce.shipping (
  customer_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  joined_at date,
  last_login timestamp NOT NULL,
  display_name varchar NOT NULL,
  api_key character varying(64),
  country character varying(128) NOT NULL,
  status char,
  last_name varchar,
  inventor_id text -- reference to inventory.barcode,
  FOREIGN KEY (inventor_id) REFERENCES inventory(barcode)
)

CREATE TABLE e-commerce.inventory (
  barcode varchar PRIMARY KEY -- unique identifier,
  published_at timestamp,
  expires_at timestamp,
  title character varying(64) NOT NULL,
  tax_rate character varying(256),
  backorder varchar,
  video_url character varying(64) -- identifier for video_url,
  category varchar NOT NULL,
  rating character varying(128) NOT NULL,
  currency char NOT NULL
)

CREATE TABLE e-commerce.order_items (
  order_id integer PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  price bigint,
  seller_id character varying(256) NOT NULL -- identifier for seller,
  total decimal,
  approval_status varchar,
  status text,
  account_id character varying(64),
  shippin_id integer NOT NULL -- reference to shipping.customer_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(customer_id)
)

[User] Get seller_id, traded_at, status from all order_items.

[Assistant] SELECT seller_id, traded_at, status FROM e-commerce.order_items;

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

[Assistant] SELECT seller_id, traded_at, status FROM e-commerce.order_items WHERE traded_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Calculate sum of price for each total in order_items.

[Assistant] SELECT total, SUM(price) AS sum_price FROM e-commerce.order_items GROUP BY total;


[User] Get all order_items.

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

[User] Sort the results by traded_at ascending.

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

[User] How many order_items are there per price?

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


[User] What are the seller_id, total, price of each order_item?

[Assistant] SELECT seller_id, total, price FROM e-commerce.order_items;

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

[Assistant] SELECT seller_id, total, price FROM e-commerce.order_items WHERE traded_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Can you order these by account_id ascending?

[Assistant] SELECT seller_id, total, price FROM e-commerce.order_items WHERE traded_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY account_id ASC;


[User] Display all order_items.

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

[User] List order_items that have price > 59.

[Assistant] SELECT * FROM e-commerce.order_items WHERE price > 59;

[User] Show me the count of order_items grouped by seller_id.

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


[User] Show me all order_items.

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

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

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

[User] Get max of approval_status by total from order_items.

[Assistant] SELECT total, MAX(approval_status) AS max_approval_status FROM e-commerce.order_items GROUP BY total;


[User] Get joined_at, inventor_id, display_name from all shipping.

[Assistant] SELECT joined_at, inventor_id, display_name FROM e-commerce.shipping;

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

[Assistant] SELECT joined_at, inventor_id, display_name FROM e-commerce.shipping ORDER BY last_name DESC;

[User] Return just 100 rows.

[Assistant] SELECT joined_at, inventor_id, display_name FROM e-commerce.shipping ORDER BY last_name DESC LIMIT 100;


[User] Retrieve all order_items.

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

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

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

[User] Sort the results by total descending.

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


[User] Retrieve all order_items.

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

[User] Retrieve traded_at, status, display_name, inventor_id showing the relationship between order_items and shipping.

[Assistant] SELECT *, shipping.display_name, shipping.inventor_id FROM e-commerce.order_items JOIN e-commerce.shipping ON order_items.shippin_id = shipping.customer_id;

[User] Return just 50 rows.

[Assistant] SELECT *, shipping.display_name, shipping.inventor_id FROM e-commerce.order_items JOIN e-commerce.shipping ON order_items.shippin_id = shipping.customer_id LIMIT 50;


[User] Retrieve api_key, last_login, updated_at for every shipping.

[Assistant] SELECT api_key, last_login, updated_at FROM e-commerce.shipping;

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

[Assistant] SELECT api_key, last_login, updated_at FROM e-commerce.shipping WHERE country LIKE 'A%';

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

[Assistant] SELECT api_key, last_login, updated_at FROM e-commerce.shipping WHERE country LIKE 'A%' ORDER BY last_login DESC;


[User] List price, status, total from order_items.

[Assistant] SELECT price, status, total FROM e-commerce.order_items;

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

[Assistant] SELECT price, status, total FROM e-commerce.order_items ORDER BY approval_status DESC;

[User] Show the results sorted by price ascending.

[Assistant] SELECT price, status, total FROM e-commerce.order_items ORDER BY price 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.orders (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  processed_at timestamp,
  cancelled_at timestamp,
  card_type character varying(64),
  payment_method char,
  exchange_rate char NOT NULL,
  approval_status char,
  customer_id character varying(64),
  total numeric(38,14) NOT NULL,
  categorie_id text -- reference to categories.post_id,
  FOREIGN KEY (categorie_id) REFERENCES categories(post_id)
)

CREATE TABLE e-commerce.shipping (
  address_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  last_inspected date,
  location_lon char,
  type varchar,
  category char,
  description character varying(64) NOT NULL,
  state char,
  timezone text
)

CREATE TABLE e-commerce.categories (
  post_id text PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  published_at date,
  thumbnail character varying(256),
  keywords character varying(256),
  text character varying(256),
  reply_to_id character varying(256) NOT NULL,
  shares character varying(256),
  views varchar,
  shippin_id text -- reference to shipping.address_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(address_id)
)

[User] Retrieve all orders.

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

[User] Retrieve processed_at, payment_method, text, thumbnail showing the relationship between orders and categories.

[Assistant] SELECT *, categories.text, categories.thumbnail FROM e-commerce.orders JOIN e-commerce.categories ON orders.categorie_id = categories.post_id;

[User] Only show the top 50 results.

[Assistant] SELECT *, categories.text, categories.thumbnail FROM e-commerce.orders JOIN e-commerce.categories ON orders.categorie_id = categories.post_id LIMIT 50;


[User] Get cancelled_at, payment_method, approval_status from all orders.

[Assistant] SELECT cancelled_at, payment_method, approval_status FROM e-commerce.orders;

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

[Assistant] SELECT cancelled_at, payment_method, approval_status FROM e-commerce.orders WHERE customer_id LIKE 'A%';

[User] Restrict the output to 5 items.

[Assistant] SELECT cancelled_at, payment_method, approval_status FROM e-commerce.orders WHERE customer_id LIKE 'A%' LIMIT 5;


[User] Show me approval_status, categorie_id, transaction_id for all orders.

[Assistant] SELECT approval_status, categorie_id, transaction_id FROM e-commerce.orders;

[User] Get all orders created yesterday.

[Assistant] SELECT approval_status, categorie_id, transaction_id FROM e-commerce.orders WHERE processed_at = CURRENT_DATE - INTERVAL '1 day';

[User] Limit the results to 100 rows.

[Assistant] SELECT approval_status, categorie_id, transaction_id FROM e-commerce.orders WHERE processed_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 100;


[User] List all orders.

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

[User] Sort the results by customer_id ascending.

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

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

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


[User] Display all orders.

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

[User] Retrieve processed_at, approval_status, reply_to_id, edited_at showing the relationship between orders and categories.

[Assistant] SELECT *, categories.reply_to_id, categories.edited_at FROM e-commerce.orders JOIN e-commerce.categories ON orders.categorie_id = categories.post_id;

[User] Calculate min of payment_method for each customer_id in orders.

[Assistant] SELECT customer_id, MIN(payment_method) AS min_payment_method FROM e-commerce.orders GROUP BY customer_id;


[User] Display all orders.

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

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

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

[User] Return just 50 rows.

[Assistant] SELECT * FROM e-commerce.orders ORDER BY exchange_rate ASC LIMIT 50;


[User] What are the keywords, thumbnail, views of each categorie?

[Assistant] SELECT keywords, thumbnail, views FROM e-commerce.categories;

[User] Show the results sorted by edited_at ascending.

[Assistant] SELECT keywords, thumbnail, views FROM e-commerce.categories ORDER BY edited_at ASC;

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

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


[User] List all orders.

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

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

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

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

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


[User] Show me all categories.

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

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

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

[User] Restrict the output to 15 items.

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


[User] Get cancelled_at, card_type, total from all orders.

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

[User] Can you order these by categorie_id ascending?

[Assistant] SELECT cancelled_at, card_type, total FROM e-commerce.orders ORDER BY categorie_id ASC;

[User] Show only 50 records.

[Assistant] SELECT cancelled_at, card_type, total FROM e-commerce.orders ORDER BY categorie_id ASC LIMIT 50;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE music.messages (
  post_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  shares character varying(256),
  content text,
  title varchar,
  user_id varchar,
  reservation_id integer NOT NULL -- reference to reservations.id,
  FOREIGN KEY (reservation_id) REFERENCES reservations(id)
)

CREATE TABLE music.reservations (
  id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  approval_status text,
  total numeric(38,14),
  card_type text,
  price numeric(38,14),
  status character varying(256),
  fee character varying(256),
  payment_status char,
  message_id text -- reference to messages.post_id,
  FOREIGN KEY (message_id) REFERENCES messages(post_id)
)

CREATE TABLE music.students (
  employee_id character varying(64) NOT NULL -- unique identifier,
  joined_at date,
  city text NOT NULL,
  address char,
  password_hash character varying(128),
  full_name character varying(64),
  first_name character varying(128) NOT NULL,
  last_name char NOT NULL
)

[User] Retrieve reservation_id, content, shares for every message.

[Assistant] SELECT reservation_id, content, shares FROM music.messages;

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

[Assistant] SELECT reservation_id, content, shares FROM music.messages WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] How many messages are there per title?

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


[User] List all reservations.

[Assistant] SELECT * FROM music.reservations;

[User] List price, total, reservation_id, updated_at for each reservation along with their message information.

[Assistant] SELECT *, messages.reservation_id, messages.updated_at FROM music.reservations JOIN music.messages ON reservations.message_id = messages.post_id;

[User] Group reservations by approval_status and show the sum of status.

[Assistant] SELECT approval_status, SUM(status) AS sum_status FROM music.reservations GROUP BY approval_status;


[User] Retrieve all reservations.

[Assistant] SELECT * FROM music.reservations;

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

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

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

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


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

[Assistant] SELECT user_id, updated_at, title FROM music.messages;

[User] List content, updated_at, price, fee for each message along with their reservation information.

[Assistant] SELECT user_id, updated_at, title, reservations.price, reservations.fee FROM music.messages JOIN music.reservations ON messages.reservation_id = reservations.id;

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

[Assistant] SELECT user_id, updated_at, title, reservations.price, reservations.fee FROM music.messages JOIN music.reservations ON messages.reservation_id = reservations.id ORDER BY title DESC;


[User] What are the message_id, total, card_type of each reservation?

[Assistant] SELECT message_id, total, card_type FROM music.reservations;

[User] Can you order these by total descending?

[Assistant] SELECT message_id, total, card_type FROM music.reservations ORDER BY total DESC;

[User] Show me sum of payment_status grouped by payment_status for reservations.

[Assistant] SELECT payment_status, SUM(payment_status) AS sum_payment_status FROM music.reservations GROUP BY payment_status;


[User] Show me fee, message_id, payment_status for all reservations.

[Assistant] SELECT fee, message_id, payment_status FROM music.reservations;

[User] Can you order these by status ascending?

[Assistant] SELECT fee, message_id, payment_status FROM music.reservations ORDER BY status ASC;

[User] Restrict the output to 100 items.

[Assistant] SELECT fee, message_id, payment_status FROM music.reservations ORDER BY status ASC LIMIT 100;


[User] Display all reservations.

[Assistant] SELECT * FROM music.reservations;

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

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

[User] Group reservations by status and show the sum of approval_status.

[Assistant] SELECT status, SUM(approval_status) AS sum_approval_status FROM music.reservations GROUP BY status;


[User] Retrieve all reservations.

[Assistant] SELECT * FROM music.reservations;

[User] List updated_at, status, updated_at, shares for each reservation along with their message information.

[Assistant] SELECT *, messages.updated_at, messages.shares FROM music.reservations JOIN music.messages ON reservations.message_id = messages.post_id;

[User] Return just 20 rows.

[Assistant] SELECT *, messages.updated_at, messages.shares FROM music.reservations JOIN music.messages ON reservations.message_id = messages.post_id LIMIT 20;


[User] Get all reservations.

[Assistant] SELECT * FROM music.reservations;

[User] Get fee, status, content, user_id by joining reservations with messages.

[Assistant] SELECT *, messages.content, messages.user_id FROM music.reservations JOIN music.messages ON reservations.message_id = messages.post_id;

[User] Tally up reservations by status.

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


[User] What are the content, title, shares of each message?

[Assistant] SELECT content, title, shares FROM music.messages;

[User] Sort the results by content descending.

[Assistant] SELECT content, title, shares FROM music.messages ORDER BY content DESC;

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.appointments (
  address_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  location_lat character varying(128),
  coordinates text,
  street character varying(64),
  latitude text,
  patient_id integer NOT NULL -- reference to patients.user_id,
  FOREIGN KEY (patient_id) REFERENCES patients(user_id)
)

CREATE TABLE healthcare.billing (
  barcode character varying(64) NOT NULL -- unique identifier,
  created_at date,
  expires_at timestamp without time zone,
  reserved character varying(128) NOT NULL,
  name character varying(64),
  media_url text,
  video_url char,
  patient_id integer NOT NULL -- reference to patients.user_id,
  FOREIGN KEY (patient_id) REFERENCES patients(user_id)
)

CREATE TABLE healthcare.patients (
  user_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at timestamp,
  username character varying(128),
  token character varying(256) NOT NULL,
  language char NOT NULL,
  timezone text
)

[User] Get all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Can you order these by media_url ascending?

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

[User] Get average of reserved by expires_at from billing.

[Assistant] SELECT expires_at, AVERAGE(reserved) AS average_reserved FROM healthcare.billing GROUP BY expires_at;


[User] List barcode, created_at, reserved from billing.

[Assistant] SELECT barcode, created_at, reserved FROM healthcare.billing;

[User] Show me barcode, reserved, updated_at, created_at from billing and their related patients.

[Assistant] SELECT barcode, created_at, reserved, patients.updated_at, patients.created_at FROM healthcare.billing JOIN healthcare.patients ON billing.patient_id = patients.user_id;

[User] Can you order these by name descending?

[Assistant] SELECT barcode, created_at, reserved, patients.updated_at, patients.created_at FROM healthcare.billing JOIN healthcare.patients ON billing.patient_id = patients.user_id ORDER BY name DESC;


[User] Retrieve all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Retrieve appointments where latitude LIKE 'A%'.

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

[User] Restrict the output to 20 items.

[Assistant] SELECT * FROM healthcare.appointments WHERE latitude LIKE 'A%' LIMIT 20;


[User] Show me location_lat, coordinates, created_at for all appointments.

[Assistant] SELECT location_lat, coordinates, created_at FROM healthcare.appointments;

[User] List appointments that have latitude LIKE 'A%'.

[Assistant] SELECT location_lat, coordinates, created_at FROM healthcare.appointments WHERE latitude LIKE 'A%';

[User] What is the max street for each coordinates in appointments?

[Assistant] SELECT coordinates, MAX(street) AS max_street FROM healthcare.appointments GROUP BY coordinates;


[User] What are the patient_id, expires_at, name of each billing?

[Assistant] SELECT patient_id, expires_at, name FROM healthcare.billing;

[User] Show the results sorted by name descending.

[Assistant] SELECT patient_id, expires_at, name FROM healthcare.billing ORDER BY name DESC;

[User] Limit the results to 100 rows.

[Assistant] SELECT patient_id, expires_at, name FROM healthcare.billing ORDER BY name DESC LIMIT 100;


[User] Show me all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] List street, coordinates, language, timezone for each appointment along with their patient information.

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

[User] Restrict the output to 100 items.

[Assistant] SELECT *, patients.language, patients.timezone FROM healthcare.appointments JOIN healthcare.patients ON appointments.patient_id = patients.user_id LIMIT 100;


[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Find appointments modified within the last hour.

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

[User] Get the distribution of appointments across different location_lat values.

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


[User] Get patient_id, barcode, media_url from all billing.

[Assistant] SELECT patient_id, barcode, media_url FROM healthcare.billing;

[User] Sort the results by barcode ascending.

[Assistant] SELECT patient_id, barcode, media_url FROM healthcare.billing ORDER BY barcode ASC;

[User] Sort the results by reserved descending.

[Assistant] SELECT patient_id, barcode, media_url FROM healthcare.billing ORDER BY reserved DESC;


[User] Retrieve expires_at, patient_id, created_at for every billing.

[Assistant] SELECT expires_at, patient_id, created_at FROM healthcare.billing;

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

[Assistant] SELECT expires_at, patient_id, created_at FROM healthcare.billing WHERE media_url LIKE 'A%';

[User] Return just 20 rows.

[Assistant] SELECT expires_at, patient_id, created_at FROM healthcare.billing WHERE media_url LIKE 'A%' LIMIT 20;


[User] Get all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Retrieve latitude, coordinates, created_at, timezone showing the relationship between appointments and patients.

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

[User] Count the number of appointments in each coordinates category.

[Assistant] SELECT coordinates, COUNT(*) AS count FROM healthcare.appointments GROUP BY coordinates 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.patients (
  person_id text PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  updated_at timestamp without time zone,
  country char NOT NULL,
  salt character varying(128) NOT NULL,
  language character varying(128),
  timezone character varying(256) NOT NULL,
  last_login date,
  medical_record_id text -- reference to medical_records.payment_id,
  FOREIGN KEY (medical_record_id) REFERENCES medical_records(payment_id)
)

CREATE TABLE healthcare.prescriptions (
  address_id integer PRIMARY KEY -- unique identifier,
  last_inspected timestamp without time zone,
  created_at timestamp,
  category text,
  timezone character varying(64),
  description text,
  country char NOT NULL,
  geo_point character varying(256) NOT NULL
)

CREATE TABLE healthcare.medical_records (
  payment_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  processed_at date,
  delivery_status character varying(64) NOT NULL,
  subtotal smallint NOT NULL,
  seller_id character varying(256) NOT NULL,
  prescription_id integer -- reference to prescriptions.address_id,
  patient_id text -- reference to patients.person_id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(address_id),
  FOREIGN KEY (patient_id) REFERENCES patients(person_id)
)

[User] Retrieve all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Retrieve patients where medical_record_id LIKE 'A%'.

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

[User] How many patients are there per timezone?

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


[User] Get all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] Retrieve medical_records where subtotal > 78.

[Assistant] SELECT * FROM healthcare.medical_records WHERE subtotal > 78;

[User] Sort the results by updated_at ascending.

[Assistant] SELECT * FROM healthcare.medical_records WHERE subtotal > 78 ORDER BY updated_at ASC;


[User] Get all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Can you order these by medical_record_id descending?

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

[User] What is the average country for each language in patients?

[Assistant] SELECT language, AVERAGE(country) AS average_country FROM healthcare.patients GROUP BY language;


[User] Retrieve all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] Find medical_records between January and March.

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

[User] Can you order these by seller_id ascending?

[Assistant] SELECT * FROM healthcare.medical_records WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY seller_id ASC;


[User] Get medical_record_id, joined_at, timezone from all patients.

[Assistant] SELECT medical_record_id, joined_at, timezone FROM healthcare.patients;

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

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

[User] Show me the count of patients grouped by salt.

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


[User] Display all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Sort the results by salt ascending.

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

[User] Count the number of patients in each medical_record_id category.

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


[User] Retrieve all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] Sort the results by delivery_status ascending.

[Assistant] SELECT * FROM healthcare.medical_records ORDER BY delivery_status ASC;

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.investments (
  id character varying(64) NOT NULL -- unique identifier,
  last_active timestamp without time zone,
  updated_at date,
  password_hash character varying(64),
  username text,
  last_name varchar NOT NULL
)

CREATE TABLE finance.loans (
  employee_id character varying(64) NOT NULL -- unique identifier,
  last_active timestamp,
  last_login timestamp without time zone,
  timezone character varying(128),
  nationality character varying(64),
  state text NOT NULL
)

CREATE TABLE finance.payments (
  id character varying(64) NOT NULL -- unique identifier,
  completed_at timestamp without time zone,
  price numeric(38,14) NOT NULL,
  subtotal decimal NOT NULL,
  status text,
  discount decimal,
  delivery_status character varying(128)
)

[User] List all loans.

[Assistant] SELECT * FROM finance.loans;

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

[Assistant] SELECT * FROM finance.loans ORDER BY timezone DESC;

[User] Get max of timezone by timezone from loans.

[Assistant] SELECT timezone, MAX(timezone) AS max_timezone FROM finance.loans GROUP BY timezone;


[User] Show me last_name, last_active, id for all investments.

[Assistant] SELECT last_name, last_active, id FROM finance.investments;

[User] List investments that have last_name LIKE 'A%'.

[Assistant] SELECT last_name, last_active, id FROM finance.investments WHERE last_name LIKE 'A%';

[User] Limit the results to 25 rows.

[Assistant] SELECT last_name, last_active, id FROM finance.investments WHERE last_name LIKE 'A%' LIMIT 25;


[User] Show me all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

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

[Assistant] SELECT * FROM finance.payments WHERE completed_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY delivery_status DESC;


[User] Show me all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Find loans from last week.

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

[User] Can you order these by last_active ascending?

[Assistant] SELECT * FROM finance.loans WHERE last_login >= CURRENT_DATE - INTERVAL '7 days' ORDER BY last_active ASC;


[User] Retrieve all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Find loans where state LIKE 'A%'.

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

[User] Show me sum of state grouped by last_login for loans.

[Assistant] SELECT last_login, SUM(state) AS sum_state FROM finance.loans GROUP BY last_login;


[User] Get timezone, last_login, last_active from all loans.

[Assistant] SELECT timezone, last_login, last_active FROM finance.loans;

[User] Get loans that match last_login > '2023-01-01'.

[Assistant] SELECT timezone, last_login, last_active FROM finance.loans WHERE last_login > '2023-01-01';

[User] Order the output by employee_id ascending.

[Assistant] SELECT timezone, last_login, last_active FROM finance.loans WHERE last_login > '2023-01-01' ORDER BY employee_id ASC;


[User] Retrieve last_login, timezone, last_active for every loan.

[Assistant] SELECT last_login, timezone, last_active FROM finance.loans;

[User] Show the results sorted by timezone ascending.

[Assistant] SELECT last_login, timezone, last_active FROM finance.loans ORDER BY timezone ASC;

[User] Count the number of loans in each last_active category.

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


[User] Retrieve all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Show the results sorted by username descending.

[Assistant] SELECT * FROM finance.investments ORDER BY username DESC;

[User] Calculate count of id for each last_active in investments.

[Assistant] SELECT last_active, COUNT(id) AS count_id FROM finance.investments GROUP BY last_active;


[User] List all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Sort the results by timezone ascending.

[Assistant] SELECT * FROM finance.loans ORDER BY timezone ASC;

[User] Restrict the output to 25 items.

[Assistant] SELECT * FROM finance.loans ORDER BY timezone ASC LIMIT 25;


[User] Display all investments.

[Assistant] SELECT * FROM finance.investments;

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

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

[User] Get max of password_hash by id from investments.

[Assistant] SELECT id, MAX(password_hash) AS max_password_hash FROM finance.investments GROUP BY 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 humanresources.addresses (
  store_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  address_line2 char NOT NULL,
  postal_code character varying(64),
  latitude char NOT NULL,
  payment_id text -- reference to payments.id,
  FOREIGN KEY (payment_id) REFERENCES payments(id)
)

CREATE TABLE humanresources.payments (
  id text PRIMARY KEY -- unique identifier,
  due_date timestamp,
  processed_at date,
  reference_number character varying(64),
  category character varying(128) NOT NULL,
  payer_id character varying(256) NOT NULL -- identifier for payer,
  approval_status character varying(128),
  customer_id text -- reference to customers.employee_id,
  addresse_id text NOT NULL -- reference to addresses.store_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id),
  FOREIGN KEY (addresse_id) REFERENCES addresses(store_id)
)

CREATE TABLE humanresources.customers (
  employee_id varchar PRIMARY KEY -- unique identifier,
  last_active timestamp,
  joined_at date,
  city text,
  language text,
  status char NOT NULL,
  last_name character varying(64),
  avatar varchar NOT NULL,
  payment_id text NOT NULL -- reference to payments.id,
  addresse_id text NOT NULL -- reference to addresses.store_id,
  FOREIGN KEY (payment_id) REFERENCES payments(id),
  FOREIGN KEY (addresse_id) REFERENCES addresses(store_id)
)

[User] Show me city, last_active, status for all customers.

[Assistant] SELECT city, last_active, status FROM humanresources.customers;

[User] Sort the results by addresse_id ascending.

[Assistant] SELECT city, last_active, status FROM humanresources.customers ORDER BY addresse_id ASC;

[User] Can you order these by language ascending?

[Assistant] SELECT city, last_active, status FROM humanresources.customers ORDER BY language ASC;


[User] Display all payments.

[Assistant] SELECT * FROM humanresources.payments;

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

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

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

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


[User] List last_name, payment_id, city from customers.

[Assistant] SELECT last_name, payment_id, city FROM humanresources.customers;

[User] Order the output by city ascending.

[Assistant] SELECT last_name, payment_id, city FROM humanresources.customers ORDER BY city ASC;

[User] Order the output by last_active ascending.

[Assistant] SELECT last_name, payment_id, city FROM humanresources.customers ORDER BY last_active ASC;


[User] Get processed_at, addresse_id, reference_number from all payments.

[Assistant] SELECT processed_at, addresse_id, reference_number FROM humanresources.payments;

[User] Order the output by payer_id descending.

[Assistant] SELECT processed_at, addresse_id, reference_number FROM humanresources.payments ORDER BY payer_id DESC;

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

[Assistant] SELECT processed_at, addresse_id, reference_number FROM humanresources.payments ORDER BY processed_at ASC;


[User] List all addresses.

[Assistant] SELECT * FROM humanresources.addresses;

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

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

[User] Restrict the output to 15 items.

[Assistant] SELECT * FROM humanresources.addresses WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 15;


[User] Retrieve all customers.

[Assistant] SELECT * FROM humanresources.customers;

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

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

[User] Show me count of addresse_id grouped by city for customers.

[Assistant] SELECT city, COUNT(addresse_id) AS count_addresse_id FROM humanresources.customers GROUP BY city;


[User] Get addresse_id, due_date, payer_id from all payments.

[Assistant] SELECT addresse_id, due_date, payer_id FROM humanresources.payments;

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

[Assistant] SELECT addresse_id, due_date, payer_id FROM humanresources.payments WHERE processed_at > '2023-01-01';

[User] Calculate min of payer_id for each reference_number in payments.

[Assistant] SELECT reference_number, MIN(payer_id) AS min_payer_id FROM humanresources.payments GROUP BY reference_number;


[User] Retrieve addresse_id, approval_status, payer_id for every payment.

[Assistant] SELECT addresse_id, approval_status, payer_id FROM humanresources.payments;

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

[Assistant] SELECT addresse_id, approval_status, payer_id FROM humanresources.payments ORDER BY payer_id ASC;

[User] Get count of payer_id by addresse_id from payments.

[Assistant] SELECT addresse_id, COUNT(payer_id) AS count_payer_id FROM humanresources.payments GROUP BY addresse_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 e-commerce.order_items (
  barcode varchar PRIMARY KEY -- unique identifier,
  expires_at timestamp without time zone,
  updated_at date,
  rating text,
  msrp char,
  tax_rate varchar NOT NULL,
  cost bigint NOT NULL,
  shippin_id text -- reference to shipping.order_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(order_id)
)

CREATE TABLE e-commerce.shipping (
  order_id varchar PRIMARY KEY -- unique identifier,
  processed_at date,
  traded_at timestamp without time zone,
  currency character varying(128),
  seller_id char -- identifier for seller,
  payment_status character varying(64),
  order_item_id text -- reference to order_items.barcode,
  FOREIGN KEY (order_item_id) REFERENCES order_items(barcode)
)

CREATE TABLE e-commerce.orders (
  order_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  amount decimal,
  quantity character varying(128) NOT NULL,
  payment_method character varying(64),
  payment_status character varying(128) NOT NULL,
  seller_id character varying(256),
  delivery_status character varying(256)
)

[User] Display all shipping.

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

[User] Find shipping created yesterday.

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

[User] Calculate min of seller_id for each order_item_id in shipping.

[Assistant] SELECT order_item_id, MIN(seller_id) AS min_seller_id FROM e-commerce.shipping GROUP BY order_item_id;


[User] List tax_rate, updated_at, expires_at from order_items.

[Assistant] SELECT tax_rate, updated_at, expires_at FROM e-commerce.order_items;

[User] Order the output by updated_at descending.

[Assistant] SELECT tax_rate, updated_at, expires_at FROM e-commerce.order_items ORDER BY updated_at DESC;

[User] Limit the results to 15 rows.

[Assistant] SELECT tax_rate, updated_at, expires_at FROM e-commerce.order_items ORDER BY updated_at DESC LIMIT 15;


[User] Retrieve cost, updated_at, tax_rate for every order_item.

[Assistant] SELECT cost, updated_at, tax_rate FROM e-commerce.order_items;

[User] Order the output by cost descending.

[Assistant] SELECT cost, updated_at, tax_rate FROM e-commerce.order_items ORDER BY cost DESC;

[User] Return just 20 rows.

[Assistant] SELECT cost, updated_at, tax_rate FROM e-commerce.order_items ORDER BY cost DESC LIMIT 20;


[User] Retrieve all shipping.

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

[User] Get traded_at, processed_at, updated_at, tax_rate by joining shipping with order_items.

[Assistant] SELECT *, order_items.updated_at, order_items.tax_rate FROM e-commerce.shipping JOIN e-commerce.order_items ON shipping.order_item_id = order_items.barcode;

[User] How many shipping are there per payment_status?

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


[User] Retrieve all order_items.

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

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

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

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

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


[User] List rating, expires_at, cost from order_items.

[Assistant] SELECT rating, expires_at, cost FROM e-commerce.order_items;

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

[Assistant] SELECT rating, expires_at, cost FROM e-commerce.order_items WHERE updated_at > '2023-12-01';

[User] Return just 15 rows.

[Assistant] SELECT rating, expires_at, cost FROM e-commerce.order_items WHERE updated_at > '2023-12-01' LIMIT 15;


[User] What are the expires_at, msrp, rating of each order_item?

[Assistant] SELECT expires_at, msrp, rating FROM e-commerce.order_items;

[User] Get all order_items from 2023.

[Assistant] SELECT expires_at, msrp, rating FROM e-commerce.order_items WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Show the results sorted by cost ascending.

[Assistant] SELECT expires_at, msrp, rating FROM e-commerce.order_items WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY cost ASC;


[User] Get all order_items.

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

[User] Sort the results by updated_at descending.

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

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

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


[User] Show me all order_items.

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

[User] Show me tax_rate, shippin_id, order_item_id, traded_at from order_items and their related shipping.

[Assistant] SELECT *, shipping.order_item_id, shipping.traded_at FROM e-commerce.order_items JOIN e-commerce.shipping ON order_items.shippin_id = shipping.order_id;

[User] Show only 20 records.

[Assistant] SELECT *, shipping.order_item_id, shipping.traded_at FROM e-commerce.order_items JOIN e-commerce.shipping ON order_items.shippin_id = shipping.order_id LIMIT 20;


[User] Show me all order_items.

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

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

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

[User] Calculate min of tax_rate for each shippin_id in order_items.

[Assistant] SELECT shippin_id, MIN(tax_rate) AS min_tax_rate FROM e-commerce.order_items GROUP BY shippin_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 education.teachers (
  payment_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  due_date timestamp,
  payer_id char,
  vendor_id character varying(128) NOT NULL -- identifier for vendor,
  balance integer,
  notes char,
  status character varying(128),
  student_id text -- reference to students.person_id,
  FOREIGN KEY (student_id) REFERENCES students(person_id)
)

CREATE TABLE education.students (
  person_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  country varchar,
  password_hash character varying(256) NOT NULL,
  token character varying(256),
  bio character varying(128) NOT NULL,
  avatar text,
  state char
)

CREATE TABLE education.departments (
  id text PRIMARY KEY -- unique identifier,
  created_at date,
  tax bigint,
  delivery_status character varying(256) NOT NULL,
  seller_id character varying(64)
)

CREATE TABLE education.assignments (
  id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  address_line2 varchar NOT NULL,
  latitude character varying(256),
  city character varying(128),
  parking_available varchar,
  timezone character varying(128) NOT NULL,
  department_id text -- reference to departments.id,
  FOREIGN KEY (department_id) REFERENCES departments(id)
)

[User] Show me parking_available, created_at, latitude for all assignments.

[Assistant] SELECT parking_available, created_at, latitude FROM education.assignments;

[User] Find assignments from last week.

[Assistant] SELECT parking_available, created_at, latitude FROM education.assignments WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

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

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


[User] List created_at, department_id, city from assignments.

[Assistant] SELECT created_at, department_id, city FROM education.assignments;

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

[Assistant] SELECT created_at, department_id, city FROM education.assignments ORDER BY parking_available ASC;

[User] Order the output by id ascending.

[Assistant] SELECT created_at, department_id, city FROM education.assignments ORDER BY id ASC;


[User] Display all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Can you order these by parking_available descending?

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

[User] How many assignments are there per timezone?

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


[User] Retrieve all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

[User] Show the results sorted by notes descending.

[Assistant] SELECT * FROM education.teachers WHERE payment_id LIKE 'A%' ORDER BY notes DESC;


[User] Retrieve department_id, address_line2, id for every assignment.

[Assistant] SELECT department_id, address_line2, id FROM education.assignments;

[User] Get assignments that match address_line2 LIKE 'A%'.

[Assistant] SELECT department_id, address_line2, id FROM education.assignments WHERE address_line2 LIKE 'A%';

[User] What is the min timezone for each created_at in assignments?

[Assistant] SELECT created_at, MIN(timezone) AS min_timezone FROM education.assignments GROUP BY created_at;


[User] Show me all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Can you order these by parking_available descending?

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

[User] Restrict the output to 100 items.

[Assistant] SELECT * FROM education.assignments ORDER BY parking_available DESC LIMIT 100;


[User] What are the latitude, timezone, parking_available of each assignment?

[Assistant] SELECT latitude, timezone, parking_available FROM education.assignments;

[User] List assignments with dates from 2023.

[Assistant] SELECT latitude, timezone, parking_available FROM education.assignments WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Only show the top 15 results.

[Assistant] SELECT latitude, timezone, parking_available FROM education.assignments WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 15;


[User] Show me all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] List address_line2, department_id, seller_id, tax for each assignment along with their department information.

[Assistant] SELECT *, departments.seller_id, departments.tax FROM education.assignments JOIN education.departments ON assignments.department_id = departments.id;

[User] Group assignments by city and show the count of parking_available.

[Assistant] SELECT city, COUNT(parking_available) AS count_parking_available FROM education.assignments GROUP BY city;


[User] Get notes, payer_id, updated_at from all teachers.

[Assistant] SELECT notes, payer_id, updated_at FROM education.teachers;

[User] Can you order these by payer_id ascending?

[Assistant] SELECT notes, payer_id, updated_at FROM education.teachers ORDER BY payer_id ASC;

[User] Order the output by updated_at ascending.

[Assistant] SELECT notes, payer_id, updated_at FROM education.teachers ORDER BY updated_at ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.reviews (
  comment_id text PRIMARY KEY -- unique identifier,
  edited_at timestamp without time zone,
  thumbnail char,
  categories varchar,
  rating text
)

CREATE TABLE e-commerce.orders (
  order_id text PRIMARY KEY -- unique identifier,
  traded_at timestamp,
  amount bigint,
  status character varying(128),
  currency char
)

CREATE TABLE e-commerce.shipping (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  cancelled_at date,
  approval_status char,
  payment_status character varying(128) NOT NULL,
  price smallint,
  subtotal numeric NOT NULL
)

[User] List all reviews.

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

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

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

[User] Tally up reviews by categories.

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


[User] List edited_at, thumbnail, rating from reviews.

[Assistant] SELECT edited_at, thumbnail, rating FROM e-commerce.reviews;

[User] Find reviews where rating LIKE 'A%'.

[Assistant] SELECT edited_at, thumbnail, rating FROM e-commerce.reviews WHERE rating LIKE 'A%';

[User] Only show the top 100 results.

[Assistant] SELECT edited_at, thumbnail, rating FROM e-commerce.reviews WHERE rating LIKE 'A%' LIMIT 100;


[User] Retrieve edited_at, categories, rating for every review.

[Assistant] SELECT edited_at, categories, rating FROM e-commerce.reviews;

[User] Find reviews where edited_at > '2023-01-01'.

[Assistant] SELECT edited_at, categories, rating FROM e-commerce.reviews WHERE edited_at > '2023-01-01';

[User] Order the output by rating descending.

[Assistant] SELECT edited_at, categories, rating FROM e-commerce.reviews WHERE edited_at > '2023-01-01' ORDER BY rating DESC;


[User] List all orders.

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

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

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

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

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


[User] List all reviews.

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

[User] Get all reviews created yesterday.

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

[User] Count the number of reviews in each rating category.

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


[User] Retrieve thumbnail, categories, edited_at for every review.

[Assistant] SELECT thumbnail, categories, edited_at FROM e-commerce.reviews;

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

[Assistant] SELECT thumbnail, categories, edited_at FROM e-commerce.reviews ORDER BY categories ASC;

[User] Show only 25 records.

[Assistant] SELECT thumbnail, categories, edited_at FROM e-commerce.reviews ORDER BY categories ASC LIMIT 25;


[User] Get price, payment_status, invoice_id from all shipping.

[Assistant] SELECT price, payment_status, invoice_id FROM e-commerce.shipping;

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

[Assistant] SELECT price, payment_status, invoice_id FROM e-commerce.shipping WHERE invoice_id LIKE 'A%';

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

[Assistant] SELECT price, payment_status, invoice_id FROM e-commerce.shipping WHERE invoice_id LIKE 'A%' ORDER BY invoice_id DESC;


[User] Show me traded_at, currency, status for all orders.

[Assistant] SELECT traded_at, currency, status FROM e-commerce.orders;

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

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

[User] Tally up orders by amount.

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


[User] Show me payment_status, approval_status, cancelled_at for all shipping.

[Assistant] SELECT payment_status, approval_status, cancelled_at FROM e-commerce.shipping;

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

[Assistant] SELECT payment_status, approval_status, cancelled_at FROM e-commerce.shipping WHERE cancelled_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

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

[Assistant] SELECT payment_status, approval_status, cancelled_at FROM e-commerce.shipping WHERE cancelled_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY payment_status DESC;


[User] Display all reviews.

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

[User] Order the output by categories descending.

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

[User] Show me the count of reviews grouped by edited_at.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.accounts (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  payment_date timestamp,
  invoice_number character varying(256),
  verification_status varchar,
  customer_id text NOT NULL -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

CREATE TABLE finance.loans (
  sku character varying(64) NOT NULL -- unique identifier,
  expires_at date,
  published_at date,
  price numeric(38,14),
  quantity varchar,
  subcategory varchar NOT NULL,
  customer_id text NOT NULL -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

CREATE TABLE finance.customers (
  employee_id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp,
  address char NOT NULL,
  account_status character varying(64),
  zip_code character varying(64) NOT NULL,
  last_name character varying(128),
  birth_date timestamp
)

[User] What are the published_at, expires_at, sku of each loan?

[Assistant] SELECT published_at, expires_at, sku FROM finance.loans;

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

[Assistant] SELECT published_at, expires_at, sku FROM finance.loans WHERE quantity LIKE 'A%';

[User] Group loans by subcategory and show the min of sku.

[Assistant] SELECT subcategory, MIN(sku) AS min_sku FROM finance.loans GROUP BY subcategory;


[User] Retrieve customer_id, published_at, subcategory for every loan.

[Assistant] SELECT customer_id, published_at, subcategory FROM finance.loans;

[User] Can you order these by customer_id ascending?

[Assistant] SELECT customer_id, published_at, subcategory FROM finance.loans ORDER BY customer_id ASC;

[User] Order the output by quantity ascending.

[Assistant] SELECT customer_id, published_at, subcategory FROM finance.loans ORDER BY quantity ASC;


[User] Get price, subcategory, expires_at from all loans.

[Assistant] SELECT price, subcategory, expires_at FROM finance.loans;

[User] Retrieve price, quantity, zip_code, last_name showing the relationship between loans and customers.

[Assistant] SELECT price, subcategory, expires_at, customers.zip_code, customers.last_name FROM finance.loans JOIN finance.customers ON loans.customer_id = customers.employee_id;

[User] Count the number of loans in each sku category.

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


[User] Display all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

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

[User] Only show the top 20 results.

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


[User] Show me quantity, expires_at, customer_id for all loans.

[Assistant] SELECT quantity, expires_at, customer_id FROM finance.loans;

[User] List price, subcategory, address, joined_at for each loan along with their customer information.

[Assistant] SELECT quantity, expires_at, customer_id, customers.address, customers.joined_at FROM finance.loans JOIN finance.customers ON loans.customer_id = customers.employee_id;

[User] Restrict the output to 25 items.

[Assistant] SELECT quantity, expires_at, customer_id, customers.address, customers.joined_at FROM finance.loans JOIN finance.customers ON loans.customer_id = customers.employee_id LIMIT 25;


[User] What are the invoice_number, payment_date, customer_id of each account?

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

[User] Can you order these by verification_status descending?

[Assistant] SELECT invoice_number, payment_date, customer_id FROM finance.accounts ORDER BY verification_status DESC;

[User] Can you order these by verification_status ascending?

[Assistant] SELECT invoice_number, payment_date, customer_id FROM finance.accounts ORDER BY verification_status ASC;


[User] Retrieve published_at, expires_at, sku for every loan.

[Assistant] SELECT published_at, expires_at, sku FROM finance.loans;

[User] Sort the results by customer_id descending.

[Assistant] SELECT published_at, expires_at, sku FROM finance.loans ORDER BY customer_id DESC;

[User] Get max of subcategory by expires_at from loans.

[Assistant] SELECT expires_at, MAX(subcategory) AS max_subcategory FROM finance.loans GROUP BY expires_at;


[User] Get all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Sort the results by customer_id descending.

[Assistant] SELECT * FROM finance.loans ORDER BY customer_id DESC;

[User] Calculate max of sku for each price in loans.

[Assistant] SELECT price, MAX(sku) AS max_sku FROM finance.loans GROUP BY price;


[User] What are the verification_status, customer_id, transaction_id of each account?

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

[User] List accounts that have verification_status LIKE 'A%'.

[Assistant] SELECT verification_status, customer_id, transaction_id FROM finance.accounts WHERE verification_status LIKE 'A%';

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

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