[User] Display all locations.

[Assistant] SELECT * FROM events.locations;

[User] Sort the results by accessibility ascending.

[Assistant] SELECT * FROM events.locations ORDER BY accessibility ASC;

[User] Restrict the output to 100 items.

[Assistant] SELECT * FROM events.locations ORDER BY accessibility ASC LIMIT 100;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE events.locations (
  location_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  parking_available text NOT NULL,
  coordinates char NOT NULL,
  accessibility character varying(64),
  longitude text,
  customer_id integer NOT NULL -- reference to customers.user_id,
  FOREIGN KEY (customer_id) REFERENCES customers(user_id)
)

CREATE TABLE events.customers (
  user_id integer PRIMARY KEY -- unique identifier,
  last_active date,
  website text,
  status text,
  zip_code character varying(256),
  birth_date timestamp,
  email varchar,
  account_status character varying(128)
)

CREATE TABLE events.articles (
  content_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  description text NOT NULL,
  reply_to_id char NOT NULL -- identifier for reply_to,
  thumbnail char
)

[User] Retrieve all locations.

[Assistant] SELECT * FROM events.locations;

[User] Retrieve locations where location_id LIKE 'A%'.

[Assistant] SELECT * FROM events.locations WHERE location_id LIKE 'A%';

[User] Sort the results by longitude ascending.

[Assistant] SELECT * FROM events.locations WHERE location_id LIKE 'A%' ORDER BY longitude ASC;


[User] What are the created_at, customer_id, parking_available of each location?

[Assistant] SELECT created_at, customer_id, parking_available FROM events.locations;

[User] Retrieve locations where customer_id > 28.

[Assistant] SELECT created_at, customer_id, parking_available FROM events.locations WHERE customer_id > 28;

[User] Group locations by created_at and show the count of parking_available.

[Assistant] SELECT created_at, COUNT(parking_available) AS count_parking_available FROM events.locations GROUP BY created_at;


[User] Show me all locations.

[Assistant] SELECT * FROM events.locations;

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

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

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

[Assistant] SELECT * FROM events.locations WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY customer_id ASC;


[User] Get created_at, coordinates, longitude from all locations.

[Assistant] SELECT created_at, coordinates, longitude FROM events.locations;

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

[Assistant] SELECT created_at, coordinates, longitude FROM events.locations WHERE created_at > '2023-01-01';

[User] Return just 15 rows.

[Assistant] SELECT created_at, coordinates, longitude FROM events.locations WHERE created_at > '2023-01-01' LIMIT 15;


[User] Show me all locations.

[Assistant] SELECT * FROM events.locations;

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

[Assistant] SELECT * FROM events.locations WHERE accessibility LIKE 'A%';

[User] Sort the results by customer_id ascending.

[Assistant] SELECT * FROM events.locations WHERE accessibility LIKE 'A%' ORDER BY customer_id ASC;


[User] Display all locations.

[Assistant] SELECT * FROM events.locations;

[User] Show me locations with coordinates LIKE 'A%'.

[Assistant] SELECT * FROM events.locations WHERE coordinates LIKE 'A%';

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

[Assistant] SELECT location_id, COUNT(*) AS count FROM events.locations GROUP BY location_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 finance.customers (
  employee_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  last_active timestamp,
  membership_level varchar,
  bio character varying(256) NOT NULL,
  last_name character varying(64)
)

CREATE TABLE finance.accounts (
  account_id character varying(64) NOT NULL -- unique identifier,
  due_date date,
  updated_at timestamp,
  description text,
  exchange_rate text NOT NULL,
  user_id character varying(128) -- identifier for user,
  credit varchar,
  verification_status character varying(64),
  customer_id text -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

CREATE TABLE finance.investments (
  venue_id integer PRIMARY KEY -- unique identifier,
  last_inspected date,
  updated_at timestamp without time zone,
  name text,
  operating_hours text,
  description character varying(128),
  state text,
  customer_id text -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

[User] Get all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] What verification_status, exchange_rate, bio, membership_level do we have for accounts and their associated customers?

[Assistant] SELECT *, customers.bio, customers.membership_level FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.employee_id;

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

[Assistant] SELECT *, customers.bio, customers.membership_level FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.employee_id ORDER BY description DESC;


[User] Get name, state, customer_id from all investments.

[Assistant] SELECT name, state, customer_id FROM finance.investments;

[User] Can you order these by updated_at ascending?

[Assistant] SELECT name, state, customer_id FROM finance.investments ORDER BY updated_at ASC;

[User] Only show the top 50 results.

[Assistant] SELECT name, state, customer_id FROM finance.investments ORDER BY updated_at ASC LIMIT 50;


[User] Show me all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Show me investments with state LIKE 'A%'.

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

[User] Get min of last_inspected by name from investments.

[Assistant] SELECT name, MIN(last_inspected) AS min_last_inspected FROM finance.investments GROUP BY name;


[User] Display all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Find accounts created yesterday.

[Assistant] SELECT * FROM finance.accounts WHERE due_date = CURRENT_DATE - INTERVAL '1 day';

[User] Can you order these by account_id descending?

[Assistant] SELECT * FROM finance.accounts WHERE due_date = CURRENT_DATE - INTERVAL '1 day' ORDER BY account_id DESC;


[User] Show me all investments.

[Assistant] SELECT * FROM finance.investments;

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

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

[User] How many investments are there per state?

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


[User] Retrieve all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Order the output by updated_at descending.

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

[User] Restrict the output to 50 items.

[Assistant] SELECT * FROM finance.investments ORDER BY updated_at DESC LIMIT 50;


[User] What are the exchange_rate, verification_status, updated_at of each account?

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

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

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

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

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


[User] Retrieve operating_hours, updated_at, customer_id for every investment.

[Assistant] SELECT operating_hours, updated_at, customer_id FROM finance.investments;

[User] Show the results sorted by name ascending.

[Assistant] SELECT operating_hours, updated_at, customer_id FROM finance.investments ORDER BY name ASC;

[User] Show the results sorted by last_inspected descending.

[Assistant] SELECT operating_hours, updated_at, customer_id FROM finance.investments ORDER BY last_inspected DESC;


[User] Get account_id, due_date, updated_at from all accounts.

[Assistant] SELECT account_id, due_date, updated_at FROM finance.accounts;

[User] Get updated_at, customer_id, last_active, membership_level by joining accounts with customers.

[Assistant] SELECT account_id, due_date, updated_at, customers.last_active, customers.membership_level FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.employee_id;

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

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


[User] Show me description, state, updated_at for all investments.

[Assistant] SELECT description, state, updated_at FROM finance.investments;

[User] List name, description, last_name, updated_at for each investment along with their customer information.

[Assistant] SELECT description, state, updated_at, customers.last_name, customers.updated_at FROM finance.investments JOIN finance.customers ON investments.customer_id = customers.employee_id;

[User] Only show the top 50 results.

[Assistant] SELECT description, state, updated_at, customers.last_name, customers.updated_at FROM finance.investments JOIN finance.customers ON investments.customer_id = customers.employee_id 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 education.students (
  employee_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  api_key character varying(64),
  website character varying(128) NOT NULL,
  age character varying(256),
  language varchar,
  address char,
  is_active bit NOT NULL
)

CREATE TABLE education.departments (
  message_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  edited_at date,
  thumbnail text NOT NULL,
  user_id text,
  author_id character varying(128) -- identifier for author,
  tags char,
  description character varying(64),
  text varchar NOT NULL
)

[User] Retrieve all students.

[Assistant] SELECT * FROM education.students;

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

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

[User] Get sum of is_active by language from students.

[Assistant] SELECT language, SUM(is_active) AS sum_is_active FROM education.students GROUP BY language;


[User] List user_id, tags, author_id from departments.

[Assistant] SELECT user_id, tags, author_id FROM education.departments;

[User] Order the output by author_id descending.

[Assistant] SELECT user_id, tags, author_id FROM education.departments ORDER BY author_id DESC;

[User] Order the output by thumbnail ascending.

[Assistant] SELECT user_id, tags, author_id FROM education.departments ORDER BY thumbnail ASC;


[User] What are the language, website, employee_id of each student?

[Assistant] SELECT language, website, employee_id FROM education.students;

[User] Sort the results by created_at descending.

[Assistant] SELECT language, website, employee_id FROM education.students ORDER BY created_at DESC;

[User] How many students are there per created_at?

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


[User] Show me edited_at, description, message_id for all departments.

[Assistant] SELECT edited_at, description, message_id FROM education.departments;

[User] Get all departments created yesterday.

[Assistant] SELECT edited_at, description, message_id FROM education.departments WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

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

[Assistant] SELECT edited_at, description, message_id FROM education.departments WHERE updated_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY tags DESC;


[User] Display all students.

[Assistant] SELECT * FROM education.students;

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

[Assistant] SELECT * FROM education.students ORDER BY api_key ASC;

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

[Assistant] SELECT * FROM education.students ORDER BY employee_id ASC;


[User] Show me all students.

[Assistant] SELECT * FROM education.students;

[User] Show me students with is_active = TRUE.

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

[User] Get sum of employee_id by created_at from students.

[Assistant] SELECT created_at, SUM(employee_id) AS sum_employee_id FROM education.students GROUP BY created_at;


[User] Display all students.

[Assistant] SELECT * FROM education.students;

[User] Retrieve students where age LIKE 'A%'.

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

[User] Sort the results by created_at descending.

[Assistant] SELECT * FROM education.students WHERE age LIKE 'A%' ORDER BY created_at DESC;


[User] Get created_at, address, language from all students.

[Assistant] SELECT created_at, address, language FROM education.students;

[User] Find students from last week.

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

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

[Assistant] SELECT created_at, address, language FROM education.students WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY is_active ASC;


[User] List api_key, age, language from students.

[Assistant] SELECT api_key, age, language FROM education.students;

[User] Retrieve students where age LIKE 'A%'.

[Assistant] SELECT api_key, age, language FROM education.students WHERE age LIKE 'A%';

[User] Only show the top 10 results.

[Assistant] SELECT api_key, age, language FROM education.students WHERE age LIKE 'A%' LIMIT 10;


[User] List description, author_id, user_id from departments.

[Assistant] SELECT description, author_id, user_id FROM education.departments;

[User] Show the results sorted by description descending.

[Assistant] SELECT description, author_id, user_id FROM education.departments ORDER BY description DESC;

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

[Assistant] SELECT updated_at, MAX(user_id) AS max_user_id FROM education.departments GROUP BY updated_at;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.transactions (
  invoice_id integer PRIMARY KEY -- unique identifier,
  completed_at date,
  account_id character varying(256),
  fee character varying(256),
  card_type character varying(128),
  delivery_status character varying(128) NOT NULL,
  payment_method character varying(256),
  customer_id character varying(64) -- identifier for customer
)

CREATE TABLE finance.customers (
  employee_id varchar PRIMARY KEY -- unique identifier,
  last_active timestamp,
  joined_at timestamp,
  is_active bit -- indicates if active is true,
  account_status character varying(64),
  status character varying(128),
  is_verified bit NOT NULL -- indicates if verified is true,
  profile_picture_url character varying(64),
  payment_id text NOT NULL -- reference to payments.transaction_id,
  transaction_id integer NOT NULL -- reference to transactions.invoice_id,
  FOREIGN KEY (payment_id) REFERENCES payments(transaction_id),
  FOREIGN KEY (transaction_id) REFERENCES transactions(invoice_id)
)

CREATE TABLE finance.payments (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  cancelled_at date,
  created_at timestamp without time zone,
  total numeric,
  user_id character varying(256),
  account_id char -- identifier for account,
  card_type char,
  product_id char NOT NULL -- identifier for product,
  customer_id text NOT NULL -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

[User] Display all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Can you order these by product_id descending?

[Assistant] SELECT * FROM finance.payments WHERE created_at > '2023-01-01' ORDER BY product_id DESC;


[User] Display all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Get min of product_id by product_id from payments.

[Assistant] SELECT product_id, MIN(product_id) AS min_product_id FROM finance.payments GROUP BY product_id;


[User] Get all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Restrict the output to 5 items.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.transactions (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  processed_at date,
  cancelled_at timestamp without time zone,
  payment_status char,
  amount bigint NOT NULL,
  approval_status character varying(64),
  payment_id text NOT NULL -- reference to payments.transaction_id,
  FOREIGN KEY (payment_id) REFERENCES payments(transaction_id)
)

CREATE TABLE finance.audits (
  id varchar PRIMARY KEY -- unique identifier,
  processed_at date,
  account_id text,
  subtotal numeric,
  card_type text NOT NULL,
  customer_id char,
  payment_method character varying(64),
  product_id character varying(256) NOT NULL,
  payment_id text NOT NULL -- reference to payments.transaction_id,
  FOREIGN KEY (payment_id) REFERENCES payments(transaction_id)
)

CREATE TABLE finance.payments (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  traded_at date,
  payment_method character varying(64),
  quantity text,
  payment_status character varying(64),
  tax numeric(38,14) NOT NULL,
  audit_id text -- reference to audits.id,
  FOREIGN KEY (audit_id) REFERENCES audits(id)
)

[User] Show me all audits.

[Assistant] SELECT * FROM finance.audits;

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

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

[User] Limit the results to 20 rows.

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


[User] Retrieve amount, cancelled_at, payment_id for every transaction.

[Assistant] SELECT amount, cancelled_at, payment_id FROM finance.transactions;

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

[Assistant] SELECT amount, cancelled_at, payment_id FROM finance.transactions WHERE processed_at > '2023-01-01';

[User] Only show the top 20 results.

[Assistant] SELECT amount, cancelled_at, payment_id FROM finance.transactions WHERE processed_at > '2023-01-01' LIMIT 20;


[User] What are the payment_id, customer_id, payment_method of each audit?

[Assistant] SELECT payment_id, customer_id, payment_method FROM finance.audits;

[User] Get account_id, payment_method, traded_at, audit_id by joining audits with payments.

[Assistant] SELECT payment_id, customer_id, payment_method, payments.traded_at, payments.audit_id FROM finance.audits JOIN finance.payments ON audits.payment_id = payments.transaction_id;

[User] Show only 50 records.

[Assistant] SELECT payment_id, customer_id, payment_method, payments.traded_at, payments.audit_id FROM finance.audits JOIN finance.payments ON audits.payment_id = payments.transaction_id LIMIT 50;


[User] Show me all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Get processed_at, payment_id, traded_at, quantity by joining transactions with payments.

[Assistant] SELECT *, payments.traded_at, payments.quantity FROM finance.transactions JOIN finance.payments ON transactions.payment_id = payments.transaction_id;

[User] Get average of payment_id by cancelled_at from transactions.

[Assistant] SELECT cancelled_at, AVERAGE(payment_id) AS average_payment_id FROM finance.transactions GROUP BY cancelled_at;


[User] Show me all transactions.

[Assistant] SELECT * FROM finance.transactions;

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

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

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

[Assistant] SELECT * FROM finance.transactions WHERE processed_at > '2023-12-01' ORDER BY amount DESC;


[User] What are the payment_status, payment_id, cancelled_at of each transaction?

[Assistant] SELECT payment_status, payment_id, cancelled_at FROM finance.transactions;

[User] Sort the results by payment_status ascending.

[Assistant] SELECT payment_status, payment_id, cancelled_at FROM finance.transactions ORDER BY payment_status ASC;

[User] Return just 25 rows.

[Assistant] SELECT payment_status, payment_id, cancelled_at FROM finance.transactions ORDER BY payment_status ASC LIMIT 25;


[User] Retrieve amount, cancelled_at, processed_at for every transaction.

[Assistant] SELECT amount, cancelled_at, processed_at FROM finance.transactions;

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

[Assistant] SELECT amount, cancelled_at, processed_at FROM finance.transactions WHERE processed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Restrict the output to 5 items.

[Assistant] SELECT amount, cancelled_at, processed_at FROM finance.transactions WHERE processed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 5;


[User] Show me all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Get all transactions from 2023.

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

[User] Order the output by approval_status descending.

[Assistant] SELECT * FROM finance.transactions WHERE cancelled_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY approval_status DESC;


[User] Get all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Get transactions that match amount > 35.

[Assistant] SELECT * FROM finance.transactions WHERE amount > 35;

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM finance.transactions WHERE amount > 35 LIMIT 10;


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Get all transactions older than 6 months.

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

[User] Tally up transactions by payment_status.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.products (
  barcode character varying(64) NOT NULL -- unique identifier,
  created_at date,
  video_url character varying(128),
  subcategory character varying(128),
  stock_level character varying(256),
  msrp character varying(256),
  shippin_id integer NOT NULL -- reference to shipping.content_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(content_id)
)

CREATE TABLE e-commerce.shipping (
  content_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  published_at timestamp without time zone,
  likes char,
  format character varying(256),
  reply_to_id character varying(256) -- identifier for reply_to,
  body char,
  visibility character varying(64),
  thumbnail character varying(64) NOT NULL
)

[User] Get all products.

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

[User] Get msrp, created_at, thumbnail, created_at by joining products with shipping.

[Assistant] SELECT *, shipping.thumbnail, shipping.created_at FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.content_id;

[User] Limit the results to 25 rows.

[Assistant] SELECT *, shipping.thumbnail, shipping.created_at FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.content_id LIMIT 25;


[User] Get all products.

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

[User] Retrieve barcode, created_at, likes, body showing the relationship between products and shipping.

[Assistant] SELECT *, shipping.likes, shipping.body FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.content_id;

[User] Restrict the output to 10 items.

[Assistant] SELECT *, shipping.likes, shipping.body FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.content_id LIMIT 10;


[User] List all products.

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

[User] Show me msrp, stock_level, likes, visibility from products and their related shipping.

[Assistant] SELECT *, shipping.likes, shipping.visibility FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.content_id;

[User] Group products by stock_level and show the sum of stock_level.

[Assistant] SELECT stock_level, SUM(stock_level) AS sum_stock_level FROM e-commerce.products GROUP BY stock_level;


[User] Get subcategory, video_url, shippin_id from all products.

[Assistant] SELECT subcategory, video_url, shippin_id FROM e-commerce.products;

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

[Assistant] SELECT subcategory, video_url, shippin_id FROM e-commerce.products WHERE barcode LIKE 'A%';

[User] Get sum of barcode by barcode from products.

[Assistant] SELECT barcode, SUM(barcode) AS sum_barcode FROM e-commerce.products GROUP BY barcode;


[User] Retrieve all products.

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

[User] Find products from 2023.

[Assistant] SELECT * FROM e-commerce.products WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Count the number of products in each stock_level category.

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


[User] Retrieve shippin_id, barcode, created_at for every product.

[Assistant] SELECT shippin_id, barcode, created_at FROM e-commerce.products;

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

[Assistant] SELECT shippin_id, barcode, created_at FROM e-commerce.products WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

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

[Assistant] SELECT shippin_id, barcode, created_at FROM e-commerce.products WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY barcode ASC;


[User] What are the created_at, msrp, barcode of each product?

[Assistant] SELECT created_at, msrp, barcode FROM e-commerce.products;

[User] Can you order these by shippin_id ascending?

[Assistant] SELECT created_at, msrp, barcode FROM e-commerce.products ORDER BY shippin_id ASC;

[User] Show the results sorted by subcategory descending.

[Assistant] SELECT created_at, msrp, barcode FROM e-commerce.products ORDER BY subcategory DESC;


[User] What are the barcode, shippin_id, video_url of each product?

[Assistant] SELECT barcode, shippin_id, video_url FROM e-commerce.products;

[User] List barcode, subcategory, likes, reply_to_id for each product along with their shipping information.

[Assistant] SELECT barcode, shippin_id, video_url, shipping.likes, shipping.reply_to_id FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.content_id;

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

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


[User] What are the stock_level, shippin_id, video_url of each product?

[Assistant] SELECT stock_level, shippin_id, video_url FROM e-commerce.products;

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

[Assistant] SELECT stock_level, shippin_id, video_url FROM e-commerce.products WHERE subcategory LIKE 'A%';

[User] Show the results sorted by created_at descending.

[Assistant] SELECT stock_level, shippin_id, video_url FROM e-commerce.products WHERE subcategory LIKE 'A%' ORDER BY created_at DESC;


[User] Show me msrp, created_at, shippin_id for all products.

[Assistant] SELECT msrp, created_at, shippin_id FROM e-commerce.products;

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

[Assistant] SELECT msrp, created_at, shippin_id FROM e-commerce.products WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Show me sum of created_at grouped by barcode for products.

[Assistant] SELECT barcode, SUM(created_at) AS sum_created_at FROM e-commerce.products GROUP BY barcode;


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.prescriptions (
  payment_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  user_id character varying(256),
  status character varying(128),
  verification_status varchar,
  customer_id varchar,
  vendor_id character varying(128),
  invoice_number character varying(256) NOT NULL,
  patient_id text NOT NULL -- reference to patients.id,
  FOREIGN KEY (patient_id) REFERENCES patients(id)
)

CREATE TABLE healthcare.patients (
  id varchar PRIMARY KEY -- unique identifier,
  last_active date,
  full_name char NOT NULL,
  birth_date date,
  website char,
  address character varying(64)
)

[User] List all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Get customer_id, processed_at, full_name, birth_date by joining prescriptions with patients.

[Assistant] SELECT *, patients.full_name, patients.birth_date FROM healthcare.prescriptions JOIN healthcare.patients ON prescriptions.patient_id = patients.id;

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

[Assistant] SELECT *, patients.full_name, patients.birth_date FROM healthcare.prescriptions JOIN healthcare.patients ON prescriptions.patient_id = patients.id ORDER BY status DESC;


[User] List all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

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

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

[User] Return just 5 rows.

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


[User] What are the user_id, status, patient_id of each prescription?

[Assistant] SELECT user_id, status, patient_id FROM healthcare.prescriptions;

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

[Assistant] SELECT user_id, status, patient_id FROM healthcare.prescriptions WHERE processed_at > '2023-12-01';

[User] Return just 20 rows.

[Assistant] SELECT user_id, status, patient_id FROM healthcare.prescriptions WHERE processed_at > '2023-12-01' LIMIT 20;


[User] Get all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Get prescriptions that match customer_id LIKE 'A%'.

[Assistant] SELECT * FROM healthcare.prescriptions WHERE customer_id LIKE 'A%';

[User] Calculate max of patient_id for each verification_status in prescriptions.

[Assistant] SELECT verification_status, MAX(patient_id) AS max_patient_id FROM healthcare.prescriptions GROUP BY verification_status;


[User] Retrieve all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] What status, user_id, website, full_name do we have for prescriptions and their associated patients?

[Assistant] SELECT *, patients.website, patients.full_name FROM healthcare.prescriptions JOIN healthcare.patients ON prescriptions.patient_id = patients.id;

[User] Can you order these by invoice_number ascending?

[Assistant] SELECT *, patients.website, patients.full_name FROM healthcare.prescriptions JOIN healthcare.patients ON prescriptions.patient_id = patients.id ORDER BY invoice_number ASC;


[User] Retrieve all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

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

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

[User] Show me max of processed_at grouped by status for prescriptions.

[Assistant] SELECT status, MAX(processed_at) AS max_processed_at FROM healthcare.prescriptions GROUP BY status;


[User] Get patient_id, user_id, customer_id from all prescriptions.

[Assistant] SELECT patient_id, user_id, customer_id FROM healthcare.prescriptions;

[User] Get prescriptions that match verification_status LIKE 'A%'.

[Assistant] SELECT patient_id, user_id, customer_id FROM healthcare.prescriptions WHERE verification_status LIKE 'A%';

[User] Can you order these by processed_at descending?

[Assistant] SELECT patient_id, user_id, customer_id FROM healthcare.prescriptions WHERE verification_status LIKE 'A%' ORDER BY processed_at DESC;


[User] Get verification_status, invoice_number, vendor_id from all prescriptions.

[Assistant] SELECT verification_status, invoice_number, vendor_id FROM healthcare.prescriptions;

[User] Retrieve processed_at, user_id, birth_date, full_name showing the relationship between prescriptions and patients.

[Assistant] SELECT verification_status, invoice_number, vendor_id, patients.birth_date, patients.full_name FROM healthcare.prescriptions JOIN healthcare.patients ON prescriptions.patient_id = patients.id;

[User] Can you order these by user_id descending?

[Assistant] SELECT verification_status, invoice_number, vendor_id, patients.birth_date, patients.full_name FROM healthcare.prescriptions JOIN healthcare.patients ON prescriptions.patient_id = patients.id ORDER BY user_id DESC;


[User] Retrieve all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Retrieve customer_id, processed_at, website, address showing the relationship between prescriptions and patients.

[Assistant] SELECT *, patients.website, patients.address FROM healthcare.prescriptions JOIN healthcare.patients ON prescriptions.patient_id = patients.id;

[User] Calculate max of user_id for each status in prescriptions.

[Assistant] SELECT status, MAX(user_id) AS max_user_id FROM healthcare.prescriptions GROUP BY status;


[User] What are the customer_id, processed_at, patient_id of each prescription?

[Assistant] SELECT customer_id, processed_at, patient_id FROM healthcare.prescriptions;

[User] Sort the results by vendor_id ascending.

[Assistant] SELECT customer_id, processed_at, patient_id FROM healthcare.prescriptions ORDER BY vendor_id ASC;

[User] Show me the count of prescriptions grouped by customer_id.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE travel.venues (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  last_inspected timestamp without time zone,
  operating_hours text NOT NULL,
  geo_point character varying(64) NOT NULL,
  longitude character varying(128),
  location_lon varchar,
  user_id integer -- reference to users.customer_id,
  FOREIGN KEY (user_id) REFERENCES users(customer_id)
)

CREATE TABLE travel.bookings (
  invoice_id integer PRIMARY KEY -- unique identifier,
  traded_at timestamp,
  total smallint,
  approval_status varchar,
  seller_id character varying(64),
  payment_method text,
  quantity character varying(256),
  account_id text -- identifier for account
)

CREATE TABLE travel.users (
  customer_id integer PRIMARY KEY -- unique identifier,
  last_active date,
  password_hash text,
  username char,
  is_verified bit NOT NULL,
  is_active bit NOT NULL -- indicates if active is true,
  booking_id integer -- reference to bookings.invoice_id,
  FOREIGN KEY (booking_id) REFERENCES bookings(invoice_id)
)

[User] Retrieve all venues.

[Assistant] SELECT * FROM travel.venues;

[User] Show me location_lon, user_id, username, password_hash from venues and their related users.

[Assistant] SELECT *, users.username, users.password_hash FROM travel.venues JOIN travel.users ON venues.user_id = users.customer_id;

[User] Order the output by last_inspected ascending.

[Assistant] SELECT *, users.username, users.password_hash FROM travel.venues JOIN travel.users ON venues.user_id = users.customer_id ORDER BY last_inspected ASC;


[User] Get last_inspected, location_lon, operating_hours from all venues.

[Assistant] SELECT last_inspected, location_lon, operating_hours FROM travel.venues;

[User] List venues with dates from last week.

[Assistant] SELECT last_inspected, location_lon, operating_hours FROM travel.venues WHERE last_inspected >= CURRENT_DATE - INTERVAL '7 days';

[User] Sort the results by updated_at descending.

[Assistant] SELECT last_inspected, location_lon, operating_hours FROM travel.venues WHERE last_inspected >= CURRENT_DATE - INTERVAL '7 days' ORDER BY updated_at DESC;


[User] Show me is_verified, last_active, booking_id for all users.

[Assistant] SELECT is_verified, last_active, booking_id FROM travel.users;

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

[Assistant] SELECT is_verified, last_active, booking_id FROM travel.users WHERE username LIKE 'A%';

[User] Group users by last_active and show the max of last_active.

[Assistant] SELECT last_active, MAX(last_active) AS max_last_active FROM travel.users GROUP BY last_active;


[User] Get all venues.

[Assistant] SELECT * FROM travel.venues;

[User] Show me last_inspected, operating_hours, is_verified, last_active from venues and their related users.

[Assistant] SELECT *, users.is_verified, users.last_active FROM travel.venues JOIN travel.users ON venues.user_id = users.customer_id;

[User] Tally up venues by geo_point.

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


[User] List booking_id, password_hash, username from users.

[Assistant] SELECT booking_id, password_hash, username FROM travel.users;

[User] List users with dates created yesterday.

[Assistant] SELECT booking_id, password_hash, username FROM travel.users WHERE last_active = CURRENT_DATE - INTERVAL '1 day';

[User] Return just 5 rows.

[Assistant] SELECT booking_id, password_hash, username FROM travel.users WHERE last_active = CURRENT_DATE - INTERVAL '1 day' LIMIT 5;


[User] Display all users.

[Assistant] SELECT * FROM travel.users;

[User] Show the results sorted by username ascending.

[Assistant] SELECT * FROM travel.users ORDER BY username ASC;

[User] Show only 50 records.

[Assistant] SELECT * FROM travel.users ORDER BY username ASC LIMIT 50;


[User] Display all users.

[Assistant] SELECT * FROM travel.users;

[User] Get all users from last week.

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

[User] How many users are there per last_active?

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


[User] Get last_inspected, longitude, geo_point from all venues.

[Assistant] SELECT last_inspected, longitude, geo_point FROM travel.venues;

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

[Assistant] SELECT last_inspected, longitude, geo_point FROM travel.venues WHERE geo_point LIKE 'A%';

[User] Show only 25 records.

[Assistant] SELECT last_inspected, longitude, geo_point FROM travel.venues WHERE geo_point LIKE 'A%' LIMIT 25;


[User] List is_active, is_verified, password_hash from users.

[Assistant] SELECT is_active, is_verified, password_hash FROM travel.users;

[User] Find users where is_active = TRUE.

[Assistant] SELECT is_active, is_verified, password_hash FROM travel.users WHERE is_active = TRUE;

[User] Restrict the output to 50 items.

[Assistant] SELECT is_active, is_verified, password_hash FROM travel.users WHERE is_active = TRUE LIMIT 50;


[User] List all users.

[Assistant] SELECT * FROM travel.users;

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

[Assistant] SELECT * FROM travel.users ORDER BY is_active DESC;

[User] Return just 50 rows.

[Assistant] SELECT * FROM travel.users ORDER BY is_active DESC 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 tradingplatform.orders (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  completed_at timestamp,
  created_at date,
  tax numeric(38,14) NOT NULL,
  approval_status character varying(64),
  subtotal decimal,
  wallet_id integer -- reference to wallets.payment_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(payment_id)
)

CREATE TABLE tradingplatform.logs (
  payment_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  price numeric(38,14) NOT NULL,
  product_id text -- identifier for product,
  subtotal smallint,
  delivery_status varchar,
  user_id varchar,
  card_type text
)

CREATE TABLE tradingplatform.wallets (
  payment_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  payment_date date,
  exchange_rate text,
  debit character varying(64) NOT NULL,
  invoice_number character varying(128),
  category text
)

[User] Get completed_at, approval_status, invoice_id from all orders.

[Assistant] SELECT completed_at, approval_status, invoice_id FROM tradingplatform.orders;

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

[Assistant] SELECT completed_at, approval_status, invoice_id FROM tradingplatform.orders ORDER BY completed_at ASC;

[User] Show only 50 records.

[Assistant] SELECT completed_at, approval_status, invoice_id FROM tradingplatform.orders ORDER BY completed_at ASC LIMIT 50;


[User] Show me all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Can you order these by invoice_id ascending?

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

[User] Return just 10 rows.

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY invoice_id ASC LIMIT 10;


[User] Retrieve all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Show the results sorted by wallet_id ascending.

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

[User] Show the results sorted by invoice_id ascending.

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


[User] Show me all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Retrieve invoice_id, completed_at, invoice_number, debit showing the relationship between orders and wallets.

[Assistant] SELECT *, wallets.invoice_number, wallets.debit FROM tradingplatform.orders JOIN tradingplatform.wallets ON orders.wallet_id = wallets.payment_id;

[User] Tally up orders by created_at.

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


[User] Retrieve approval_status, subtotal, tax for every order.

[Assistant] SELECT approval_status, subtotal, tax FROM tradingplatform.orders;

[User] Sort the results by tax descending.

[Assistant] SELECT approval_status, subtotal, tax FROM tradingplatform.orders ORDER BY tax DESC;

[User] Order the output by completed_at ascending.

[Assistant] SELECT approval_status, subtotal, tax FROM tradingplatform.orders ORDER BY completed_at ASC;


[User] Retrieve wallet_id, approval_status, tax for every order.

[Assistant] SELECT wallet_id, approval_status, tax FROM tradingplatform.orders;

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

[Assistant] SELECT wallet_id, approval_status, tax FROM tradingplatform.orders WHERE approval_status LIKE 'A%';

[User] Show the results sorted by wallet_id descending.

[Assistant] SELECT wallet_id, approval_status, tax FROM tradingplatform.orders WHERE approval_status LIKE 'A%' ORDER BY wallet_id DESC;


[User] Display all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

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

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

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


[User] Retrieve all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Sort the results by invoice_id ascending.

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

[User] Show the results sorted by subtotal descending.

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


[User] What are the created_at, wallet_id, tax of each order?

[Assistant] SELECT created_at, wallet_id, tax FROM tradingplatform.orders;

[User] Get subtotal, completed_at, payment_date, exchange_rate by joining orders with wallets.

[Assistant] SELECT created_at, wallet_id, tax, wallets.payment_date, wallets.exchange_rate FROM tradingplatform.orders JOIN tradingplatform.wallets ON orders.wallet_id = wallets.payment_id;

[User] Calculate min of invoice_id for each tax in orders.

[Assistant] SELECT tax, MIN(invoice_id) AS min_invoice_id FROM tradingplatform.orders GROUP BY tax;


[User] List tax, approval_status, wallet_id from orders.

[Assistant] SELECT tax, approval_status, wallet_id FROM tradingplatform.orders;

[User] What completed_at, wallet_id, category, updated_at do we have for orders and their associated wallets?

[Assistant] SELECT tax, approval_status, wallet_id, wallets.category, wallets.updated_at FROM tradingplatform.orders JOIN tradingplatform.wallets ON orders.wallet_id = wallets.payment_id;

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE inventory.goods (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at timestamp without time zone,
  subcategory character varying(64) NOT NULL,
  image_url character varying(128) NOT NULL,
  backorder character varying(256),
  quantity character varying(256),
  location_id integer NOT NULL -- reference to locations.id,
  FOREIGN KEY (location_id) REFERENCES locations(id)
)

CREATE TABLE inventory.locations (
  id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  description char,
  parking_available text,
  timezone character varying(128)
)

[User] List all goods.

[Assistant] SELECT * FROM inventory.goods;

[User] Get goods that match quantity LIKE 'A%'.

[Assistant] SELECT * FROM inventory.goods WHERE quantity LIKE 'A%';

[User] Get the distribution of goods across different subcategory values.

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


[User] List quantity, image_url, subcategory from goods.

[Assistant] SELECT quantity, image_url, subcategory FROM inventory.goods;

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

[Assistant] SELECT quantity, image_url, subcategory FROM inventory.goods WHERE image_url LIKE 'A%';

[User] Group goods by backorder and show the max of created_at.

[Assistant] SELECT backorder, MAX(created_at) AS max_created_at FROM inventory.goods GROUP BY backorder;


[User] Display all goods.

[Assistant] SELECT * FROM inventory.goods;

[User] List goods that have location_id > 10.

[Assistant] SELECT * FROM inventory.goods WHERE location_id > 10;

[User] Limit the results to 25 rows.

[Assistant] SELECT * FROM inventory.goods WHERE location_id > 10 LIMIT 25;


[User] Get all goods.

[Assistant] SELECT * FROM inventory.goods;

[User] What subcategory, backorder, updated_at, parking_available do we have for goods and their associated locations?

[Assistant] SELECT *, locations.updated_at, locations.parking_available FROM inventory.goods JOIN inventory.locations ON goods.location_id = locations.id;

[User] Get max of image_url by image_url from goods.

[Assistant] SELECT image_url, MAX(image_url) AS max_image_url FROM inventory.goods GROUP BY image_url;


[User] Show me location_id, created_at, subcategory for all goods.

[Assistant] SELECT location_id, created_at, subcategory FROM inventory.goods;

[User] Sort the results by updated_at descending.

[Assistant] SELECT location_id, created_at, subcategory FROM inventory.goods ORDER BY updated_at DESC;

[User] Get max of updated_at by subcategory from goods.

[Assistant] SELECT subcategory, MAX(updated_at) AS max_updated_at FROM inventory.goods GROUP BY subcategory;


[User] List created_at, backorder, image_url from goods.

[Assistant] SELECT created_at, backorder, image_url FROM inventory.goods;

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

[Assistant] SELECT created_at, backorder, image_url FROM inventory.goods WHERE updated_at > '2023-12-01';

[User] Group goods by image_url and show the average of created_at.

[Assistant] SELECT image_url, AVERAGE(created_at) AS average_created_at FROM inventory.goods GROUP BY image_url;


[User] Display all goods.

[Assistant] SELECT * FROM inventory.goods;

[User] Can you order these by created_at ascending?

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

[User] Sort the results by image_url descending.

[Assistant] SELECT * FROM inventory.goods ORDER BY image_url DESC;


[User] Show me backorder, quantity, created_at for all goods.

[Assistant] SELECT backorder, quantity, created_at FROM inventory.goods;

[User] What location_id, subcategory, timezone, description do we have for goods and their associated locations?

[Assistant] SELECT backorder, quantity, created_at, locations.timezone, locations.description FROM inventory.goods JOIN inventory.locations ON goods.location_id = locations.id;

[User] Get min of created_at by quantity from goods.

[Assistant] SELECT quantity, MIN(created_at) AS min_created_at FROM inventory.goods GROUP BY quantity;


[User] List image_url, quantity, created_at from goods.

[Assistant] SELECT image_url, quantity, created_at FROM inventory.goods;

[User] List goods that have subcategory LIKE 'A%'.

[Assistant] SELECT image_url, quantity, created_at FROM inventory.goods WHERE subcategory LIKE 'A%';

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

[Assistant] SELECT image_url, quantity, created_at FROM inventory.goods WHERE subcategory LIKE 'A%' ORDER BY created_at DESC;


[User] Retrieve location_id, created_at, quantity for every good.

[Assistant] SELECT location_id, created_at, quantity FROM inventory.goods;

[User] List goods that have location_id > 89.

[Assistant] SELECT location_id, created_at, quantity FROM inventory.goods WHERE location_id > 89;

[User] Group goods by quantity and show the count of location_id.

[Assistant] SELECT quantity, COUNT(location_id) AS count_location_id FROM inventory.goods GROUP BY quantity;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.transactions (
  id character varying(64) NOT NULL -- unique identifier,
  traded_at timestamp without time zone,
  exchange_rate text,
  total numeric NOT NULL,
  card_type character varying(128) NOT NULL,
  loan_id text -- reference to loans.content_id,
  FOREIGN KEY (loan_id) REFERENCES loans(content_id)
)

CREATE TABLE finance.loans (
  content_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  score character varying(256),
  rating character varying(128),
  views char,
  categories text NOT NULL,
  subject character varying(256)
)

[User] What are the exchange_rate, traded_at, loan_id of each transaction?

[Assistant] SELECT exchange_rate, traded_at, loan_id FROM finance.transactions;

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

[Assistant] SELECT exchange_rate, traded_at, loan_id FROM finance.transactions WHERE traded_at > '2023-12-01';

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

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


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] List card_type, loan_id, rating, views for each transaction along with their loan information.

[Assistant] SELECT *, loans.rating, loans.views FROM finance.transactions JOIN finance.loans ON transactions.loan_id = loans.content_id;

[User] Tally up transactions by total.

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


[User] Retrieve all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Get loan_id, card_type, score, subject by joining transactions with loans.

[Assistant] SELECT *, loans.score, loans.subject FROM finance.transactions JOIN finance.loans ON transactions.loan_id = loans.content_id;

[User] Tally up transactions by id.

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


[User] Show me all transactions.

[Assistant] SELECT * FROM finance.transactions;

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

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

[User] Show the results sorted by id descending.

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


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Retrieve transactions where total > 7.

[Assistant] SELECT * FROM finance.transactions WHERE total > 7;

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

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


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Retrieve loan_id, card_type, score, updated_at showing the relationship between transactions and loans.

[Assistant] SELECT *, loans.score, loans.updated_at FROM finance.transactions JOIN finance.loans ON transactions.loan_id = loans.content_id;

[User] Sort the results by id descending.

[Assistant] SELECT *, loans.score, loans.updated_at FROM finance.transactions JOIN finance.loans ON transactions.loan_id = loans.content_id ORDER BY id DESC;


[User] Display all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Get all transactions between January and March.

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

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

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


[User] Get total, exchange_rate, id from all transactions.

[Assistant] SELECT total, exchange_rate, id FROM finance.transactions;

[User] List traded_at, total, updated_at, score for each transaction along with their loan information.

[Assistant] SELECT total, exchange_rate, id, loans.updated_at, loans.score FROM finance.transactions JOIN finance.loans ON transactions.loan_id = loans.content_id;

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

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


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Show me transactions with exchange_rate LIKE 'A%'.

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

[User] Limit the results to 10 rows.

[Assistant] SELECT * FROM finance.transactions WHERE exchange_rate LIKE 'A%' LIMIT 10;


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Retrieve loan_id, card_type, views, categories showing the relationship between transactions and loans.

[Assistant] SELECT *, loans.views, loans.categories FROM finance.transactions JOIN finance.loans ON transactions.loan_id = loans.content_id;

[User] Get max of card_type by id from transactions.

[Assistant] SELECT id, MAX(card_type) AS max_card_type FROM finance.transactions 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 healthcare.appointments (
  employee_id text PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  last_active timestamp,
  nationality text,
  last_name char NOT NULL,
  city character varying(64),
  state char NOT NULL,
  is_verified boolean -- indicates if verified is true,
  full_name text,
  billin_id text NOT NULL -- reference to billing.id,
  FOREIGN KEY (billin_id) REFERENCES billing(id)
)

CREATE TABLE healthcare.billing (
  id varchar PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  created_at date,
  reference_number text NOT NULL,
  approval_status character varying(64) NOT NULL,
  reconciliation_status character varying(64),
  vendor_id char -- identifier for vendor,
  category char,
  medical_record_id integer -- reference to medical_records.id,
  appointment_id text -- reference to appointments.employee_id,
  FOREIGN KEY (medical_record_id) REFERENCES medical_records(id),
  FOREIGN KEY (appointment_id) REFERENCES appointments(employee_id)
)

CREATE TABLE healthcare.medical_records (
  id integer PRIMARY KEY -- unique identifier,
  due_date timestamp,
  category char NOT NULL,
  vendor_id char,
  currency character varying(128),
  reconciliation_status character varying(64),
  payee_id character varying(256) -- identifier for payee,
  billin_id text -- reference to billing.id,
  FOREIGN KEY (billin_id) REFERENCES billing(id)
)

[User] What are the state, city, full_name of each appointment?

[Assistant] SELECT state, city, full_name FROM healthcare.appointments;

[User] Can you order these by joined_at descending?

[Assistant] SELECT state, city, full_name FROM healthcare.appointments ORDER BY joined_at DESC;

[User] Show only 25 records.

[Assistant] SELECT state, city, full_name FROM healthcare.appointments ORDER BY joined_at DESC LIMIT 25;


[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Retrieve billing where reconciliation_status LIKE 'A%'.

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

[User] Sort the results by created_at ascending.

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


[User] Get all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Show the results sorted by created_at descending.

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

[User] Restrict the output to 15 items.

[Assistant] SELECT * FROM healthcare.billing ORDER BY created_at DESC LIMIT 15;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.doctors (
  location_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  last_inspected date,
  location_lon character varying(256),
  geo_point text,
  accessibility character varying(128),
  prescription_id text -- reference to prescriptions.id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(id)
)

CREATE TABLE healthcare.prescriptions (
  id varchar PRIMARY KEY -- unique identifier,
  due_date timestamp without time zone,
  customer_id varchar NOT NULL -- identifier for customer,
  user_id varchar -- identifier for user,
  approval_status varchar,
  reconciliation_status character varying(128) NOT NULL,
  description character varying(256),
  invoice_number char,
  debit character varying(256)
)

[User] Retrieve updated_at, location_id, last_inspected for every doctor.

[Assistant] SELECT updated_at, location_id, last_inspected FROM healthcare.doctors;

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

[Assistant] SELECT updated_at, location_id, last_inspected FROM healthcare.doctors WHERE geo_point LIKE 'A%';

[User] Show me the count of doctors grouped by location_lon.

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


[User] Show me all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

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

[User] Only show the top 15 results.

[Assistant] SELECT * FROM healthcare.doctors WHERE last_inspected <= CURRENT_DATE - INTERVAL '6 months' LIMIT 15;


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Retrieve prescription_id, location_id, customer_id, debit showing the relationship between doctors and prescriptions.

[Assistant] SELECT *, prescriptions.customer_id, prescriptions.debit FROM healthcare.doctors JOIN healthcare.prescriptions ON doctors.prescription_id = prescriptions.id;

[User] Show only 50 records.

[Assistant] SELECT *, prescriptions.customer_id, prescriptions.debit FROM healthcare.doctors JOIN healthcare.prescriptions ON doctors.prescription_id = prescriptions.id LIMIT 50;


[User] Get location_id, accessibility, location_lon from all doctors.

[Assistant] SELECT location_id, accessibility, location_lon FROM healthcare.doctors;

[User] Get doctors that match accessibility LIKE 'A%'.

[Assistant] SELECT location_id, accessibility, location_lon FROM healthcare.doctors WHERE accessibility LIKE 'A%';

[User] Group doctors by accessibility and show the max of updated_at.

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


[User] Show me all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] List doctors with dates from 2023.

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

[User] Show the results sorted by last_inspected ascending.

[Assistant] SELECT * FROM healthcare.doctors WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY last_inspected ASC;


[User] Show me all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Get all doctors older than 6 months.

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

[User] Count the number of doctors in each accessibility category.

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


[User] List last_inspected, updated_at, prescription_id from doctors.

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

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

[Assistant] SELECT last_inspected, updated_at, prescription_id FROM healthcare.doctors WHERE last_inspected BETWEEN '2023-01-01' AND '2023-12-31';

[User] Only show the top 20 results.

[Assistant] SELECT last_inspected, updated_at, prescription_id FROM healthcare.doctors WHERE last_inspected BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 20;


[User] Get updated_at, location_lon, location_id from all doctors.

[Assistant] SELECT updated_at, location_lon, location_id FROM healthcare.doctors;

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

[Assistant] SELECT updated_at, location_lon, location_id FROM healthcare.doctors WHERE updated_at > '2023-01-01';

[User] Group doctors by last_inspected and show the count of location_id.

[Assistant] SELECT last_inspected, COUNT(location_id) AS count_location_id FROM healthcare.doctors GROUP BY last_inspected;


[User] List geo_point, updated_at, last_inspected from doctors.

[Assistant] SELECT geo_point, updated_at, last_inspected FROM healthcare.doctors;

[User] Find doctors modified within the last hour.

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

[User] Count the number of doctors in each accessibility category.

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


[User] Show me location_id, geo_point, accessibility for all doctors.

[Assistant] SELECT location_id, geo_point, accessibility FROM healthcare.doctors;

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

[Assistant] SELECT location_id, geo_point, accessibility FROM healthcare.doctors WHERE accessibility LIKE 'A%';

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.messages (
  message_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp without time zone,
  parent_id character varying(64) NOT NULL,
  author_id character varying(256),
  image_url character varying(128),
  format character varying(128),
  post_id text NOT NULL -- reference to posts.id,
  FOREIGN KEY (post_id) REFERENCES posts(id)
)

CREATE TABLE socialmedia.posts (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  visibility char,
  rating char,
  body character varying(128)
)

[User] Get all messages.

[Assistant] SELECT * FROM socialmedia.messages;

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

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

[User] What is the min format for each published_at in messages?

[Assistant] SELECT published_at, MIN(format) AS min_format FROM socialmedia.messages GROUP BY published_at;


[User] Retrieve all messages.

[Assistant] SELECT * FROM socialmedia.messages;

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

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

[User] Sort the results by message_id descending.

[Assistant] SELECT * FROM socialmedia.messages WHERE published_at > '2023-12-01' ORDER BY message_id DESC;


[User] Display all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Can you order these by image_url descending?

[Assistant] SELECT * FROM socialmedia.messages ORDER BY image_url DESC;

[User] Return just 20 rows.

[Assistant] SELECT * FROM socialmedia.messages ORDER BY image_url DESC LIMIT 20;


[User] Show me all messages.

[Assistant] SELECT * FROM socialmedia.messages;

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

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

[User] Show the results sorted by author_id ascending.

[Assistant] SELECT * FROM socialmedia.messages WHERE published_at > '2023-01-01' ORDER BY author_id ASC;


[User] Get format, parent_id, published_at from all messages.

[Assistant] SELECT format, parent_id, published_at FROM socialmedia.messages;

[User] Show the results sorted by post_id ascending.

[Assistant] SELECT format, parent_id, published_at FROM socialmedia.messages ORDER BY post_id ASC;

[User] Tally up messages by image_url.

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


[User] Get published_at, format, image_url from all messages.

[Assistant] SELECT published_at, format, image_url FROM socialmedia.messages;

[User] Find messages where published_at > '2023-01-01'.

[Assistant] SELECT published_at, format, image_url FROM socialmedia.messages WHERE published_at > '2023-01-01';

[User] Calculate sum of post_id for each image_url in messages.

[Assistant] SELECT image_url, SUM(post_id) AS sum_post_id FROM socialmedia.messages GROUP BY image_url;


[User] Retrieve author_id, published_at, post_id for every message.

[Assistant] SELECT author_id, published_at, post_id FROM socialmedia.messages;

[User] Retrieve format, published_at, updated_at, body showing the relationship between messages and posts.

[Assistant] SELECT author_id, published_at, post_id, posts.updated_at, posts.body FROM socialmedia.messages JOIN socialmedia.posts ON messages.post_id = posts.id;

[User] Sort the results by image_url ascending.

[Assistant] SELECT author_id, published_at, post_id, posts.updated_at, posts.body FROM socialmedia.messages JOIN socialmedia.posts ON messages.post_id = posts.id ORDER BY image_url ASC;


[User] What are the format, image_url, parent_id of each message?

[Assistant] SELECT format, image_url, parent_id FROM socialmedia.messages;

[User] Show me author_id, image_url, visibility, body from messages and their related posts.

[Assistant] SELECT format, image_url, parent_id, posts.visibility, posts.body FROM socialmedia.messages JOIN socialmedia.posts ON messages.post_id = posts.id;

[User] Only show the top 15 results.

[Assistant] SELECT format, image_url, parent_id, posts.visibility, posts.body FROM socialmedia.messages JOIN socialmedia.posts ON messages.post_id = posts.id LIMIT 15;


[User] Retrieve format, author_id, post_id for every message.

[Assistant] SELECT format, author_id, post_id FROM socialmedia.messages;

[User] List messages with dates from 2023.

[Assistant] SELECT format, author_id, post_id FROM socialmedia.messages WHERE published_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Only show the top 10 results.

[Assistant] SELECT format, author_id, post_id FROM socialmedia.messages WHERE published_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 10;


[User] Show me format, image_url, message_id for all messages.

[Assistant] SELECT format, image_url, message_id FROM socialmedia.messages;

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

[Assistant] SELECT format, image_url, message_id FROM socialmedia.messages WHERE published_at > '2023-01-01';

[User] Sort the results by format descending.

[Assistant] SELECT format, image_url, message_id FROM socialmedia.messages WHERE published_at > '2023-01-01' ORDER BY format 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.doctors (
  person_id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  profile_picture_url text,
  country text,
  first_name character varying(64),
  is_verified boolean,
  patient_id text -- reference to patients.id,
  FOREIGN KEY (patient_id) REFERENCES patients(id)
)

CREATE TABLE healthcare.appointments (
  location_id integer PRIMARY KEY -- unique identifier,
  last_inspected timestamp without time zone,
  updated_at timestamp without time zone,
  type character varying(256),
  address_line2 character varying(128),
  postal_code text,
  patient_id text -- reference to patients.id,
  FOREIGN KEY (patient_id) REFERENCES patients(id)
)

CREATE TABLE healthcare.patients (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  token character varying(64),
  password_hash char,
  last_name character varying(64),
  address text,
  username character varying(128) NOT NULL,
  status character varying(128),
  appointment_id integer NOT NULL -- reference to appointments.location_id,
  doctor_id text NOT NULL -- reference to doctors.person_id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(location_id),
  FOREIGN KEY (doctor_id) REFERENCES doctors(person_id)
)

[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Show me doctors that were from 2023.

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

[User] Count the number of doctors in each patient_id category.

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


[User] Show me all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

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

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

[User] Tally up appointments by last_inspected.

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


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

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

[User] Group doctors by is_verified and show the min of patient_id.

[Assistant] SELECT is_verified, MIN(patient_id) AS min_patient_id FROM healthcare.doctors GROUP BY is_verified;


[User] Retrieve all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

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

[User] Tally up doctors by joined_at.

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


[User] List all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Sort the results by first_name descending.

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

[User] Tally up doctors by profile_picture_url.

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


[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

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

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

[User] Tally up appointments by last_inspected.

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


[User] Retrieve all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Get postal_code, last_inspected, last_name, appointment_id by joining appointments with patients.

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

[User] Restrict the output to 10 items.

[Assistant] SELECT *, patients.last_name, patients.appointment_id FROM healthcare.appointments JOIN healthcare.patients ON appointments.patient_id = patients.id LIMIT 10;


[User] Show me all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] What country, patient_id, doctor_id, password_hash do we have for doctors and their associated patients?

[Assistant] SELECT *, patients.doctor_id, patients.password_hash FROM healthcare.doctors JOIN healthcare.patients ON doctors.patient_id = patients.id;

[User] Sort the results by joined_at ascending.

[Assistant] SELECT *, patients.doctor_id, patients.password_hash FROM healthcare.doctors JOIN healthcare.patients ON doctors.patient_id = patients.id ORDER BY joined_at ASC;


[User] Retrieve all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Get all doctors created yesterday.

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

[User] Limit the results to 20 rows.

[Assistant] SELECT * FROM healthcare.doctors WHERE joined_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 20;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.users (
  user_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  updated_at timestamp without time zone,
  age varchar,
  username character varying(256) NOT NULL,
  last_login date NOT NULL,
  zip_code character varying(256),
  gender character varying(256),
  product_id text NOT NULL -- reference to products.barcode,
  FOREIGN KEY (product_id) REFERENCES products(barcode)
)

CREATE TABLE e-commerce.products (
  barcode text PRIMARY KEY -- unique identifier,
  expires_at timestamp without time zone,
  image_url text NOT NULL,
  discount decimal,
  popularity_score text NOT NULL,
  featured_rank varchar,
  categorie_id integer -- reference to categories.payment_id,
  FOREIGN KEY (categorie_id) REFERENCES categories(payment_id)
)

CREATE TABLE e-commerce.categories (
  payment_id integer PRIMARY KEY -- unique identifier,
  processed_at date,
  approval_status varchar,
  buyer_id character varying(128) NOT NULL -- identifier for buyer,
  product_id character varying(256),
  price numeric(38,14),
  currency character varying(256),
  user_id integer -- reference to users.user_id,
  FOREIGN KEY (user_id) REFERENCES users(user_id)
)

[User] Get all categories.

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

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

[Assistant] SELECT * FROM e-commerce.categories WHERE processed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Show only 20 records.

[Assistant] SELECT * FROM e-commerce.categories WHERE processed_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 20;


[User] What are the price, buyer_id, processed_at of each categorie?

[Assistant] SELECT price, buyer_id, processed_at FROM e-commerce.categories;

[User] List currency, processed_at, product_id, gender for each categorie along with their user information.

[Assistant] SELECT price, buyer_id, processed_at, users.product_id, users.gender FROM e-commerce.categories JOIN e-commerce.users ON categories.user_id = users.user_id;

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

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


[User] Display all users.

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

[User] What product_id, created_at, discount, expires_at do we have for users and their associated products?

[Assistant] SELECT *, products.discount, products.expires_at FROM e-commerce.users JOIN e-commerce.products ON users.product_id = products.barcode;

[User] Limit the results to 25 rows.

[Assistant] SELECT *, products.discount, products.expires_at FROM e-commerce.users JOIN e-commerce.products ON users.product_id = products.barcode LIMIT 25;


[User] Show me user_id, product_id, buyer_id for all categories.

[Assistant] SELECT user_id, product_id, buyer_id FROM e-commerce.categories;

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

[Assistant] SELECT user_id, product_id, buyer_id FROM e-commerce.categories WHERE currency LIKE 'A%';

[User] Calculate min of processed_at for each user_id in categories.

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


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

[Assistant] SELECT updated_at, zip_code, created_at FROM e-commerce.users;

[User] Show the results sorted by zip_code descending.

[Assistant] SELECT updated_at, zip_code, created_at FROM e-commerce.users ORDER BY zip_code DESC;

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

[Assistant] SELECT updated_at, zip_code, created_at FROM e-commerce.users ORDER BY updated_at DESC;


[User] Retrieve buyer_id, currency, product_id for every categorie.

[Assistant] SELECT buyer_id, currency, product_id FROM e-commerce.categories;

[User] Can you order these by buyer_id descending?

[Assistant] SELECT buyer_id, currency, product_id FROM e-commerce.categories ORDER BY buyer_id DESC;

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

[Assistant] SELECT buyer_id, currency, product_id FROM e-commerce.categories ORDER BY buyer_id DESC;


[User] Get all categories.

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

[User] Show the results sorted by buyer_id descending.

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

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

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


[User] Get buyer_id, processed_at, price from all categories.

[Assistant] SELECT buyer_id, processed_at, price FROM e-commerce.categories;

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

[Assistant] SELECT buyer_id, processed_at, price FROM e-commerce.categories WHERE processed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Tally up categories by price.

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


[User] What are the age, zip_code, username of each user?

[Assistant] SELECT age, zip_code, username FROM e-commerce.users;

[User] List gender, age, categorie_id, discount for each user along with their product information.

[Assistant] SELECT age, zip_code, username, products.categorie_id, products.discount FROM e-commerce.users JOIN e-commerce.products ON users.product_id = products.barcode;

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

[Assistant] SELECT age, zip_code, username, products.categorie_id, products.discount FROM e-commerce.users JOIN e-commerce.products ON users.product_id = products.barcode ORDER BY age DESC;


[User] Retrieve user_id, processed_at, currency for every categorie.

[Assistant] SELECT user_id, processed_at, currency FROM e-commerce.categories;

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

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

[User] Group categories by approval_status and show the average of price.

[Assistant] SELECT approval_status, AVERAGE(price) AS average_price FROM e-commerce.categories GROUP BY approval_status;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE gaming.products (
  item_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  published_at timestamp,
  subcategory character varying(256),
  reserved text NOT NULL,
  image_url varchar,
  thumbnail_url character varying(256),
  video_url character varying(256),
  student_id text -- reference to students.user_id,
  FOREIGN KEY (student_id) REFERENCES students(user_id)
)

CREATE TABLE gaming.messages (
  post_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  published_at timestamp without time zone,
  parent_id varchar NOT NULL,
  keywords character varying(128) NOT NULL,
  user_id character varying(64) -- identifier for user,
  title character varying(256) NOT NULL
)

CREATE TABLE gaming.students (
  user_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at timestamp without time zone,
  last_name character varying(64),
  timezone text NOT NULL,
  age character varying(64) NOT NULL,
  status character varying(64) NOT NULL,
  token character varying(128)
)

[User] Display all products.

[Assistant] SELECT * FROM gaming.products;

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

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

[User] Only show the top 5 results.

[Assistant] SELECT * FROM gaming.products WHERE published_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 5;


[User] Retrieve video_url, updated_at, reserved for every product.

[Assistant] SELECT video_url, updated_at, reserved FROM gaming.products;

[User] List subcategory, updated_at, created_at, timezone for each product along with their student information.

[Assistant] SELECT video_url, updated_at, reserved, students.created_at, students.timezone FROM gaming.products JOIN gaming.students ON products.student_id = students.user_id;

[User] How many products are there per image_url?

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


[User] Retrieve all products.

[Assistant] SELECT * FROM gaming.products;

[User] List published_at, video_url, last_name, status for each product along with their student information.

[Assistant] SELECT *, students.last_name, students.status FROM gaming.products JOIN gaming.students ON products.student_id = students.user_id;

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

[Assistant] SELECT *, students.last_name, students.status FROM gaming.products JOIN gaming.students ON products.student_id = students.user_id ORDER BY thumbnail_url ASC;


[User] Display all products.

[Assistant] SELECT * FROM gaming.products;

[User] List reserved, student_id, age, created_at for each product along with their student information.

[Assistant] SELECT *, students.age, students.created_at FROM gaming.products JOIN gaming.students ON products.student_id = students.user_id;

[User] Return just 50 rows.

[Assistant] SELECT *, students.age, students.created_at FROM gaming.products JOIN gaming.students ON products.student_id = students.user_id LIMIT 50;


[User] Show me all products.

[Assistant] SELECT * FROM gaming.products;

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

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

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

[Assistant] SELECT image_url, COUNT(updated_at) AS count_updated_at FROM gaming.products GROUP BY image_url;


[User] List all products.

[Assistant] SELECT * FROM gaming.products;

[User] Order the output by published_at descending.

[Assistant] SELECT * FROM gaming.products ORDER BY published_at DESC;

[User] Sort the results by student_id descending.

[Assistant] SELECT * FROM gaming.products ORDER BY student_id DESC;


[User] List all products.

[Assistant] SELECT * FROM gaming.products;

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

[Assistant] SELECT * FROM gaming.products WHERE subcategory LIKE 'A%';

[User] Get the distribution of products across different reserved values.

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


[User] Show me video_url, published_at, student_id for all products.

[Assistant] SELECT video_url, published_at, student_id FROM gaming.products;

[User] Show me reserved, published_at, token, status from products and their related students.

[Assistant] SELECT video_url, published_at, student_id, students.token, students.status FROM gaming.products JOIN gaming.students ON products.student_id = students.user_id;

[User] Restrict the output to 15 items.

[Assistant] SELECT video_url, published_at, student_id, students.token, students.status FROM gaming.products JOIN gaming.students ON products.student_id = students.user_id LIMIT 15;


[User] List all products.

[Assistant] SELECT * FROM gaming.products;

[User] Sort the results by item_id descending.

[Assistant] SELECT * FROM gaming.products ORDER BY item_id DESC;

[User] How many products are there per published_at?

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


[User] Retrieve published_at, student_id, image_url for every product.

[Assistant] SELECT published_at, student_id, image_url FROM gaming.products;

[User] Get video_url, thumbnail_url, last_name, age by joining products with students.

[Assistant] SELECT published_at, student_id, image_url, students.last_name, students.age FROM gaming.products JOIN gaming.students ON products.student_id = students.user_id;

[User] Sort the results by student_id descending.

[Assistant] SELECT published_at, student_id, image_url, students.last_name, students.age FROM gaming.products JOIN gaming.students ON products.student_id = students.user_id ORDER BY student_id DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.medical_records (
  id integer PRIMARY KEY -- unique identifier,
  joined_at date,
  last_active timestamp,
  city text,
  last_login timestamp without time zone,
  email char,
  is_verified boolean NOT NULL,
  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,
  last_active date,
  updated_at timestamp without time zone,
  profile_picture_url char,
  full_name character varying(128),
  bio character varying(64),
  birth_date date,
  medical_record_id integer -- reference to medical_records.id,
  FOREIGN KEY (medical_record_id) REFERENCES medical_records(id)
)

CREATE TABLE healthcare.billing (
  sku character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  published_at timestamp without time zone,
  video_url character varying(256) NOT NULL,
  name varchar,
  description varchar NOT NULL,
  thumbnail_url character varying(64),
  manufacturer character varying(256),
  patient_id integer NOT NULL -- reference to patients.user_id,
  medical_record_id integer -- reference to medical_records.id,
  FOREIGN KEY (patient_id) REFERENCES patients(user_id),
  FOREIGN KEY (medical_record_id) REFERENCES medical_records(id)
)

[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] Order the output by manufacturer ascending.

[Assistant] SELECT * FROM healthcare.billing WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY manufacturer ASC;


[User] Display all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Get updated_at, profile_picture_url, patient_id, last_active by joining patients with medical_records.

[Assistant] SELECT *, medical_records.patient_id, medical_records.last_active FROM healthcare.patients JOIN healthcare.medical_records ON patients.medical_record_id = medical_records.id;

[User] Calculate count of bio for each birth_date in patients.

[Assistant] SELECT birth_date, COUNT(bio) AS count_bio FROM healthcare.patients GROUP BY birth_date;


[User] Display all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Get published_at, manufacturer, updated_at, profile_picture_url by joining billing with patients.

[Assistant] SELECT *, patients.updated_at, patients.profile_picture_url FROM healthcare.billing JOIN healthcare.patients ON billing.patient_id = patients.user_id;

[User] Get the distribution of billing across different thumbnail_url values.

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


[User] Get joined_at, email, is_verified from all medical_records.

[Assistant] SELECT joined_at, email, is_verified FROM healthcare.medical_records;

[User] Show the results sorted by patient_id descending.

[Assistant] SELECT joined_at, email, is_verified FROM healthcare.medical_records ORDER BY patient_id DESC;

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

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


[User] Retrieve city, patient_id, is_verified for every medical_record.

[Assistant] SELECT city, patient_id, is_verified FROM healthcare.medical_records;

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

[Assistant] SELECT city, patient_id, is_verified FROM healthcare.medical_records WHERE last_login BETWEEN '2023-01-01' AND '2023-12-31';

[User] Get min of patient_id by city from medical_records.

[Assistant] SELECT city, MIN(patient_id) AS min_patient_id FROM healthcare.medical_records GROUP BY city;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.trades (
  id text PRIMARY KEY -- unique identifier,
  cancelled_at timestamp without time zone,
  traded_at timestamp without time zone,
  discount bigint,
  payment_method character varying(256) NOT NULL,
  account_id text
)

CREATE TABLE tradingplatform.notifications (
  content_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  published_at date,
  visibility char,
  description text NOT NULL,
  likes varchar,
  attachment_url character varying(256),
  trade_id text NOT NULL -- reference to trades.id,
  FOREIGN KEY (trade_id) REFERENCES trades(id)
)

CREATE TABLE tradingplatform.wallets (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  due_date timestamp without time zone,
  created_at date,
  reference_number character varying(128),
  debit char NOT NULL,
  status character varying(64) NOT NULL
)

[User] Retrieve description, visibility, likes for every notification.

[Assistant] SELECT description, visibility, likes FROM tradingplatform.notifications;

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

[Assistant] SELECT description, visibility, likes FROM tradingplatform.notifications WHERE published_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Show me max of attachment_url grouped by likes for notifications.

[Assistant] SELECT likes, MAX(attachment_url) AS max_attachment_url FROM tradingplatform.notifications GROUP BY likes;


[User] Display all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Find notifications where visibility LIKE 'A%'.

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

[User] How many notifications are there per trade_id?

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


[User] Get attachment_url, created_at, trade_id from all notifications.

[Assistant] SELECT attachment_url, created_at, trade_id FROM tradingplatform.notifications;

[User] List notifications that have attachment_url LIKE 'A%'.

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

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

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


[User] Show me published_at, likes, description for all notifications.

[Assistant] SELECT published_at, likes, description FROM tradingplatform.notifications;

[User] Find notifications where trade_id LIKE 'A%'.

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

[User] Order the output by description descending.

[Assistant] SELECT published_at, likes, description FROM tradingplatform.notifications WHERE trade_id LIKE 'A%' ORDER BY description DESC;


[User] What are the description, attachment_url, likes of each notification?

[Assistant] SELECT description, attachment_url, likes FROM tradingplatform.notifications;

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

[Assistant] SELECT description, attachment_url, likes FROM tradingplatform.notifications WHERE attachment_url LIKE 'A%';

[User] Show only 5 records.

[Assistant] SELECT description, attachment_url, likes FROM tradingplatform.notifications WHERE attachment_url LIKE 'A%' LIMIT 5;


[User] Show me created_at, visibility, description for all notifications.

[Assistant] SELECT created_at, visibility, description FROM tradingplatform.notifications;

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

[Assistant] SELECT created_at, visibility, description FROM tradingplatform.notifications WHERE created_at > '2023-01-01';

[User] Return just 15 rows.

[Assistant] SELECT created_at, visibility, description FROM tradingplatform.notifications WHERE created_at > '2023-01-01' LIMIT 15;


[User] Display all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] List published_at, description, account_id, discount for each notification along with their trade information.

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

[User] Get the distribution of notifications across different description values.

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


[User] Show me visibility, trade_id, description for all notifications.

[Assistant] SELECT visibility, trade_id, description FROM tradingplatform.notifications;

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

[Assistant] SELECT visibility, trade_id, description FROM tradingplatform.notifications WHERE trade_id LIKE 'A%';

[User] Show the results sorted by created_at descending.

[Assistant] SELECT visibility, trade_id, description FROM tradingplatform.notifications WHERE trade_id LIKE 'A%' ORDER BY created_at DESC;