System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.reviews (
  message_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  created_at date,
  attachment_url character varying(256),
  format character varying(256),
  tags text
)

CREATE TABLE e-commerce.users (
  user_id character varying(64) NOT NULL -- unique identifier,
  last_active date,
  joined_at timestamp,
  language text,
  is_active boolean -- indicates if active is true,
  city character varying(256),
  api_key character varying(128),
  categorie_id text -- reference to categories.address_id,
  FOREIGN KEY (categorie_id) REFERENCES categories(address_id)
)

CREATE TABLE e-commerce.orders (
  payment_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  completed_at timestamp,
  approval_status varchar,
  customer_id character varying(256),
  currency character varying(64),
  price decimal,
  categorie_id text NOT NULL -- reference to categories.address_id,
  FOREIGN KEY (categorie_id) REFERENCES categories(address_id)
)

CREATE TABLE e-commerce.categories (
  address_id varchar PRIMARY KEY -- unique identifier,
  last_inspected timestamp,
  postal_code text NOT NULL,
  street character varying(128),
  name varchar,
  location_lon character varying(128) NOT NULL,
  address_line1 character varying(256) NOT NULL,
  city character varying(128)
)

[User] Get all orders.

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

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

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

[User] Restrict the output to 25 items.

[Assistant] SELECT * FROM e-commerce.orders WHERE payment_id LIKE 'A%' LIMIT 25;


[User] Get all users.

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

[User] Sort the results by user_id descending.

[Assistant] SELECT * FROM e-commerce.users ORDER BY user_id DESC;

[User] Return just 25 rows.

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


[User] Get customer_id, payment_id, created_at from all orders.

[Assistant] SELECT customer_id, payment_id, created_at FROM e-commerce.orders;

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

[Assistant] SELECT customer_id, payment_id, created_at FROM e-commerce.orders WHERE categorie_id LIKE 'A%';

[User] Restrict the output to 20 items.

[Assistant] SELECT customer_id, payment_id, created_at FROM e-commerce.orders WHERE categorie_id LIKE 'A%' LIMIT 20;


[User] Get all orders.

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

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

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

[User] Restrict the output to 5 items.

[Assistant] SELECT * FROM e-commerce.orders WHERE completed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 5;


[User] Retrieve approval_status, categorie_id, customer_id for every order.

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

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

[Assistant] SELECT approval_status, categorie_id, customer_id FROM e-commerce.orders WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

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

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


[User] What are the api_key, is_active, last_active of each user?

[Assistant] SELECT api_key, is_active, last_active FROM e-commerce.users;

[User] Sort the results by user_id ascending.

[Assistant] SELECT api_key, is_active, last_active FROM e-commerce.users ORDER BY user_id ASC;

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

[Assistant] SELECT api_key, is_active, last_active FROM e-commerce.users ORDER BY joined_at ASC;


[User] Get currency, created_at, customer_id from all orders.

[Assistant] SELECT currency, created_at, customer_id FROM e-commerce.orders;

[User] Find orders between January and March.

[Assistant] SELECT currency, created_at, customer_id FROM e-commerce.orders WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Return just 50 rows.

[Assistant] SELECT currency, created_at, customer_id FROM e-commerce.orders WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 50;


[User] What are the categorie_id, price, payment_id of each order?

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

[User] Can you order these by created_at ascending?

[Assistant] SELECT categorie_id, price, payment_id FROM e-commerce.orders ORDER BY created_at ASC;

[User] Sort the results by completed_at ascending.

[Assistant] SELECT categorie_id, price, payment_id FROM e-commerce.orders ORDER BY completed_at ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.billing (
  item_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  thumbnail_url character varying(128) NOT NULL,
  name char,
  views varchar,
  discount integer,
  prescription_id text -- reference to prescriptions.payment_id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(payment_id)
)

CREATE TABLE healthcare.prescriptions (
  payment_id text PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  amount numeric,
  reference_number character varying(128),
  currency character varying(64),
  approval_status character varying(128),
  notes varchar,
  vendor_id character varying(64),
  billin_id text -- reference to billing.item_id,
  FOREIGN KEY (billin_id) REFERENCES billing(item_id)
)

[User] Get currency, billin_id, amount from all prescriptions.

[Assistant] SELECT currency, billin_id, amount FROM healthcare.prescriptions;

[User] Can you order these by billin_id descending?

[Assistant] SELECT currency, billin_id, amount FROM healthcare.prescriptions ORDER BY billin_id DESC;

[User] Show the results sorted by payment_date descending.

[Assistant] SELECT currency, billin_id, amount FROM healthcare.prescriptions ORDER BY payment_date DESC;


[User] Get all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Show me updated_at, views, billin_id, notes from billing and their related prescriptions.

[Assistant] SELECT *, prescriptions.billin_id, prescriptions.notes FROM healthcare.billing JOIN healthcare.prescriptions ON billing.prescription_id = prescriptions.payment_id;

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

[Assistant] SELECT *, prescriptions.billin_id, prescriptions.notes FROM healthcare.billing JOIN healthcare.prescriptions ON billing.prescription_id = prescriptions.payment_id ORDER BY discount DESC;


[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] Return just 20 rows.

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


[User] Get all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Retrieve approval_status, reference_number, thumbnail_url, updated_at showing the relationship between prescriptions and billing.

[Assistant] SELECT *, billing.thumbnail_url, billing.updated_at FROM healthcare.prescriptions JOIN healthcare.billing ON prescriptions.billin_id = billing.item_id;

[User] Show me max of payment_date grouped by approval_status for prescriptions.

[Assistant] SELECT approval_status, MAX(payment_date) AS max_payment_date FROM healthcare.prescriptions GROUP BY approval_status;


[User] List amount, vendor_id, notes from prescriptions.

[Assistant] SELECT amount, vendor_id, notes FROM healthcare.prescriptions;

[User] Show me payment_date, billin_id, updated_at, thumbnail_url from prescriptions and their related billing.

[Assistant] SELECT amount, vendor_id, notes, billing.updated_at, billing.thumbnail_url FROM healthcare.prescriptions JOIN healthcare.billing ON prescriptions.billin_id = billing.item_id;

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

[Assistant] SELECT amount, vendor_id, notes, billing.updated_at, billing.thumbnail_url FROM healthcare.prescriptions JOIN healthcare.billing ON prescriptions.billin_id = billing.item_id ORDER BY billin_id DESC;


[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Sort the results by discount ascending.

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

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

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


[User] What are the approval_status, payment_date, vendor_id of each prescription?

[Assistant] SELECT approval_status, payment_date, vendor_id FROM healthcare.prescriptions;

[User] Can you order these by amount ascending?

[Assistant] SELECT approval_status, payment_date, vendor_id FROM healthcare.prescriptions ORDER BY amount ASC;

[User] Limit the results to 10 rows.

[Assistant] SELECT approval_status, payment_date, vendor_id FROM healthcare.prescriptions ORDER BY amount ASC LIMIT 10;


[User] Retrieve vendor_id, approval_status, payment_date for every prescription.

[Assistant] SELECT vendor_id, approval_status, payment_date FROM healthcare.prescriptions;

[User] Order the output by billin_id ascending.

[Assistant] SELECT vendor_id, approval_status, payment_date FROM healthcare.prescriptions ORDER BY billin_id ASC;

[User] Return just 100 rows.

[Assistant] SELECT vendor_id, approval_status, payment_date FROM healthcare.prescriptions ORDER BY billin_id ASC LIMIT 100;


[User] Show me billin_id, amount, payment_date for all prescriptions.

[Assistant] SELECT billin_id, amount, payment_date FROM healthcare.prescriptions;

[User] Find prescriptions where approval_status LIKE 'A%'.

[Assistant] SELECT billin_id, amount, payment_date FROM healthcare.prescriptions WHERE approval_status LIKE 'A%';

[User] Calculate average of amount for each approval_status in prescriptions.

[Assistant] SELECT approval_status, AVERAGE(amount) AS average_amount FROM healthcare.prescriptions GROUP BY approval_status;


[User] Display all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] Restrict the output to 100 items.

[Assistant] SELECT * FROM healthcare.billing ORDER BY updated_at DESC 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 education.enrollments (
  invoice_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  debit character varying(64),
  amount smallint NOT NULL,
  balance smallint NOT NULL,
  verification_status character varying(64) NOT NULL,
  assignment_id integer NOT NULL -- reference to assignments.sku,
  FOREIGN KEY (assignment_id) REFERENCES assignments(sku)
)

CREATE TABLE education.assignments (
  sku integer PRIMARY KEY -- unique identifier,
  created_at date,
  subcategory varchar,
  brand character varying(256),
  manufacturer character varying(128),
  media_url character varying(128),
  thumbnail_url character varying(64) NOT NULL
)

CREATE TABLE education.grades (
  invoice_id integer PRIMARY KEY -- unique identifier,
  payment_date timestamp,
  due_date timestamp without time zone,
  approval_status character varying(256) NOT NULL,
  payer_id character varying(128),
  category varchar NOT NULL,
  exchange_rate character varying(64),
  verification_status text,
  user_id text,
  credit varchar,
  enrollment_id text NOT NULL -- reference to enrollments.invoice_id,
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(invoice_id)
)

[User] Show me assignment_id, updated_at, amount for all enrollments.

[Assistant] SELECT assignment_id, updated_at, amount FROM education.enrollments;

[User] Get all enrollments created yesterday.

[Assistant] SELECT assignment_id, updated_at, amount FROM education.enrollments WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Can you order these by verification_status descending?

[Assistant] SELECT assignment_id, updated_at, amount FROM education.enrollments WHERE updated_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY verification_status DESC;


[User] Retrieve credit, exchange_rate, verification_status for every grade.

[Assistant] SELECT credit, exchange_rate, verification_status FROM education.grades;

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

[Assistant] SELECT credit, exchange_rate, verification_status FROM education.grades WHERE user_id LIKE 'A%';

[User] Group grades by credit and show the average of payment_date.

[Assistant] SELECT credit, AVERAGE(payment_date) AS average_payment_date FROM education.grades GROUP BY credit;


[User] Show me amount, balance, verification_status for all enrollments.

[Assistant] SELECT amount, balance, verification_status FROM education.enrollments;

[User] Find enrollments where debit LIKE 'A%'.

[Assistant] SELECT amount, balance, verification_status FROM education.enrollments WHERE debit LIKE 'A%';

[User] Get the distribution of enrollments across different debit values.

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


[User] Show me all enrollments.

[Assistant] SELECT * FROM education.enrollments;

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

[Assistant] SELECT * FROM education.enrollments WHERE updated_at > '2023-01-01';

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

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


[User] Get all grades.

[Assistant] SELECT * FROM education.grades;

[User] List grades with dates created yesterday.

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

[User] Only show the top 100 results.

[Assistant] SELECT * FROM education.grades WHERE due_date = CURRENT_DATE - INTERVAL '1 day' LIMIT 100;


[User] Retrieve payer_id, exchange_rate, payment_date for every grade.

[Assistant] SELECT payer_id, exchange_rate, payment_date FROM education.grades;

[User] Retrieve verification_status, payment_date, assignment_id, debit showing the relationship between grades and enrollments.

[Assistant] SELECT payer_id, exchange_rate, payment_date, enrollments.assignment_id, enrollments.debit FROM education.grades JOIN education.enrollments ON grades.enrollment_id = enrollments.invoice_id;

[User] How many grades are there per verification_status?

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


[User] List amount, balance, updated_at from enrollments.

[Assistant] SELECT amount, balance, updated_at FROM education.enrollments;

[User] Show me verification_status, debit, brand, manufacturer from enrollments and their related assignments.

[Assistant] SELECT amount, balance, updated_at, assignments.brand, assignments.manufacturer FROM education.enrollments JOIN education.assignments ON enrollments.assignment_id = assignments.sku;

[User] Order the output by amount ascending.

[Assistant] SELECT amount, balance, updated_at, assignments.brand, assignments.manufacturer FROM education.enrollments JOIN education.assignments ON enrollments.assignment_id = assignments.sku ORDER BY amount ASC;


[User] Get debit, assignment_id, balance from all enrollments.

[Assistant] SELECT debit, assignment_id, balance FROM education.enrollments;

[User] Show me updated_at, amount, subcategory, thumbnail_url from enrollments and their related assignments.

[Assistant] SELECT debit, assignment_id, balance, assignments.subcategory, assignments.thumbnail_url FROM education.enrollments JOIN education.assignments ON enrollments.assignment_id = assignments.sku;

[User] Get count of assignment_id by balance from enrollments.

[Assistant] SELECT balance, COUNT(assignment_id) AS count_assignment_id FROM education.enrollments GROUP BY balance;


[User] List all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Show the results sorted by verification_status descending.

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

[User] Order the output by updated_at ascending.

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


[User] Retrieve all grades.

[Assistant] SELECT * FROM education.grades;

[User] Retrieve approval_status, due_date, assignment_id, verification_status showing the relationship between grades and enrollments.

[Assistant] SELECT *, enrollments.assignment_id, enrollments.verification_status FROM education.grades JOIN education.enrollments ON grades.enrollment_id = enrollments.invoice_id;

[User] Tally up grades by user_id.

[Assistant] SELECT user_id, COUNT(*) AS count FROM education.grades GROUP BY user_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 insurance.branches (
  id text PRIMARY KEY -- unique identifier,
  updated_at date,
  coordinates text,
  category character varying(128),
  zip_code character varying(64),
  address_line2 char,
  parking_available char,
  type character varying(128),
  comment_id text -- reference to comments.message_id,
  FOREIGN KEY (comment_id) REFERENCES comments(message_id)
)

CREATE TABLE insurance.transactions (
  order_id varchar PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  created_at timestamp without time zone,
  currency character varying(64) NOT NULL,
  payment_status character varying(64) NOT NULL,
  amount numeric(38,14),
  payment_method character varying(256),
  approval_status text NOT NULL,
  subtotal numeric NOT NULL
)

CREATE TABLE insurance.comments (
  message_id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  categories character varying(64),
  views text NOT NULL,
  subject char,
  media_url varchar NOT NULL,
  user_id text,
  rating character varying(256) NOT NULL,
  transaction_id text -- reference to transactions.order_id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(order_id)
)

[User] Display all branches.

[Assistant] SELECT * FROM insurance.branches;

[User] Order the output by address_line2 ascending.

[Assistant] SELECT * FROM insurance.branches ORDER BY address_line2 ASC;

[User] Order the output by comment_id ascending.

[Assistant] SELECT * FROM insurance.branches ORDER BY comment_id ASC;


[User] What are the address_line2, zip_code, updated_at of each branche?

[Assistant] SELECT address_line2, zip_code, updated_at FROM insurance.branches;

[User] List category, updated_at, subject, published_at for each branche along with their comment information.

[Assistant] SELECT address_line2, zip_code, updated_at, comments.subject, comments.published_at FROM insurance.branches JOIN insurance.comments ON branches.comment_id = comments.message_id;

[User] Get the distribution of branches across different parking_available values.

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


[User] Show me all branches.

[Assistant] SELECT * FROM insurance.branches;

[User] Retrieve updated_at, coordinates, published_at, subject showing the relationship between branches and comments.

[Assistant] SELECT *, comments.published_at, comments.subject FROM insurance.branches JOIN insurance.comments ON branches.comment_id = comments.message_id;

[User] Return just 50 rows.

[Assistant] SELECT *, comments.published_at, comments.subject FROM insurance.branches JOIN insurance.comments ON branches.comment_id = comments.message_id LIMIT 50;


[User] What are the category, type, parking_available of each branche?

[Assistant] SELECT category, type, parking_available FROM insurance.branches;

[User] Find branches where parking_available LIKE 'A%'.

[Assistant] SELECT category, type, parking_available FROM insurance.branches WHERE parking_available LIKE 'A%';

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

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


[User] Show me all comments.

[Assistant] SELECT * FROM insurance.comments;

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

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

[User] Group comments by views and show the max of media_url.

[Assistant] SELECT views, MAX(media_url) AS max_media_url FROM insurance.comments GROUP BY views;


[User] Retrieve categories, rating, user_id for every comment.

[Assistant] SELECT categories, rating, user_id FROM insurance.comments;

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

[Assistant] SELECT categories, rating, user_id FROM insurance.comments WHERE published_at > '2023-01-01';

[User] How many comments are there per user_id?

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


[User] Display all comments.

[Assistant] SELECT * FROM insurance.comments;

[User] Show the results sorted by categories ascending.

[Assistant] SELECT * FROM insurance.comments ORDER BY categories ASC;

[User] Sort the results by media_url descending.

[Assistant] SELECT * FROM insurance.comments ORDER BY media_url DESC;


[User] Show me all branches.

[Assistant] SELECT * FROM insurance.branches;

[User] List comment_id, parking_available, published_at, media_url for each branche along with their comment information.

[Assistant] SELECT *, comments.published_at, comments.media_url FROM insurance.branches JOIN insurance.comments ON branches.comment_id = comments.message_id;

[User] Group branches by zip_code and show the max of address_line2.

[Assistant] SELECT zip_code, MAX(address_line2) AS max_address_line2 FROM insurance.branches GROUP BY zip_code;


[User] Get all comments.

[Assistant] SELECT * FROM insurance.comments;

[User] Retrieve subject, published_at, payment_status, approval_status showing the relationship between comments and transactions.

[Assistant] SELECT *, transactions.payment_status, transactions.approval_status FROM insurance.comments JOIN insurance.transactions ON comments.transaction_id = transactions.order_id;

[User] Show me sum of subject grouped by rating for comments.

[Assistant] SELECT rating, SUM(subject) AS sum_subject FROM insurance.comments GROUP BY rating;


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 insurance.addresses (
  location_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  last_inspected timestamp without time zone,
  city character varying(64),
  capacity varchar,
  description character varying(256),
  longitude character varying(64) NOT NULL,
  state character varying(128),
  postal_code character varying(64),
  review_id text NOT NULL -- reference to reviews.post_id,
  FOREIGN KEY (review_id) REFERENCES reviews(post_id)
)

CREATE TABLE insurance.reviews (
  post_id text PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  content text,
  shares character varying(64),
  rating char,
  visibility character varying(128) NOT NULL,
  user_id character varying(64) NOT NULL -- identifier for user
)

CREATE TABLE insurance.students (
  employee_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  salt text,
  city character varying(64),
  timezone character varying(128) NOT NULL,
  addresse_id text -- reference to addresses.location_id,
  FOREIGN KEY (addresse_id) REFERENCES addresses(location_id)
)

[User] Retrieve timezone, addresse_id, salt for every student.

[Assistant] SELECT timezone, addresse_id, salt FROM insurance.students;

[User] Show me created_at, salt, city, state from students and their related addresses.

[Assistant] SELECT timezone, addresse_id, salt, addresses.city, addresses.state FROM insurance.students JOIN insurance.addresses ON students.addresse_id = addresses.location_id;

[User] Get max of addresse_id by salt from students.

[Assistant] SELECT salt, MAX(addresse_id) AS max_addresse_id FROM insurance.students GROUP BY salt;


[User] Retrieve capacity, state, city for every addresse.

[Assistant] SELECT capacity, state, city FROM insurance.addresses;

[User] Show me addresses with capacity LIKE 'A%'.

[Assistant] SELECT capacity, state, city FROM insurance.addresses WHERE capacity LIKE 'A%';

[User] Show only 15 records.

[Assistant] SELECT capacity, state, city FROM insurance.addresses WHERE capacity LIKE 'A%' LIMIT 15;


[User] Retrieve timezone, created_at, addresse_id for every student.

[Assistant] SELECT timezone, created_at, addresse_id FROM insurance.students;

[User] Sort the results by timezone ascending.

[Assistant] SELECT timezone, created_at, addresse_id FROM insurance.students ORDER BY timezone ASC;

[User] Limit the results to 20 rows.

[Assistant] SELECT timezone, created_at, addresse_id FROM insurance.students ORDER BY timezone ASC LIMIT 20;


[User] Get all students.

[Assistant] SELECT * FROM insurance.students;

[User] Show me students with city LIKE 'A%'.

[Assistant] SELECT * FROM insurance.students WHERE city LIKE 'A%';

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

[Assistant] SELECT * FROM insurance.students WHERE city LIKE 'A%' ORDER BY addresse_id ASC;


[User] Retrieve created_at, city, addresse_id for every student.

[Assistant] SELECT created_at, city, addresse_id FROM insurance.students;

[User] List students with dates from 2023.

[Assistant] SELECT created_at, city, addresse_id FROM insurance.students WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Return just 50 rows.

[Assistant] SELECT created_at, city, addresse_id FROM insurance.students WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 50;


[User] Get last_inspected, city, capacity from all addresses.

[Assistant] SELECT last_inspected, city, capacity FROM insurance.addresses;

[User] Show me state, description, content, edited_at from addresses and their related reviews.

[Assistant] SELECT last_inspected, city, capacity, reviews.content, reviews.edited_at FROM insurance.addresses JOIN insurance.reviews ON addresses.review_id = reviews.post_id;

[User] Can you order these by longitude ascending?

[Assistant] SELECT last_inspected, city, capacity, reviews.content, reviews.edited_at FROM insurance.addresses JOIN insurance.reviews ON addresses.review_id = reviews.post_id ORDER BY longitude ASC;


[User] Get created_at, review_id, state from all addresses.

[Assistant] SELECT created_at, review_id, state FROM insurance.addresses;

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

[Assistant] SELECT created_at, review_id, state FROM insurance.addresses WHERE created_at > '2023-01-01';

[User] Can you order these by state ascending?

[Assistant] SELECT created_at, review_id, state FROM insurance.addresses WHERE created_at > '2023-01-01' ORDER BY state ASC;


[User] Get review_id, capacity, postal_code from all addresses.

[Assistant] SELECT review_id, capacity, postal_code FROM insurance.addresses;

[User] Show me last_inspected, capacity, user_id, content from addresses and their related reviews.

[Assistant] SELECT review_id, capacity, postal_code, reviews.user_id, reviews.content FROM insurance.addresses JOIN insurance.reviews ON addresses.review_id = reviews.post_id;

[User] What is the max description for each created_at in addresses?

[Assistant] SELECT created_at, MAX(description) AS max_description FROM insurance.addresses GROUP BY created_at;


[User] Show me capacity, city, postal_code for all addresses.

[Assistant] SELECT capacity, city, postal_code FROM insurance.addresses;

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

[Assistant] SELECT capacity, city, postal_code FROM insurance.addresses ORDER BY review_id DESC;

[User] Can you order these by last_inspected descending?

[Assistant] SELECT capacity, city, postal_code FROM insurance.addresses ORDER BY last_inspected DESC;


[User] Retrieve created_at, timezone, addresse_id for every student.

[Assistant] SELECT created_at, timezone, addresse_id FROM insurance.students;

[User] Sort the results by timezone ascending.

[Assistant] SELECT created_at, timezone, addresse_id FROM insurance.students ORDER BY timezone ASC;

[User] Limit the results to 20 rows.

[Assistant] SELECT created_at, timezone, addresse_id FROM insurance.students ORDER BY timezone ASC 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 tradingplatform.logs (
  employee_id varchar PRIMARY KEY -- unique identifier,
  last_active date,
  account_status character varying(256),
  api_key character varying(256) NOT NULL,
  age character varying(128) NOT NULL,
  full_name character varying(256)
)

CREATE TABLE tradingplatform.wallets (
  payment_id character varying(64) NOT NULL -- unique identifier,
  processed_at date,
  payment_date timestamp,
  status character varying(128),
  reference_number text,
  debit char,
  notes character varying(256) NOT NULL,
  reconciliation_status text
)

CREATE TABLE tradingplatform.users (
  employee_id character varying(64) NOT NULL -- unique identifier,
  joined_at timestamp without time zone,
  last_active date,
  api_key varchar,
  phone text,
  display_name varchar,
  age char,
  log_id text NOT NULL -- reference to logs.employee_id,
  FOREIGN KEY (log_id) REFERENCES logs(employee_id)
)

[User] Retrieve display_name, age, api_key for every user.

[Assistant] SELECT display_name, age, api_key FROM tradingplatform.users;

[User] List users that have last_active > '2023-01-01'.

[Assistant] SELECT display_name, age, api_key FROM tradingplatform.users WHERE last_active > '2023-01-01';

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

[Assistant] SELECT phone, COUNT(employee_id) AS count_employee_id FROM tradingplatform.users GROUP BY phone;


[User] Retrieve display_name, api_key, last_active for every user.

[Assistant] SELECT display_name, api_key, last_active FROM tradingplatform.users;

[User] Order the output by last_active descending.

[Assistant] SELECT display_name, api_key, last_active FROM tradingplatform.users ORDER BY last_active DESC;

[User] Show me max of api_key grouped by employee_id for users.

[Assistant] SELECT employee_id, MAX(api_key) AS max_api_key FROM tradingplatform.users GROUP BY employee_id;


[User] What are the joined_at, display_name, employee_id of each user?

[Assistant] SELECT joined_at, display_name, employee_id FROM tradingplatform.users;

[User] Get phone, employee_id, full_name, last_active by joining users with logs.

[Assistant] SELECT joined_at, display_name, employee_id, logs.full_name, logs.last_active FROM tradingplatform.users JOIN tradingplatform.logs ON users.log_id = logs.employee_id;

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

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


[User] List last_active, joined_at, display_name from users.

[Assistant] SELECT last_active, joined_at, display_name FROM tradingplatform.users;

[User] Show the results sorted by last_active descending.

[Assistant] SELECT last_active, joined_at, display_name FROM tradingplatform.users ORDER BY last_active DESC;

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

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


[User] Show me joined_at, age, log_id for all users.

[Assistant] SELECT joined_at, age, log_id FROM tradingplatform.users;

[User] Get phone, age, last_active, full_name by joining users with logs.

[Assistant] SELECT joined_at, age, log_id, logs.last_active, logs.full_name FROM tradingplatform.users JOIN tradingplatform.logs ON users.log_id = logs.employee_id;

[User] Sort the results by log_id descending.

[Assistant] SELECT joined_at, age, log_id, logs.last_active, logs.full_name FROM tradingplatform.users JOIN tradingplatform.logs ON users.log_id = logs.employee_id ORDER BY log_id DESC;


[User] Show me all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] Show me users with employee_id LIKE 'A%'.

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

[User] Limit the results to 10 rows.

[Assistant] SELECT * FROM tradingplatform.users WHERE employee_id LIKE 'A%' LIMIT 10;


[User] List log_id, last_active, joined_at from users.

[Assistant] SELECT log_id, last_active, joined_at FROM tradingplatform.users;

[User] List last_active, phone, api_key, full_name for each user along with their log information.

[Assistant] SELECT log_id, last_active, joined_at, logs.api_key, logs.full_name FROM tradingplatform.users JOIN tradingplatform.logs ON users.log_id = logs.employee_id;

[User] Get the distribution of users across different api_key values.

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


[User] Show me all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] Get users that match last_active > '2023-01-01'.

[Assistant] SELECT * FROM tradingplatform.users WHERE last_active > '2023-01-01';

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

[Assistant] SELECT * FROM tradingplatform.users WHERE last_active > '2023-01-01' ORDER BY api_key DESC;


[User] List all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] Find users from last week.

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

[User] Order the output by age descending.

[Assistant] SELECT * FROM tradingplatform.users WHERE joined_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY age DESC;


[User] Retrieve all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] Order the output by joined_at descending.

[Assistant] SELECT * FROM tradingplatform.users ORDER BY joined_at DESC;

[User] Order the output by last_active ascending.

[Assistant] SELECT * FROM tradingplatform.users ORDER BY last_active ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.departments (
  order_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  traded_at timestamp without time zone,
  account_id char -- identifier for account,
  fee character varying(128),
  currency character varying(128),
  subtotal bigint,
  appointment_id text NOT NULL -- reference to appointments.sku,
  prescription_id integer -- reference to prescriptions.id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(sku),
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(id)
)

CREATE TABLE healthcare.appointments (
  sku text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  description character varying(128),
  popularity_score char,
  backorder character varying(64) NOT NULL,
  views varchar NOT NULL,
  msrp character varying(128)
)

CREATE TABLE healthcare.doctors (
  user_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  last_active timestamp without time zone,
  salt character varying(64),
  status text,
  last_login date
)

CREATE TABLE healthcare.prescriptions (
  id integer PRIMARY KEY -- unique identifier,
  joined_at date,
  salt text,
  is_verified boolean NOT NULL,
  website character varying(64) NOT NULL,
  language varchar,
  appointment_id text NOT NULL -- reference to appointments.sku,
  FOREIGN KEY (appointment_id) REFERENCES appointments(sku)
)

[User] Retrieve all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Order the output by language ascending.

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

[User] Return just 100 rows.

[Assistant] SELECT * FROM healthcare.prescriptions ORDER BY language ASC LIMIT 100;


[User] Retrieve all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Find prescriptions from 2023.

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

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

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


[User] Display all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Can you order these by subtotal descending?

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

[User] Return just 25 rows.

[Assistant] SELECT * FROM healthcare.departments ORDER BY subtotal DESC LIMIT 25;


[User] Display all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Sort the results by appointment_id descending.

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

[User] Can you order these by appointment_id descending?

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


[User] List all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

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

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

[User] How many prescriptions are there per salt?

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.accounts (
  invoice_id integer PRIMARY KEY -- unique identifier,
  payment_date date,
  due_date date,
  reconciliation_status character varying(256),
  customer_id text,
  description text NOT NULL,
  notes character varying(64),
  exchange_rate character varying(256),
  status character varying(128),
  audit_id text -- reference to audits.invoice_id,
  FOREIGN KEY (audit_id) REFERENCES audits(invoice_id)
)

CREATE TABLE finance.audits (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  tax numeric,
  card_type character varying(64) NOT NULL,
  subtotal smallint,
  account_id char
)

[User] Show me description, audit_id, customer_id for all accounts.

[Assistant] SELECT description, audit_id, customer_id FROM finance.accounts;

[User] Show me audit_id, reconciliation_status, traded_at, card_type from accounts and their related audits.

[Assistant] SELECT description, audit_id, customer_id, audits.traded_at, audits.card_type FROM finance.accounts JOIN finance.audits ON accounts.audit_id = audits.invoice_id;

[User] Sort the results by exchange_rate ascending.

[Assistant] SELECT description, audit_id, customer_id, audits.traded_at, audits.card_type FROM finance.accounts JOIN finance.audits ON accounts.audit_id = audits.invoice_id ORDER BY exchange_rate ASC;


[User] Show me due_date, audit_id, description for all accounts.

[Assistant] SELECT due_date, audit_id, description FROM finance.accounts;

[User] Retrieve customer_id, description, account_id, card_type showing the relationship between accounts and audits.

[Assistant] SELECT due_date, audit_id, description, audits.account_id, audits.card_type FROM finance.accounts JOIN finance.audits ON accounts.audit_id = audits.invoice_id;

[User] Show me average of status grouped by reconciliation_status for accounts.

[Assistant] SELECT reconciliation_status, AVERAGE(status) AS average_status FROM finance.accounts GROUP BY reconciliation_status;


[User] List all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] List due_date, description, account_id, traded_at for each account along with their audit information.

[Assistant] SELECT *, audits.account_id, audits.traded_at FROM finance.accounts JOIN finance.audits ON accounts.audit_id = audits.invoice_id;

[User] Get sum of audit_id by audit_id from accounts.

[Assistant] SELECT audit_id, SUM(audit_id) AS sum_audit_id FROM finance.accounts GROUP BY audit_id;


[User] Show me all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

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

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

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


[User] Get all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Get accounts that match due_date > '2023-01-01'.

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

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

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


[User] Show me all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Sort the results by payment_date descending.

[Assistant] SELECT * FROM finance.accounts ORDER BY payment_date DESC;

[User] Sort the results by reconciliation_status ascending.

[Assistant] SELECT * FROM finance.accounts ORDER BY reconciliation_status ASC;


[User] Display all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] What notes, exchange_rate, subtotal, account_id do we have for accounts and their associated audits?

[Assistant] SELECT *, audits.subtotal, audits.account_id FROM finance.accounts JOIN finance.audits ON accounts.audit_id = audits.invoice_id;

[User] Sort the results by status ascending.

[Assistant] SELECT *, audits.subtotal, audits.account_id FROM finance.accounts JOIN finance.audits ON accounts.audit_id = audits.invoice_id ORDER BY status ASC;


[User] Get all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

[Assistant] SELECT * FROM finance.accounts ORDER BY exchange_rate DESC;

[User] Show only 5 records.

[Assistant] SELECT * FROM finance.accounts ORDER BY exchange_rate DESC LIMIT 5;


[User] List audit_id, description, reconciliation_status from accounts.

[Assistant] SELECT audit_id, description, reconciliation_status FROM finance.accounts;

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

[Assistant] SELECT audit_id, description, reconciliation_status FROM finance.accounts WHERE payment_date >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

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

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


[User] Show me all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

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

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.enrollments (
  venue_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  created_at timestamp,
  description character varying(128),
  operating_hours character varying(128) NOT NULL,
  longitude character varying(128) NOT NULL,
  course_id integer NOT NULL -- reference to courses.location_id,
  FOREIGN KEY (course_id) REFERENCES courses(location_id)
)

CREATE TABLE education.courses (
  location_id integer PRIMARY KEY -- unique identifier,
  last_inspected date,
  created_at date,
  longitude text,
  geo_point character varying(256),
  description character varying(128) NOT NULL,
  postal_code char
)

CREATE TABLE education.grades (
  comment_id text PRIMARY KEY -- unique identifier,
  edited_at date,
  published_at timestamp without time zone,
  user_id text,
  attachment_url character varying(64),
  views character varying(128),
  enrollment_id text -- reference to enrollments.venue_id,
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(venue_id)
)

[User] Retrieve all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] List longitude, created_at, created_at, postal_code for each enrollment along with their course information.

[Assistant] SELECT *, courses.created_at, courses.postal_code FROM education.enrollments JOIN education.courses ON enrollments.course_id = courses.location_id;

[User] Return just 20 rows.

[Assistant] SELECT *, courses.created_at, courses.postal_code FROM education.enrollments JOIN education.courses ON enrollments.course_id = courses.location_id LIMIT 20;


[User] What are the course_id, operating_hours, updated_at of each enrollment?

[Assistant] SELECT course_id, operating_hours, updated_at FROM education.enrollments;

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

[Assistant] SELECT course_id, operating_hours, updated_at FROM education.enrollments WHERE description LIKE 'A%';

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

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


[User] Retrieve all grades.

[Assistant] SELECT * FROM education.grades;

[User] Order the output by published_at descending.

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

[User] Show the results sorted by user_id descending.

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


[User] Retrieve course_id, longitude, operating_hours for every enrollment.

[Assistant] SELECT course_id, longitude, operating_hours FROM education.enrollments;

[User] List enrollments with dates from 2023.

[Assistant] SELECT course_id, longitude, operating_hours FROM education.enrollments WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Count the number of enrollments in each course_id category.

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


[User] Show me edited_at, attachment_url, published_at for all grades.

[Assistant] SELECT edited_at, attachment_url, published_at FROM education.grades;

[User] Retrieve views, enrollment_id, created_at, longitude showing the relationship between grades and enrollments.

[Assistant] SELECT edited_at, attachment_url, published_at, enrollments.created_at, enrollments.longitude FROM education.grades JOIN education.enrollments ON grades.enrollment_id = enrollments.venue_id;

[User] Get the distribution of grades across different published_at values.

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


[User] What are the created_at, updated_at, description of each enrollment?

[Assistant] SELECT created_at, updated_at, description FROM education.enrollments;

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

[Assistant] SELECT created_at, updated_at, description FROM education.enrollments WHERE created_at > '2023-01-01';

[User] Show the results sorted by course_id descending.

[Assistant] SELECT created_at, updated_at, description FROM education.enrollments WHERE created_at > '2023-01-01' ORDER BY course_id DESC;


[User] List all enrollments.

[Assistant] SELECT * FROM education.enrollments;

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

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

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

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


[User] Display all grades.

[Assistant] SELECT * FROM education.grades;

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

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

[User] Order the output by published_at ascending.

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


[User] Show me all enrollments.

[Assistant] SELECT * FROM education.enrollments;

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

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

[User] Count the number of enrollments in each operating_hours category.

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


[User] List user_id, edited_at, published_at from grades.

[Assistant] SELECT user_id, edited_at, published_at FROM education.grades;

[User] Retrieve grades where edited_at > '2023-01-01'.

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

[User] Can you order these by enrollment_id descending?

[Assistant] SELECT user_id, edited_at, published_at FROM education.grades WHERE edited_at > '2023-01-01' ORDER BY enrollment_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 media.locations (
  store_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  country character varying(128) NOT NULL,
  capacity character varying(64),
  reservation_id text -- reference to reservations.order_id,
  FOREIGN KEY (reservation_id) REFERENCES reservations(order_id)
)

CREATE TABLE media.reservations (
  order_id varchar PRIMARY KEY -- unique identifier,
  cancelled_at date,
  price numeric(38,14) NOT NULL,
  currency character varying(256) NOT NULL,
  buyer_id varchar NOT NULL -- identifier for buyer,
  approval_status char NOT NULL,
  total smallint NOT NULL,
  card_type varchar
)

CREATE TABLE media.billing (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  due_date date,
  credit character varying(64),
  category character varying(128),
  vendor_id char NOT NULL -- identifier for vendor,
  notes character varying(128),
  status varchar NOT NULL,
  user_id character varying(256) -- identifier for user
)

[User] Show me capacity, created_at, country for all locations.

[Assistant] SELECT capacity, created_at, country FROM media.locations;

[User] Can you order these by reservation_id descending?

[Assistant] SELECT capacity, created_at, country FROM media.locations ORDER BY reservation_id DESC;

[User] Only show the top 50 results.

[Assistant] SELECT capacity, created_at, country FROM media.locations ORDER BY reservation_id DESC LIMIT 50;


[User] Retrieve all locations.

[Assistant] SELECT * FROM media.locations;

[User] What country, created_at, approval_status, buyer_id do we have for locations and their associated reservations?

[Assistant] SELECT *, reservations.approval_status, reservations.buyer_id FROM media.locations JOIN media.reservations ON locations.reservation_id = reservations.order_id;

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

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


[User] List capacity, reservation_id, created_at from locations.

[Assistant] SELECT capacity, reservation_id, created_at FROM media.locations;

[User] Sort the results by capacity ascending.

[Assistant] SELECT capacity, reservation_id, created_at FROM media.locations ORDER BY capacity ASC;

[User] Group locations by capacity and show the average of reservation_id.

[Assistant] SELECT capacity, AVERAGE(reservation_id) AS average_reservation_id FROM media.locations GROUP BY capacity;


[User] Get capacity, country, created_at from all locations.

[Assistant] SELECT capacity, country, created_at FROM media.locations;

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

[Assistant] SELECT capacity, country, created_at FROM media.locations WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

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

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


[User] Show me reservation_id, capacity, country for all locations.

[Assistant] SELECT reservation_id, capacity, country FROM media.locations;

[User] List locations that have country LIKE 'A%'.

[Assistant] SELECT reservation_id, capacity, country FROM media.locations WHERE country LIKE 'A%';

[User] Calculate sum of reservation_id for each created_at in locations.

[Assistant] SELECT created_at, SUM(reservation_id) AS sum_reservation_id FROM media.locations GROUP BY created_at;


[User] Retrieve country, capacity, reservation_id for every location.

[Assistant] SELECT country, capacity, reservation_id FROM media.locations;

[User] Show me reservation_id, created_at, approval_status, buyer_id from locations and their related reservations.

[Assistant] SELECT country, capacity, reservation_id, reservations.approval_status, reservations.buyer_id FROM media.locations JOIN media.reservations ON locations.reservation_id = reservations.order_id;

[User] Restrict the output to 15 items.

[Assistant] SELECT country, capacity, reservation_id, reservations.approval_status, reservations.buyer_id FROM media.locations JOIN media.reservations ON locations.reservation_id = reservations.order_id LIMIT 15;


[User] Show me all locations.

[Assistant] SELECT * FROM media.locations;

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

[Assistant] SELECT *, reservations.price, reservations.total FROM media.locations JOIN media.reservations ON locations.reservation_id = reservations.order_id;

[User] Group locations by country and show the average of created_at.

[Assistant] SELECT country, AVERAGE(created_at) AS average_created_at FROM media.locations GROUP BY country;


[User] What are the country, created_at, reservation_id of each location?

[Assistant] SELECT country, created_at, reservation_id FROM media.locations;

[User] Can you order these by created_at descending?

[Assistant] SELECT country, created_at, reservation_id FROM media.locations ORDER BY created_at DESC;

[User] Order the output by country ascending.

[Assistant] SELECT country, created_at, reservation_id FROM media.locations ORDER BY country ASC;


[User] Display all locations.

[Assistant] SELECT * FROM media.locations;

[User] Retrieve country, capacity, approval_status, total showing the relationship between locations and reservations.

[Assistant] SELECT *, reservations.approval_status, reservations.total FROM media.locations JOIN media.reservations ON locations.reservation_id = reservations.order_id;

[User] How many locations are there per capacity?

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


[User] Show me all locations.

[Assistant] SELECT * FROM media.locations;

[User] Get all locations between January and March.

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

[User] Group locations by country and show the sum of country.

[Assistant] SELECT country, SUM(country) AS sum_country FROM media.locations GROUP BY country;


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 insurance.posts (
  message_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  published_at timestamp without time zone,
  format character varying(128),
  attachment_url character varying(64) NOT NULL,
  reply_to_id text,
  views character varying(256),
  tags character varying(256) NOT NULL,
  facilitie_id text NOT NULL -- reference to facilities.address_id,
  FOREIGN KEY (facilitie_id) REFERENCES facilities(address_id)
)

CREATE TABLE insurance.facilities (
  address_id text PRIMARY KEY -- unique identifier,
  created_at date,
  last_inspected timestamp without time zone,
  operating_hours text,
  parking_available character varying(128) NOT NULL,
  timezone character varying(256),
  city character varying(64)
)

[User] Retrieve all posts.

[Assistant] SELECT * FROM insurance.posts;

[User] What format, attachment_url, parking_available, last_inspected do we have for posts and their associated facilities?

[Assistant] SELECT *, facilities.parking_available, facilities.last_inspected FROM insurance.posts JOIN insurance.facilities ON posts.facilitie_id = facilities.address_id;

[User] What is the max message_id for each message_id in posts?

[Assistant] SELECT message_id, MAX(message_id) AS max_message_id FROM insurance.posts GROUP BY message_id;


[User] Retrieve facilitie_id, attachment_url, reply_to_id for every post.

[Assistant] SELECT facilitie_id, attachment_url, reply_to_id FROM insurance.posts;

[User] Retrieve message_id, tags, last_inspected, city showing the relationship between posts and facilities.

[Assistant] SELECT facilitie_id, attachment_url, reply_to_id, facilities.last_inspected, facilities.city FROM insurance.posts JOIN insurance.facilities ON posts.facilitie_id = facilities.address_id;

[User] Can you order these by published_at descending?

[Assistant] SELECT facilitie_id, attachment_url, reply_to_id, facilities.last_inspected, facilities.city FROM insurance.posts JOIN insurance.facilities ON posts.facilitie_id = facilities.address_id ORDER BY published_at DESC;


[User] List all posts.

[Assistant] SELECT * FROM insurance.posts;

[User] Show me posts with attachment_url LIKE 'A%'.

[Assistant] SELECT * FROM insurance.posts WHERE attachment_url LIKE 'A%';

[User] Calculate count of attachment_url for each tags in posts.

[Assistant] SELECT tags, COUNT(attachment_url) AS count_attachment_url FROM insurance.posts GROUP BY tags;


[User] Get all posts.

[Assistant] SELECT * FROM insurance.posts;

[User] Can you order these by reply_to_id ascending?

[Assistant] SELECT * FROM insurance.posts ORDER BY reply_to_id ASC;

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

[Assistant] SELECT * FROM insurance.posts ORDER BY facilitie_id DESC;


[User] List all posts.

[Assistant] SELECT * FROM insurance.posts;

[User] Sort the results by attachment_url ascending.

[Assistant] SELECT * FROM insurance.posts ORDER BY attachment_url ASC;

[User] Only show the top 5 results.

[Assistant] SELECT * FROM insurance.posts ORDER BY attachment_url ASC LIMIT 5;


[User] Get all posts.

[Assistant] SELECT * FROM insurance.posts;

[User] Show me format, published_at, last_inspected, city from posts and their related facilities.

[Assistant] SELECT *, facilities.last_inspected, facilities.city FROM insurance.posts JOIN insurance.facilities ON posts.facilitie_id = facilities.address_id;

[User] How many posts are there per message_id?

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


[User] Display all posts.

[Assistant] SELECT * FROM insurance.posts;

[User] Find posts older than 6 months.

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

[User] Sort the results by updated_at ascending.

[Assistant] SELECT * FROM insurance.posts WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY updated_at ASC;


[User] List facilitie_id, published_at, tags from posts.

[Assistant] SELECT facilitie_id, published_at, tags FROM insurance.posts;

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

[Assistant] SELECT facilitie_id, published_at, tags FROM insurance.posts WHERE published_at > '2023-12-01';

[User] Can you order these by reply_to_id descending?

[Assistant] SELECT facilitie_id, published_at, tags FROM insurance.posts WHERE published_at > '2023-12-01' ORDER BY reply_to_id DESC;


[User] List all posts.

[Assistant] SELECT * FROM insurance.posts;

[User] Retrieve format, message_id, timezone, city showing the relationship between posts and facilities.

[Assistant] SELECT *, facilities.timezone, facilities.city FROM insurance.posts JOIN insurance.facilities ON posts.facilitie_id = facilities.address_id;

[User] Tally up posts by attachment_url.

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


[User] List all posts.

[Assistant] SELECT * FROM insurance.posts;

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

[Assistant] SELECT * FROM insurance.posts ORDER BY published_at DESC;

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM insurance.posts ORDER BY published_at DESC LIMIT 10;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.shipping (
  person_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  joined_at timestamp,
  email character varying(256),
  display_name character varying(256),
  nationality character varying(128) NOT NULL,
  membership_level varchar NOT NULL,
  last_login timestamp without time zone,
  bio character varying(128) NOT NULL,
  review_id text NOT NULL -- reference to reviews.message_id,
  FOREIGN KEY (review_id) REFERENCES reviews(message_id)
)

CREATE TABLE e-commerce.reviews (
  message_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  media_url varchar NOT NULL,
  keywords char,
  text varchar
)

CREATE TABLE e-commerce.categories (
  customer_id varchar PRIMARY KEY -- unique identifier,
  last_active timestamp,
  profile_picture_url character varying(64),
  display_name character varying(256),
  state character varying(128),
  membership_level char
)

[User] Get membership_level, updated_at, display_name from all shipping.

[Assistant] SELECT membership_level, updated_at, display_name FROM e-commerce.shipping;

[User] Show me membership_level, display_name, media_url, text from shipping and their related reviews.

[Assistant] SELECT membership_level, updated_at, display_name, reviews.media_url, reviews.text FROM e-commerce.shipping JOIN e-commerce.reviews ON shipping.review_id = reviews.message_id;

[User] Get the distribution of shipping across different display_name values.

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


[User] Retrieve all shipping.

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

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

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

[User] Return just 15 rows.

[Assistant] SELECT * FROM e-commerce.shipping WHERE last_login >= CURRENT_DATE - INTERVAL '30 days' LIMIT 15;


[User] List all shipping.

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

[User] Show me display_name, membership_level, created_at, keywords from shipping and their related reviews.

[Assistant] SELECT *, reviews.created_at, reviews.keywords FROM e-commerce.shipping JOIN e-commerce.reviews ON shipping.review_id = reviews.message_id;

[User] Only show the top 25 results.

[Assistant] SELECT *, reviews.created_at, reviews.keywords FROM e-commerce.shipping JOIN e-commerce.reviews ON shipping.review_id = reviews.message_id LIMIT 25;


[User] Display all shipping.

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

[User] Sort the results by joined_at ascending.

[Assistant] SELECT * FROM e-commerce.shipping ORDER BY joined_at ASC;

[User] Sort the results by bio ascending.

[Assistant] SELECT * FROM e-commerce.shipping ORDER BY bio ASC;


[User] Retrieve updated_at, display_name, membership_level for every shipping.

[Assistant] SELECT updated_at, display_name, membership_level FROM e-commerce.shipping;

[User] Get last_login, nationality, keywords, media_url by joining shipping with reviews.

[Assistant] SELECT updated_at, display_name, membership_level, reviews.keywords, reviews.media_url FROM e-commerce.shipping JOIN e-commerce.reviews ON shipping.review_id = reviews.message_id;

[User] Sort the results by display_name descending.

[Assistant] SELECT updated_at, display_name, membership_level, reviews.keywords, reviews.media_url FROM e-commerce.shipping JOIN e-commerce.reviews ON shipping.review_id = reviews.message_id ORDER BY display_name DESC;


[User] Show me joined_at, review_id, updated_at for all shipping.

[Assistant] SELECT joined_at, review_id, updated_at FROM e-commerce.shipping;

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

[Assistant] SELECT joined_at, review_id, updated_at FROM e-commerce.shipping WHERE updated_at > '2023-01-01';

[User] Show me average of membership_level grouped by last_login for shipping.

[Assistant] SELECT last_login, AVERAGE(membership_level) AS average_membership_level FROM e-commerce.shipping GROUP BY last_login;


[User] Get all shipping.

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

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

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

[User] Show only 10 records.

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


[User] Get all shipping.

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

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

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

[User] Restrict the output to 100 items.

[Assistant] SELECT * FROM e-commerce.shipping WHERE review_id LIKE 'A%' LIMIT 100;


[User] What are the last_login, email, display_name of each shipping?

[Assistant] SELECT last_login, email, display_name FROM e-commerce.shipping;

[User] Find shipping created yesterday.

[Assistant] SELECT last_login, email, display_name FROM e-commerce.shipping WHERE last_login = CURRENT_DATE - INTERVAL '1 day';

[User] Get the distribution of shipping across different membership_level values.

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


[User] What are the membership_level, bio, review_id of each shipping?

[Assistant] SELECT membership_level, bio, review_id FROM e-commerce.shipping;

[User] Can you order these by review_id ascending?

[Assistant] SELECT membership_level, bio, review_id FROM e-commerce.shipping ORDER BY review_id ASC;

[User] Show only 20 records.

[Assistant] SELECT membership_level, bio, review_id FROM e-commerce.shipping ORDER BY review_id ASC 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 education.enrollments (
  content_id character varying(64) NOT NULL -- unique identifier,
  edited_at timestamp,
  updated_at date,
  views character varying(64),
  keywords varchar,
  tags text NOT NULL,
  teacher_id text NOT NULL -- reference to teachers.order_id,
  department_id integer -- reference to departments.employee_id,
  FOREIGN KEY (teacher_id) REFERENCES teachers(order_id),
  FOREIGN KEY (department_id) REFERENCES departments(employee_id)
)

CREATE TABLE education.teachers (
  order_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  delivery_status char,
  exchange_rate char,
  payment_method character varying(256) NOT NULL
)

CREATE TABLE education.departments (
  employee_id integer PRIMARY KEY -- unique identifier,
  joined_at timestamp,
  updated_at timestamp,
  country text,
  zip_code character varying(128),
  first_name text,
  age char,
  api_key char NOT NULL,
  last_login timestamp,
  is_active boolean -- indicates if active is true,
  teacher_id text NOT NULL -- reference to teachers.order_id,
  FOREIGN KEY (teacher_id) REFERENCES teachers(order_id)
)

[User] Show me country, first_name, api_key for all departments.

[Assistant] SELECT country, first_name, api_key FROM education.departments;

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

[Assistant] SELECT country, first_name, api_key FROM education.departments WHERE updated_at > '2023-01-01';

[User] Order the output by api_key descending.

[Assistant] SELECT country, first_name, api_key FROM education.departments WHERE updated_at > '2023-01-01' ORDER BY api_key DESC;


[User] What are the content_id, tags, edited_at of each enrollment?

[Assistant] SELECT content_id, tags, edited_at FROM education.enrollments;

[User] Sort the results by edited_at descending.

[Assistant] SELECT content_id, tags, edited_at FROM education.enrollments ORDER BY edited_at DESC;

[User] Order the output by tags descending.

[Assistant] SELECT content_id, tags, edited_at FROM education.enrollments ORDER BY tags DESC;


[User] Retrieve all departments.

[Assistant] SELECT * FROM education.departments;

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

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

[User] Group departments by age and show the average of teacher_id.

[Assistant] SELECT age, AVERAGE(teacher_id) AS average_teacher_id FROM education.departments GROUP BY age;


[User] Show me all departments.

[Assistant] SELECT * FROM education.departments;

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

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

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

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


[User] Get all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Get enrollments that match teacher_id LIKE 'A%'.

[Assistant] SELECT * FROM education.enrollments WHERE teacher_id LIKE 'A%';

[User] How many enrollments are there per keywords?

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


[User] Get tags, edited_at, content_id from all enrollments.

[Assistant] SELECT tags, edited_at, content_id FROM education.enrollments;

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

[Assistant] SELECT tags, edited_at, content_id FROM education.enrollments WHERE edited_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Restrict the output to 50 items.

[Assistant] SELECT tags, edited_at, content_id FROM education.enrollments WHERE edited_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 50;


[User] Display all departments.

[Assistant] SELECT * FROM education.departments;

[User] Order the output by is_active descending.

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

[User] Get sum of is_active by first_name from departments.

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


[User] Retrieve api_key, age, zip_code for every department.

[Assistant] SELECT api_key, age, zip_code FROM education.departments;

[User] Retrieve departments where last_login > '2023-01-01'.

[Assistant] SELECT api_key, age, zip_code FROM education.departments WHERE last_login > '2023-01-01';

[User] Order the output by zip_code ascending.

[Assistant] SELECT api_key, age, zip_code FROM education.departments WHERE last_login > '2023-01-01' ORDER BY zip_code ASC;


[User] Show me is_active, age, country for all departments.

[Assistant] SELECT is_active, age, country FROM education.departments;

[User] Get all departments older than 6 months.

[Assistant] SELECT is_active, age, country FROM education.departments WHERE last_login <= CURRENT_DATE - INTERVAL '6 months';

[User] Group departments by teacher_id and show the max of country.

[Assistant] SELECT teacher_id, MAX(country) AS max_country FROM education.departments GROUP BY teacher_id;


[User] Retrieve all departments.

[Assistant] SELECT * FROM education.departments;

[User] What teacher_id, last_login, exchange_rate, updated_at do we have for departments and their associated teachers?

[Assistant] SELECT *, teachers.exchange_rate, teachers.updated_at FROM education.departments JOIN education.teachers ON departments.teacher_id = teachers.order_id;

[User] Only show the top 50 results.

[Assistant] SELECT *, teachers.exchange_rate, teachers.updated_at FROM education.departments JOIN education.teachers ON departments.teacher_id = teachers.order_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 socialmedia.events (
  message_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp without time zone,
  edited_at timestamp,
  rating text NOT NULL,
  image_url character varying(256) NOT NULL,
  thumbnail character varying(64),
  likes varchar NOT NULL,
  user_id character varying(64) NOT NULL
)

CREATE TABLE socialmedia.messages (
  message_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  edited_at timestamp without time zone,
  parent_id character varying(128),
  description character varying(256),
  views character varying(256) NOT NULL,
  title character varying(256),
  rating varchar,
  tags char NOT NULL
)

CREATE TABLE socialmedia.groups (
  location_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  country character varying(64) NOT NULL,
  state text NOT NULL,
  operating_hours character varying(64),
  postal_code char,
  message_id text -- reference to messages.message_id,
  FOREIGN KEY (message_id) REFERENCES messages(message_id)
)

[User] Show me all groups.

[Assistant] SELECT * FROM socialmedia.groups;

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

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

[User] Sort the results by location_id descending.

[Assistant] SELECT * FROM socialmedia.groups WHERE updated_at > '2023-12-01' ORDER BY location_id DESC;


[User] Show me message_id, state, postal_code for all groups.

[Assistant] SELECT message_id, state, postal_code FROM socialmedia.groups;

[User] Get operating_hours, state, edited_at, updated_at by joining groups with messages.

[Assistant] SELECT message_id, state, postal_code, messages.edited_at, messages.updated_at FROM socialmedia.groups JOIN socialmedia.messages ON groups.message_id = messages.message_id;

[User] Limit the results to 100 rows.

[Assistant] SELECT message_id, state, postal_code, messages.edited_at, messages.updated_at FROM socialmedia.groups JOIN socialmedia.messages ON groups.message_id = messages.message_id LIMIT 100;


[User] Get location_id, postal_code, updated_at from all groups.

[Assistant] SELECT location_id, postal_code, updated_at FROM socialmedia.groups;

[User] Order the output by location_id descending.

[Assistant] SELECT location_id, postal_code, updated_at FROM socialmedia.groups ORDER BY location_id DESC;

[User] How many groups are there per state?

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


[User] Retrieve all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Retrieve operating_hours, country, edited_at, updated_at showing the relationship between groups and messages.

[Assistant] SELECT *, messages.edited_at, messages.updated_at FROM socialmedia.groups JOIN socialmedia.messages ON groups.message_id = messages.message_id;

[User] Count the number of groups in each operating_hours category.

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


[User] List country, location_id, operating_hours from groups.

[Assistant] SELECT country, location_id, operating_hours FROM socialmedia.groups;

[User] Show me location_id, updated_at, rating, updated_at from groups and their related messages.

[Assistant] SELECT country, location_id, operating_hours, messages.rating, messages.updated_at FROM socialmedia.groups JOIN socialmedia.messages ON groups.message_id = messages.message_id;

[User] Show me average of updated_at grouped by state for groups.

[Assistant] SELECT state, AVERAGE(updated_at) AS average_updated_at FROM socialmedia.groups GROUP BY state;


[User] Retrieve all groups.

[Assistant] SELECT * FROM socialmedia.groups;

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

[Assistant] SELECT * FROM socialmedia.groups WHERE state LIKE 'A%';

[User] Show me the count of groups grouped by operating_hours.

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


[User] What are the operating_hours, country, message_id of each group?

[Assistant] SELECT operating_hours, country, message_id FROM socialmedia.groups;

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

[Assistant] SELECT operating_hours, country, message_id FROM socialmedia.groups ORDER BY message_id DESC;

[User] Limit the results to 25 rows.

[Assistant] SELECT operating_hours, country, message_id FROM socialmedia.groups ORDER BY message_id DESC LIMIT 25;


[User] Display all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Find groups where country LIKE 'A%'.

[Assistant] SELECT * FROM socialmedia.groups WHERE country LIKE 'A%';

[User] Limit the results to 20 rows.

[Assistant] SELECT * FROM socialmedia.groups WHERE country LIKE 'A%' LIMIT 20;


[User] Get all groups.

[Assistant] SELECT * FROM socialmedia.groups;

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

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

[User] Return just 20 rows.

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


[User] List location_id, postal_code, country from groups.

[Assistant] SELECT location_id, postal_code, country FROM socialmedia.groups;

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

[Assistant] SELECT location_id, postal_code, country FROM socialmedia.groups WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Can you order these by updated_at ascending?

[Assistant] SELECT location_id, postal_code, country FROM socialmedia.groups WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY updated_at ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.posts (
  post_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  rating varchar,
  parent_id character varying(256) -- identifier for parent,
  author_id character varying(64),
  subject character varying(128) NOT NULL,
  visibility char,
  likes varchar
)

CREATE TABLE socialmedia.messages (
  post_id character varying(64) NOT NULL -- unique identifier,
  edited_at date,
  text text,
  rating text NOT NULL,
  title char
)

CREATE TABLE socialmedia.followers (
  payment_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  cancelled_at timestamp without time zone,
  payment_status char,
  approval_status character varying(256) NOT NULL,
  subtotal bigint NOT NULL,
  payment_method char
)

CREATE TABLE socialmedia.events (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  debit text,
  amount numeric(38,14),
  category char NOT NULL,
  notes character varying(256),
  currency char
)

[User] Get all messages.

[Assistant] SELECT * FROM socialmedia.messages;

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

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

[User] How many messages are there per edited_at?

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


[User] Retrieve all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Find events from 2023.

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

[User] Limit the results to 100 rows.

[Assistant] SELECT * FROM socialmedia.events WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 100;


[User] Get all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Show me events with amount > 47.

[Assistant] SELECT * FROM socialmedia.events WHERE amount > 47;

[User] Limit the results to 10 rows.

[Assistant] SELECT * FROM socialmedia.events WHERE amount > 47 LIMIT 10;


[User] What are the updated_at, amount, category of each event?

[Assistant] SELECT updated_at, amount, category FROM socialmedia.events;

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

[Assistant] SELECT updated_at, amount, category FROM socialmedia.events WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Return just 5 rows.

[Assistant] SELECT updated_at, amount, category FROM socialmedia.events WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 5;


[User] Retrieve cancelled_at, payment_method, payment_status for every follower.

[Assistant] SELECT cancelled_at, payment_method, payment_status FROM socialmedia.followers;

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

[Assistant] SELECT cancelled_at, payment_method, payment_status FROM socialmedia.followers WHERE approval_status LIKE 'A%';

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

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


[User] Show me title, edited_at, post_id for all messages.

[Assistant] SELECT title, edited_at, post_id FROM socialmedia.messages;

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

[Assistant] SELECT title, edited_at, post_id FROM socialmedia.messages WHERE edited_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

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

[Assistant] SELECT title, edited_at, post_id FROM socialmedia.messages WHERE edited_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY title ASC;


[User] List rating, post_id, text from messages.

[Assistant] SELECT rating, post_id, text FROM socialmedia.messages;

[User] Show the results sorted by title descending.

[Assistant] SELECT rating, post_id, text FROM socialmedia.messages ORDER BY title DESC;

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

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


[User] Get post_id, rating, title from all messages.

[Assistant] SELECT post_id, rating, title FROM socialmedia.messages;

[User] Show the results sorted by rating ascending.

[Assistant] SELECT post_id, rating, title FROM socialmedia.messages ORDER BY rating ASC;

[User] Get max of edited_at by text from messages.

[Assistant] SELECT text, MAX(edited_at) AS max_edited_at FROM socialmedia.messages GROUP BY text;


[User] Show me all posts.

[Assistant] SELECT * FROM socialmedia.posts;

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

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

[User] Can you order these by visibility ascending?

[Assistant] SELECT * FROM socialmedia.posts WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY visibility ASC;


[User] Retrieve all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] Show me posts with rating LIKE 'A%'.

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

[User] Order the output by author_id descending.

[Assistant] SELECT * FROM socialmedia.posts WHERE rating LIKE 'A%' ORDER BY author_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.departments (
  message_id varchar PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  created_at timestamp without time zone,
  thumbnail text,
  author_id char,
  subject text,
  visibility character varying(128),
  billin_id integer NOT NULL -- reference to billing.id,
  FOREIGN KEY (billin_id) REFERENCES billing(id)
)

CREATE TABLE healthcare.billing (
  id integer PRIMARY KEY -- unique identifier,
  expires_at timestamp without time zone,
  available text,
  tax_rate text NOT NULL,
  media_url char,
  thumbnail_url character varying(256) NOT NULL,
  image_url character varying(64) NOT NULL,
  views character varying(256) NOT NULL,
  doctor_id text NOT NULL -- reference to doctors.comment_id,
  FOREIGN KEY (doctor_id) REFERENCES doctors(comment_id)
)

CREATE TABLE healthcare.doctors (
  comment_id text PRIMARY KEY -- unique identifier,
  published_at date,
  created_at date,
  visibility character varying(128),
  format character varying(256),
  parent_id character varying(128) NOT NULL -- identifier for parent,
  billin_id integer -- reference to billing.id,
  department_id text NOT NULL -- reference to departments.message_id,
  FOREIGN KEY (billin_id) REFERENCES billing(id),
  FOREIGN KEY (department_id) REFERENCES departments(message_id)
)

[User] List all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Show me format, visibility, thumbnail_url, image_url from doctors and their related billing.

[Assistant] SELECT *, billing.thumbnail_url, billing.image_url FROM healthcare.doctors JOIN healthcare.billing ON doctors.billin_id = billing.id;

[User] Can you order these by visibility ascending?

[Assistant] SELECT *, billing.thumbnail_url, billing.image_url FROM healthcare.doctors JOIN healthcare.billing ON doctors.billin_id = billing.id ORDER BY visibility ASC;


[User] Get all departments.

[Assistant] SELECT * FROM healthcare.departments;

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

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

[User] Show me max of author_id grouped by edited_at for departments.

[Assistant] SELECT edited_at, MAX(author_id) AS max_author_id FROM healthcare.departments GROUP BY edited_at;


[User] Retrieve all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Show me subject, billin_id, expires_at, thumbnail_url from departments and their related billing.

[Assistant] SELECT *, billing.expires_at, billing.thumbnail_url FROM healthcare.departments JOIN healthcare.billing ON departments.billin_id = billing.id;

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

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


[User] Display all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Get departments that match billin_id > 64.

[Assistant] SELECT * FROM healthcare.departments WHERE billin_id > 64;

[User] Show the results sorted by edited_at descending.

[Assistant] SELECT * FROM healthcare.departments WHERE billin_id > 64 ORDER BY edited_at DESC;


[User] List media_url, views, available from billing.

[Assistant] SELECT media_url, views, available FROM healthcare.billing;

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

[Assistant] SELECT media_url, views, available FROM healthcare.billing ORDER BY tax_rate ASC;

[User] Order the output by thumbnail_url ascending.

[Assistant] SELECT media_url, views, available FROM healthcare.billing ORDER BY thumbnail_url ASC;


[User] Retrieve all departments.

[Assistant] SELECT * FROM healthcare.departments;

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

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

[User] Calculate average of created_at for each thumbnail in departments.

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


[User] What are the subject, edited_at, billin_id of each department?

[Assistant] SELECT subject, edited_at, billin_id FROM healthcare.departments;

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

[Assistant] SELECT subject, edited_at, billin_id FROM healthcare.departments WHERE edited_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Get average of billin_id by edited_at from departments.

[Assistant] SELECT edited_at, AVERAGE(billin_id) AS average_billin_id FROM healthcare.departments GROUP BY edited_at;


[User] Retrieve all departments.

[Assistant] SELECT * FROM healthcare.departments;

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

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

[User] Can you order these by subject descending?

[Assistant] SELECT * FROM healthcare.departments WHERE created_at > '2023-01-01' ORDER BY subject DESC;


[User] Show me all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Retrieve departments where billin_id > 53.

[Assistant] SELECT * FROM healthcare.departments WHERE billin_id > 53;

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

[Assistant] SELECT * FROM healthcare.departments WHERE billin_id > 53 ORDER BY created_at ASC;


[User] Retrieve views, image_url, available for every billing.

[Assistant] SELECT views, image_url, available FROM healthcare.billing;

[User] Sort the results by available ascending.

[Assistant] SELECT views, image_url, available FROM healthcare.billing ORDER BY available ASC;

[User] Can you order these by available ascending?

[Assistant] SELECT views, image_url, available FROM healthcare.billing ORDER BY available ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.posts (
  post_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  created_at timestamp,
  content character varying(64) NOT NULL,
  categories text,
  keywords text,
  title varchar NOT NULL,
  body varchar NOT NULL
)

CREATE TABLE socialmedia.followers (
  message_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  edited_at timestamp without time zone,
  tags varchar NOT NULL,
  shares text,
  body text,
  image_url varchar NOT NULL,
  media_url character varying(256)
)

CREATE TABLE socialmedia.comments (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  edited_at timestamp,
  views character varying(256),
  thumbnail char,
  image_url character varying(64),
  format character varying(256),
  parent_id character varying(64) NOT NULL -- identifier for parent,
  text text
)

CREATE TABLE socialmedia.events (
  venue_id character varying(64) NOT NULL -- unique identifier,
  last_inspected date,
  updated_at timestamp without time zone,
  latitude char,
  country character varying(128),
  category char,
  name char,
  description varchar NOT NULL,
  capacity character varying(256),
  longitude character varying(128),
  follower_id text NOT NULL -- reference to followers.message_id,
  FOREIGN KEY (follower_id) REFERENCES followers(message_id)
)

[User] Get latitude, category, follower_id from all events.

[Assistant] SELECT latitude, category, follower_id FROM socialmedia.events;

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

[Assistant] SELECT latitude, category, follower_id FROM socialmedia.events WHERE last_inspected >= CURRENT_DATE - INTERVAL '30 days';

[User] Show me sum of category grouped by follower_id for events.

[Assistant] SELECT follower_id, SUM(category) AS sum_category FROM socialmedia.events GROUP BY follower_id;


[User] Show me latitude, description, last_inspected for all events.

[Assistant] SELECT latitude, description, last_inspected FROM socialmedia.events;

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

[Assistant] SELECT latitude, description, last_inspected FROM socialmedia.events WHERE country LIKE 'A%';

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

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


[User] Retrieve all events.

[Assistant] SELECT * FROM socialmedia.events;

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

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

[User] Order the output by venue_id ascending.

[Assistant] SELECT * FROM socialmedia.events WHERE updated_at > '2023-12-01' ORDER BY venue_id ASC;


[User] Show me all events.

[Assistant] SELECT * FROM socialmedia.events;

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

[Assistant] SELECT * FROM socialmedia.events WHERE last_inspected >= CURRENT_DATE - INTERVAL '30 days';

[User] Show me min of description grouped by country for events.

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


[User] Get all events.

[Assistant] SELECT * FROM socialmedia.events;

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

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

[User] Restrict the output to 20 items.

[Assistant] SELECT * FROM socialmedia.events WHERE last_inspected BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 20;


[User] What are the country, follower_id, latitude of each event?

[Assistant] SELECT country, follower_id, latitude FROM socialmedia.events;

[User] Show the results sorted by country descending.

[Assistant] SELECT country, follower_id, latitude FROM socialmedia.events ORDER BY country DESC;

[User] Can you order these by description ascending?

[Assistant] SELECT country, follower_id, latitude FROM socialmedia.events ORDER BY description ASC;


[User] What are the category, updated_at, description of each event?

[Assistant] SELECT category, updated_at, description FROM socialmedia.events;

[User] Sort the results by country ascending.

[Assistant] SELECT category, updated_at, description FROM socialmedia.events ORDER BY country ASC;

[User] Return just 5 rows.

[Assistant] SELECT category, updated_at, description FROM socialmedia.events ORDER BY country ASC LIMIT 5;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE banking.customers (
  employee_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  last_active timestamp without time zone,
  city character varying(256),
  age text NOT NULL,
  language character varying(128) NOT NULL,
  profile_picture_url character varying(128),
  subscription_id integer NOT NULL -- reference to subscriptions.transaction_id,
  FOREIGN KEY (subscription_id) REFERENCES subscriptions(transaction_id)
)

CREATE TABLE banking.subscriptions (
  transaction_id integer PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  notes text,
  exchange_rate varchar,
  verification_status text,
  payee_id char NOT NULL -- identifier for payee,
  customer_id text -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

CREATE TABLE banking.purchases (
  transaction_id text PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  status varchar,
  subtotal numeric NOT NULL,
  exchange_rate char,
  customer_id text NOT NULL -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

[User] List all customers.

[Assistant] SELECT * FROM banking.customers;

[User] List customers that have subscription_id > 9.

[Assistant] SELECT * FROM banking.customers WHERE subscription_id > 9;

[User] How many customers are there per profile_picture_url?

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


[User] Show me all subscriptions.

[Assistant] SELECT * FROM banking.subscriptions;

[User] Show the results sorted by customer_id ascending.

[Assistant] SELECT * FROM banking.subscriptions ORDER BY customer_id ASC;

[User] Show me count of verification_status grouped by verification_status for subscriptions.

[Assistant] SELECT verification_status, COUNT(verification_status) AS count_verification_status FROM banking.subscriptions GROUP BY verification_status;


[User] Display all customers.

[Assistant] SELECT * FROM banking.customers;

[User] Can you order these by language descending?

[Assistant] SELECT * FROM banking.customers ORDER BY language DESC;

[User] Group customers by age and show the max of age.

[Assistant] SELECT age, MAX(age) AS max_age FROM banking.customers GROUP BY age;


[User] Retrieve exchange_rate, subtotal, customer_id for every purchase.

[Assistant] SELECT exchange_rate, subtotal, customer_id FROM banking.purchases;

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

[Assistant] SELECT exchange_rate, subtotal, customer_id FROM banking.purchases WHERE cancelled_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Show me the count of purchases grouped by status.

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