[User] Get all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Show me category, wallet_id, wallet_id, last_active from metadata and their related users.

[Assistant] SELECT *, users.wallet_id, users.last_active FROM tradingplatform.metadata JOIN tradingplatform.users ON metadata.user_id = users.id;

[User] Get average of category by timezone from metadata.

[Assistant] SELECT timezone, AVERAGE(category) AS average_category FROM tradingplatform.metadata GROUP BY timezone;


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.metadata (
  location_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  coordinates varchar,
  parking_available text NOT NULL,
  location_lon character varying(256),
  category char,
  timezone char NOT NULL,
  user_id text NOT NULL -- reference to users.id,
  wallet_id text -- reference to wallets.account_id,
  FOREIGN KEY (user_id) REFERENCES users(id),
  FOREIGN KEY (wallet_id) REFERENCES wallets(account_id)
)

CREATE TABLE tradingplatform.wallets (
  account_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  updated_at timestamp,
  payer_id varchar -- identifier for payer,
  user_id character varying(256),
  reconciliation_status character varying(128),
  category text,
  currency character varying(256)
)

CREATE TABLE tradingplatform.users (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  last_active timestamp,
  email character varying(64),
  token text NOT NULL,
  language text,
  city character varying(256),
  membership_level text,
  wallet_id text NOT NULL -- reference to wallets.account_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(account_id)
)

[User] Show me membership_level, wallet_id, email for all users.

[Assistant] SELECT membership_level, wallet_id, email FROM tradingplatform.users;

[User] Find users modified within the last hour.

[Assistant] SELECT membership_level, wallet_id, email FROM tradingplatform.users WHERE last_active >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

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

[Assistant] SELECT membership_level, wallet_id, email FROM tradingplatform.users WHERE last_active >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY last_active ASC;


[User] What are the email, language, wallet_id of each user?

[Assistant] SELECT email, language, wallet_id FROM tradingplatform.users;

[User] Show the results sorted by wallet_id ascending.

[Assistant] SELECT email, language, wallet_id FROM tradingplatform.users ORDER BY wallet_id ASC;

[User] Show me min of created_at grouped by language for users.

[Assistant] SELECT language, MIN(created_at) AS min_created_at FROM tradingplatform.users GROUP BY language;


[User] Show me all users.

[Assistant] SELECT * FROM tradingplatform.users;

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

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

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

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


[User] What are the email, last_active, language of each user?

[Assistant] SELECT email, last_active, language FROM tradingplatform.users;

[User] Find users modified within the last hour.

[Assistant] SELECT email, last_active, language FROM tradingplatform.users WHERE last_active >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Group users by language and show the count of language.

[Assistant] SELECT language, COUNT(language) AS count_language FROM tradingplatform.users GROUP BY language;


[User] What are the language, last_active, token of each user?

[Assistant] SELECT language, last_active, token FROM tradingplatform.users;

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

[Assistant] SELECT language, last_active, token FROM tradingplatform.users WHERE created_at > '2023-01-01';

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

[Assistant] SELECT language, last_active, token FROM tradingplatform.users WHERE created_at > '2023-01-01' ORDER BY last_active DESC;


[User] Show me email, language, token for all users.

[Assistant] SELECT email, language, token FROM tradingplatform.users;

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

[Assistant] SELECT email, language, token FROM tradingplatform.users WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

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

[Assistant] SELECT email, language, token FROM tradingplatform.users WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY email 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 (
  store_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  last_inspected timestamp,
  accessibility character varying(64),
  parking_available character varying(128) NOT NULL,
  address_line1 char NOT NULL,
  type char,
  department_id text -- reference to departments.invoice_id,
  FOREIGN KEY (department_id) REFERENCES departments(invoice_id)
)

CREATE TABLE healthcare.departments (
  invoice_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  amount decimal NOT NULL,
  buyer_id character varying(128),
  payment_status character varying(128),
  card_type character varying(64) NOT NULL,
  discount integer,
  appointment_id text NOT NULL -- reference to appointments.transaction_id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(transaction_id)
)

CREATE TABLE healthcare.appointments (
  transaction_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  payment_date timestamp,
  credit varchar,
  category character varying(64),
  reference_number char NOT NULL,
  approval_status char NOT NULL,
  reconciliation_status character varying(256) NOT NULL,
  currency character varying(128),
  payer_id character varying(256)
)

[User] List all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Retrieve departments where appointment_id LIKE 'A%'.

[Assistant] SELECT * FROM healthcare.departments WHERE appointment_id LIKE 'A%';

[User] Return just 10 rows.

[Assistant] SELECT * FROM healthcare.departments WHERE appointment_id LIKE 'A%' LIMIT 10;


[User] Get all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Find departments where appointment_id LIKE 'A%'.

[Assistant] SELECT * FROM healthcare.departments WHERE appointment_id LIKE 'A%';

[User] Return just 10 rows.

[Assistant] SELECT * FROM healthcare.departments WHERE appointment_id LIKE 'A%' LIMIT 10;


[User] Show me updated_at, buyer_id, discount for all departments.

[Assistant] SELECT updated_at, buyer_id, discount FROM healthcare.departments;

[User] Order the output by amount descending.

[Assistant] SELECT updated_at, buyer_id, discount FROM healthcare.departments ORDER BY amount DESC;

[User] Only show the top 25 results.

[Assistant] SELECT updated_at, buyer_id, discount FROM healthcare.departments ORDER BY amount DESC LIMIT 25;


[User] Get all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Find departments from 2023.

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

[User] Get min of buyer_id by buyer_id from departments.

[Assistant] SELECT buyer_id, MIN(buyer_id) AS min_buyer_id FROM healthcare.departments GROUP BY buyer_id;


[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Sort the results by created_at descending.

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

[User] How many billing are there per type?

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


[User] Display all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] What address_line1, department_id, appointment_id, discount do we have for billing and their associated departments?

[Assistant] SELECT *, departments.appointment_id, departments.discount FROM healthcare.billing JOIN healthcare.departments ON billing.department_id = departments.invoice_id;

[User] Sort the results by accessibility ascending.

[Assistant] SELECT *, departments.appointment_id, departments.discount FROM healthcare.billing JOIN healthcare.departments ON billing.department_id = departments.invoice_id ORDER BY accessibility ASC;


[User] Show me appointment_id, updated_at, payment_status for all departments.

[Assistant] SELECT appointment_id, updated_at, payment_status FROM healthcare.departments;

[User] List departments that have card_type LIKE 'A%'.

[Assistant] SELECT appointment_id, updated_at, payment_status FROM healthcare.departments WHERE card_type LIKE 'A%';

[User] How many departments are there per amount?

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


[User] Retrieve all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Can you order these by department_id descending?

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

[User] Show me the count of billing grouped by type.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.wallets (
  account_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  description text,
  reconciliation_status character varying(128),
  category text,
  trade_id text NOT NULL -- reference to trades.invoice_id,
  FOREIGN KEY (trade_id) REFERENCES trades(invoice_id)
)

CREATE TABLE tradingplatform.orders (
  payment_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  created_at date,
  quantity text,
  seller_id character varying(128),
  subtotal numeric(38,14),
  payment_status char NOT NULL,
  wallet_id text NOT NULL -- reference to wallets.account_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(account_id)
)

CREATE TABLE tradingplatform.trades (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  completed_at date,
  status character varying(128),
  currency text,
  customer_id text NOT NULL,
  user_id char,
  price decimal,
  wallet_id text -- reference to wallets.account_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(account_id)
)

[User] Retrieve all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Get payment_status, seller_id, reconciliation_status, trade_id by joining orders with wallets.

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

[User] Show me count of updated_at grouped by subtotal for orders.

[Assistant] SELECT subtotal, COUNT(updated_at) AS count_updated_at FROM tradingplatform.orders GROUP BY subtotal;


[User] Retrieve description, trade_id, created_at for every wallet.

[Assistant] SELECT description, trade_id, created_at FROM tradingplatform.wallets;

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

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

[User] Restrict the output to 10 items.

[Assistant] SELECT description, trade_id, created_at FROM tradingplatform.wallets WHERE created_at > '2023-01-01' LIMIT 10;


[User] Get all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Can you order these by created_at ascending?

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

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM tradingplatform.wallets ORDER BY created_at ASC LIMIT 10;


[User] Show me all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Order the output by reconciliation_status descending.

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

[User] Return just 15 rows.

[Assistant] SELECT * FROM tradingplatform.wallets ORDER BY reconciliation_status DESC LIMIT 15;


[User] Get all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

[User] List trades that have status LIKE 'A%'.

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

[User] Limit the results to 100 rows.

[Assistant] SELECT * FROM tradingplatform.trades WHERE status LIKE 'A%' LIMIT 100;


[User] Get all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Find wallets older than 6 months.

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

[User] Get sum of trade_id by trade_id from wallets.

[Assistant] SELECT trade_id, SUM(trade_id) AS sum_trade_id FROM tradingplatform.wallets GROUP BY trade_id;


[User] List price, currency, user_id from trades.

[Assistant] SELECT price, currency, user_id FROM tradingplatform.trades;

[User] Retrieve trades where price > 37.

[Assistant] SELECT price, currency, user_id FROM tradingplatform.trades WHERE price > 37;

[User] Limit the results to 25 rows.

[Assistant] SELECT price, currency, user_id FROM tradingplatform.trades WHERE price > 37 LIMIT 25;


[User] Display all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] What category, created_at, completed_at, user_id do we have for wallets and their associated trades?

[Assistant] SELECT *, trades.completed_at, trades.user_id FROM tradingplatform.wallets JOIN tradingplatform.trades ON wallets.trade_id = trades.invoice_id;

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

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


[User] Display all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Show the results sorted by updated_at ascending.

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

[User] Calculate min of quantity for each subtotal in orders.

[Assistant] SELECT subtotal, MIN(quantity) AS min_quantity FROM tradingplatform.orders GROUP BY subtotal;


[User] Retrieve description, reconciliation_status, created_at for every wallet.

[Assistant] SELECT description, reconciliation_status, created_at FROM tradingplatform.wallets;

[User] Retrieve trade_id, category, status, user_id showing the relationship between wallets and trades.

[Assistant] SELECT description, reconciliation_status, created_at, trades.status, trades.user_id FROM tradingplatform.wallets JOIN tradingplatform.trades ON wallets.trade_id = trades.invoice_id;

[User] Restrict the output to 15 items.

[Assistant] SELECT description, reconciliation_status, created_at, trades.status, trades.user_id FROM tradingplatform.wallets JOIN tradingplatform.trades ON wallets.trade_id = trades.invoice_id LIMIT 15;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.students (
  id text PRIMARY KEY -- unique identifier,
  last_active date,
  joined_at timestamp,
  country character varying(128),
  status character varying(256),
  gender character varying(128),
  avatar character varying(128)
)

CREATE TABLE education.teachers (
  post_id character varying(64) NOT NULL -- unique identifier,
  edited_at date,
  updated_at date,
  tags varchar NOT NULL,
  image_url character varying(256),
  body text,
  description char NOT NULL,
  user_id character varying(64),
  media_url character varying(128),
  student_id text -- reference to students.id,
  FOREIGN KEY (student_id) REFERENCES students(id)
)

[User] What are the updated_at, user_id, image_url of each teacher?

[Assistant] SELECT updated_at, user_id, image_url FROM education.teachers;

[User] Show me teachers with body LIKE 'A%'.

[Assistant] SELECT updated_at, user_id, image_url FROM education.teachers WHERE body LIKE 'A%';

[User] Calculate sum of image_url for each user_id in teachers.

[Assistant] SELECT user_id, SUM(image_url) AS sum_image_url FROM education.teachers GROUP BY user_id;


[User] Show me image_url, updated_at, body for all teachers.

[Assistant] SELECT image_url, updated_at, body FROM education.teachers;

[User] List image_url, description, status, avatar for each teacher along with their student information.

[Assistant] SELECT image_url, updated_at, body, students.status, students.avatar FROM education.teachers JOIN education.students ON teachers.student_id = students.id;

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

[Assistant] SELECT image_url, updated_at, body, students.status, students.avatar FROM education.teachers JOIN education.students ON teachers.student_id = students.id ORDER BY body ASC;


[User] Retrieve user_id, body, tags for every teacher.

[Assistant] SELECT user_id, body, tags FROM education.teachers;

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

[Assistant] SELECT user_id, body, tags FROM education.teachers WHERE updated_at > '2023-01-01';

[User] Show the results sorted by post_id ascending.

[Assistant] SELECT user_id, body, tags FROM education.teachers WHERE updated_at > '2023-01-01' ORDER BY post_id ASC;


[User] Retrieve all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

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

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


[User] List post_id, updated_at, body from teachers.

[Assistant] SELECT post_id, updated_at, body FROM education.teachers;

[User] Can you order these by student_id descending?

[Assistant] SELECT post_id, updated_at, body FROM education.teachers ORDER BY student_id DESC;

[User] Get sum of media_url by post_id from teachers.

[Assistant] SELECT post_id, SUM(media_url) AS sum_media_url FROM education.teachers GROUP BY post_id;


[User] Get tags, student_id, updated_at from all teachers.

[Assistant] SELECT tags, student_id, updated_at FROM education.teachers;

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

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

[User] Show the results sorted by edited_at descending.

[Assistant] SELECT tags, student_id, updated_at FROM education.teachers WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY edited_at DESC;


[User] Retrieve media_url, post_id, body for every teacher.

[Assistant] SELECT media_url, post_id, body FROM education.teachers;

[User] Sort the results by student_id ascending.

[Assistant] SELECT media_url, post_id, body FROM education.teachers ORDER BY student_id ASC;

[User] How many teachers are there per body?

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


[User] Retrieve edited_at, post_id, updated_at for every teacher.

[Assistant] SELECT edited_at, post_id, updated_at FROM education.teachers;

[User] Can you order these by updated_at ascending?

[Assistant] SELECT edited_at, post_id, updated_at FROM education.teachers ORDER BY updated_at ASC;

[User] What is the max user_id for each tags in teachers?

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


[User] List all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] Show the results sorted by post_id descending.

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

[User] Tally up teachers by media_url.

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


[User] List user_id, body, updated_at from teachers.

[Assistant] SELECT user_id, body, updated_at FROM education.teachers;

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

[Assistant] SELECT user_id, body, updated_at FROM education.teachers WHERE updated_at > '2023-01-01';

[User] Show only 20 records.

[Assistant] SELECT user_id, body, updated_at FROM education.teachers WHERE updated_at > '2023-01-01' 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 socialmedia.messages (
  id character varying(64) NOT NULL -- unique identifier,
  edited_at timestamp,
  author_id char NOT NULL,
  tags char,
  image_url character varying(64),
  user_id character varying(128) NOT NULL -- identifier for user,
  format char NOT NULL,
  group_id text NOT NULL -- reference to groups.payment_id,
  FOREIGN KEY (group_id) REFERENCES groups(payment_id)
)

CREATE TABLE socialmedia.groups (
  payment_id text PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  fee varchar,
  approval_status character varying(64),
  price numeric(38,14),
  payment_method varchar,
  user_id character varying(128),
  payment_status character varying(256) NOT NULL,
  card_type char
)

[User] Get tags, group_id, image_url from all messages.

[Assistant] SELECT tags, group_id, image_url FROM socialmedia.messages;

[User] List group_id, format, card_type, price for each message along with their group information.

[Assistant] SELECT tags, group_id, image_url, groups.card_type, groups.price FROM socialmedia.messages JOIN socialmedia.groups ON messages.group_id = groups.payment_id;

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

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


[User] Show me all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] What tags, user_id, price, user_id do we have for messages and their associated groups?

[Assistant] SELECT *, groups.price, groups.user_id FROM socialmedia.messages JOIN socialmedia.groups ON messages.group_id = groups.payment_id;

[User] Sort the results by image_url ascending.

[Assistant] SELECT *, groups.price, groups.user_id FROM socialmedia.messages JOIN socialmedia.groups ON messages.group_id = groups.payment_id ORDER BY image_url ASC;


[User] What are the image_url, user_id, author_id of each message?

[Assistant] SELECT image_url, user_id, author_id FROM socialmedia.messages;

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

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

[User] Limit the results to 15 rows.

[Assistant] SELECT image_url, user_id, author_id FROM socialmedia.messages WHERE edited_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 15;


[User] Get author_id, user_id, id from all messages.

[Assistant] SELECT author_id, user_id, id FROM socialmedia.messages;

[User] Order the output by user_id descending.

[Assistant] SELECT author_id, user_id, id FROM socialmedia.messages ORDER BY user_id DESC;

[User] Order the output by tags descending.

[Assistant] SELECT author_id, user_id, id FROM socialmedia.messages ORDER BY tags DESC;


[User] List all messages.

[Assistant] SELECT * FROM socialmedia.messages;

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

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

[User] Can you order these by user_id descending?

[Assistant] SELECT * FROM socialmedia.messages WHERE edited_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY user_id DESC;


[User] Get author_id, group_id, image_url from all messages.

[Assistant] SELECT author_id, group_id, image_url FROM socialmedia.messages;

[User] Get all messages from last week.

[Assistant] SELECT author_id, group_id, image_url FROM socialmedia.messages WHERE edited_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Return just 25 rows.

[Assistant] SELECT author_id, group_id, image_url FROM socialmedia.messages WHERE edited_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 25;


[User] Show me group_id, author_id, image_url for all messages.

[Assistant] SELECT group_id, author_id, image_url FROM socialmedia.messages;

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

[Assistant] SELECT group_id, author_id, image_url FROM socialmedia.messages ORDER BY edited_at ASC;

[User] What is the count tags for each image_url in messages?

[Assistant] SELECT image_url, COUNT(tags) AS count_tags FROM socialmedia.messages GROUP BY image_url;


[User] Retrieve all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Get tags, edited_at, traded_at, payment_status by joining messages with groups.

[Assistant] SELECT *, groups.traded_at, groups.payment_status FROM socialmedia.messages JOIN socialmedia.groups ON messages.group_id = groups.payment_id;

[User] Return just 5 rows.

[Assistant] SELECT *, groups.traded_at, groups.payment_status FROM socialmedia.messages JOIN socialmedia.groups ON messages.group_id = groups.payment_id LIMIT 5;


[User] Show me author_id, image_url, tags for all messages.

[Assistant] SELECT author_id, image_url, tags FROM socialmedia.messages;

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

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

[User] Sort the results by author_id descending.

[Assistant] SELECT author_id, image_url, tags FROM socialmedia.messages WHERE edited_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY author_id DESC;


[User] What are the author_id, tags, image_url of each message?

[Assistant] SELECT author_id, tags, image_url FROM socialmedia.messages;

[User] Show me messages with tags LIKE 'A%'.

[Assistant] SELECT author_id, tags, image_url FROM socialmedia.messages WHERE tags LIKE 'A%';

[User] Restrict the output to 5 items.

[Assistant] SELECT author_id, tags, image_url FROM socialmedia.messages WHERE tags LIKE 'A%' LIMIT 5;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.medical_records (
  user_id text PRIMARY KEY -- unique identifier,
  last_active timestamp,
  created_at date,
  first_name text,
  website character varying(256),
  full_name varchar,
  timezone character varying(64),
  salt text,
  billin_id text -- reference to billing.customer_id,
  FOREIGN KEY (billin_id) REFERENCES billing(customer_id)
)

CREATE TABLE healthcare.billing (
  customer_id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  created_at timestamp without time zone,
  display_name char,
  nationality char,
  gender character varying(64),
  bio varchar,
  birth_date timestamp without time zone NOT NULL
)

CREATE TABLE healthcare.appointments (
  user_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  gender varchar,
  zip_code text,
  language character varying(128),
  salt varchar,
  address character varying(256),
  billin_id text -- reference to billing.customer_id,
  FOREIGN KEY (billin_id) REFERENCES billing(customer_id)
)

[User] List full_name, timezone, first_name from medical_records.

[Assistant] SELECT full_name, timezone, first_name FROM healthcare.medical_records;

[User] Get last_active, website, nationality, display_name by joining medical_records with billing.

[Assistant] SELECT full_name, timezone, first_name, billing.nationality, billing.display_name FROM healthcare.medical_records JOIN healthcare.billing ON medical_records.billin_id = billing.customer_id;

[User] Show the results sorted by first_name descending.

[Assistant] SELECT full_name, timezone, first_name, billing.nationality, billing.display_name FROM healthcare.medical_records JOIN healthcare.billing ON medical_records.billin_id = billing.customer_id ORDER BY first_name DESC;


[User] Retrieve all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

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

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

[User] How many appointments are there per salt?

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


[User] Get billin_id, created_at, address from all appointments.

[Assistant] SELECT billin_id, created_at, address FROM healthcare.appointments;

[User] List zip_code, created_at, created_at, nationality for each appointment along with their billing information.

[Assistant] SELECT billin_id, created_at, address, billing.created_at, billing.nationality FROM healthcare.appointments JOIN healthcare.billing ON appointments.billin_id = billing.customer_id;

[User] Restrict the output to 15 items.

[Assistant] SELECT billin_id, created_at, address, billing.created_at, billing.nationality FROM healthcare.appointments JOIN healthcare.billing ON appointments.billin_id = billing.customer_id LIMIT 15;


[User] List all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] List billin_id, created_at, created_at, nationality for each medical_record along with their billing information.

[Assistant] SELECT *, billing.created_at, billing.nationality FROM healthcare.medical_records JOIN healthcare.billing ON medical_records.billin_id = billing.customer_id;

[User] Get min of first_name by billin_id from medical_records.

[Assistant] SELECT billin_id, MIN(first_name) AS min_first_name FROM healthcare.medical_records GROUP BY billin_id;


[User] Retrieve billin_id, website, salt for every medical_record.

[Assistant] SELECT billin_id, website, salt FROM healthcare.medical_records;

[User] Get medical_records that match timezone LIKE 'A%'.

[Assistant] SELECT billin_id, website, salt FROM healthcare.medical_records WHERE timezone LIKE 'A%';

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

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


[User] Show me first_name, billin_id, salt for all medical_records.

[Assistant] SELECT first_name, billin_id, salt FROM healthcare.medical_records;

[User] List medical_records that have salt LIKE 'A%'.

[Assistant] SELECT first_name, billin_id, salt FROM healthcare.medical_records WHERE salt LIKE 'A%';

[User] Limit the results to 5 rows.

[Assistant] SELECT first_name, billin_id, salt FROM healthcare.medical_records WHERE salt LIKE 'A%' LIMIT 5;


[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

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

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

[User] Sort the results by billin_id descending.

[Assistant] SELECT * FROM healthcare.appointments WHERE created_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY billin_id DESC;


[User] List language, billin_id, address from appointments.

[Assistant] SELECT language, billin_id, address FROM healthcare.appointments;

[User] Get all appointments from 2023.

[Assistant] SELECT language, billin_id, address FROM healthcare.appointments WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Order the output by created_at descending.

[Assistant] SELECT language, billin_id, address FROM healthcare.appointments WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY created_at DESC;


[User] List created_at, full_name, timezone from medical_records.

[Assistant] SELECT created_at, full_name, timezone FROM healthcare.medical_records;

[User] Show me salt, full_name, created_at, joined_at from medical_records and their related billing.

[Assistant] SELECT created_at, full_name, timezone, billing.created_at, billing.joined_at FROM healthcare.medical_records JOIN healthcare.billing ON medical_records.billin_id = billing.customer_id;

[User] Restrict the output to 25 items.

[Assistant] SELECT created_at, full_name, timezone, billing.created_at, billing.joined_at FROM healthcare.medical_records JOIN healthcare.billing ON medical_records.billin_id = billing.customer_id LIMIT 25;


[User] What are the billin_id, salt, full_name of each medical_record?

[Assistant] SELECT billin_id, salt, full_name FROM healthcare.medical_records;

[User] Can you order these by last_active ascending?

[Assistant] SELECT billin_id, salt, full_name FROM healthcare.medical_records ORDER BY last_active ASC;

[User] Limit the results to 100 rows.

[Assistant] SELECT billin_id, salt, full_name FROM healthcare.medical_records ORDER BY last_active ASC LIMIT 100;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.logs (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  delivery_status character varying(256),
  user_id character varying(256) -- identifier for user,
  status varchar
)

CREATE TABLE tradingplatform.assets (
  product_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  created_at timestamp without time zone,
  thumbnail_url char,
  media_url character varying(128),
  rating char,
  image_url character varying(128),
  category varchar,
  popularity_score character varying(256),
  wallet_id text -- reference to wallets.account_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(account_id)
)

CREATE TABLE tradingplatform.wallets (
  account_id text PRIMARY KEY -- unique identifier,
  payment_date date,
  updated_at timestamp,
  approval_status character varying(128),
  customer_id char NOT NULL,
  category character varying(128),
  reference_number character varying(128),
  exchange_rate varchar,
  payer_id character varying(64) NOT NULL,
  description character varying(64)
)

[User] List updated_at, popularity_score, rating from assets.

[Assistant] SELECT updated_at, popularity_score, rating FROM tradingplatform.assets;

[User] Show me rating, category, category, updated_at from assets and their related wallets.

[Assistant] SELECT updated_at, popularity_score, rating, wallets.category, wallets.updated_at FROM tradingplatform.assets JOIN tradingplatform.wallets ON assets.wallet_id = wallets.account_id;

[User] Return just 10 rows.

[Assistant] SELECT updated_at, popularity_score, rating, wallets.category, wallets.updated_at FROM tradingplatform.assets JOIN tradingplatform.wallets ON assets.wallet_id = wallets.account_id LIMIT 10;


[User] Retrieve product_id, wallet_id, created_at for every asset.

[Assistant] SELECT product_id, wallet_id, created_at FROM tradingplatform.assets;

[User] Show the results sorted by popularity_score descending.

[Assistant] SELECT product_id, wallet_id, created_at FROM tradingplatform.assets ORDER BY popularity_score DESC;

[User] Show me the count of assets grouped by popularity_score.

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


[User] Get category, media_url, popularity_score from all assets.

[Assistant] SELECT category, media_url, popularity_score FROM tradingplatform.assets;

[User] Sort the results by thumbnail_url descending.

[Assistant] SELECT category, media_url, popularity_score FROM tradingplatform.assets ORDER BY thumbnail_url DESC;

[User] Tally up assets by media_url.

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


[User] Get all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] What rating, updated_at, customer_id, payer_id do we have for assets and their associated wallets?

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

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

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


[User] List all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Get assets that match category LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.assets WHERE category LIKE 'A%';

[User] Get the distribution of assets across different product_id values.

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


[User] Display all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Retrieve assets where popularity_score LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.assets WHERE popularity_score LIKE 'A%';

[User] Sort the results by product_id ascending.

[Assistant] SELECT * FROM tradingplatform.assets WHERE popularity_score LIKE 'A%' ORDER BY product_id ASC;


[User] Retrieve rating, media_url, product_id for every asset.

[Assistant] SELECT rating, media_url, product_id FROM tradingplatform.assets;

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

[Assistant] SELECT rating, media_url, product_id FROM tradingplatform.assets WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Limit the results to 5 rows.

[Assistant] SELECT rating, media_url, product_id FROM tradingplatform.assets WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 5;


[User] List product_id, created_at, updated_at from assets.

[Assistant] SELECT product_id, created_at, updated_at FROM tradingplatform.assets;

[User] List rating, popularity_score, customer_id, approval_status for each asset along with their wallet information.

[Assistant] SELECT product_id, created_at, updated_at, wallets.customer_id, wallets.approval_status FROM tradingplatform.assets JOIN tradingplatform.wallets ON assets.wallet_id = wallets.account_id;

[User] Can you order these by wallet_id descending?

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


[User] List all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] List assets with dates created yesterday.

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

[User] What is the max rating for each popularity_score in assets?

[Assistant] SELECT popularity_score, MAX(rating) AS max_rating FROM tradingplatform.assets GROUP BY popularity_score;


[User] List category, image_url, popularity_score from assets.

[Assistant] SELECT category, image_url, popularity_score FROM tradingplatform.assets;

[User] What media_url, thumbnail_url, category, payer_id do we have for assets and their associated wallets?

[Assistant] SELECT category, image_url, popularity_score, wallets.category, wallets.payer_id FROM tradingplatform.assets JOIN tradingplatform.wallets ON assets.wallet_id = wallets.account_id;

[User] Sort the results by image_url ascending.

[Assistant] SELECT category, image_url, popularity_score, wallets.category, wallets.payer_id FROM tradingplatform.assets JOIN tradingplatform.wallets ON assets.wallet_id = wallets.account_id ORDER BY image_url 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.messages (
  content_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  media_url char,
  visibility character varying(64) NOT NULL,
  tags character varying(128),
  keywords character varying(64),
  user_id text -- identifier for user,
  thumbnail character varying(128) NOT NULL
)

CREATE TABLE socialmedia.groups (
  barcode character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  expires_at date,
  tax_rate character varying(64),
  subcategory varchar NOT NULL,
  video_url text -- identifier for video_url,
  featured_rank varchar,
  name character varying(64),
  backorder varchar,
  brand char
)

CREATE TABLE socialmedia.users (
  customer_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  joined_at date,
  address char,
  account_status character varying(64),
  display_name varchar,
  last_name char NOT NULL,
  age character varying(64) NOT NULL
)

[User] Get address, display_name, created_at from all users.

[Assistant] SELECT address, display_name, created_at FROM socialmedia.users;

[User] Sort the results by address descending.

[Assistant] SELECT address, display_name, created_at FROM socialmedia.users ORDER BY address DESC;

[User] Tally up users by address.

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


[User] Retrieve joined_at, created_at, display_name for every user.

[Assistant] SELECT joined_at, created_at, display_name FROM socialmedia.users;

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

[Assistant] SELECT joined_at, created_at, display_name FROM socialmedia.users WHERE address LIKE 'A%';

[User] Show the results sorted by joined_at descending.

[Assistant] SELECT joined_at, created_at, display_name FROM socialmedia.users WHERE address LIKE 'A%' ORDER BY joined_at DESC;


[User] List video_url, expires_at, featured_rank from groups.

[Assistant] SELECT video_url, expires_at, featured_rank FROM socialmedia.groups;

[User] List groups with dates from last week.

[Assistant] SELECT video_url, expires_at, featured_rank FROM socialmedia.groups WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Return just 25 rows.

[Assistant] SELECT video_url, expires_at, featured_rank FROM socialmedia.groups WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 25;


[User] What are the subcategory, brand, expires_at of each group?

[Assistant] SELECT subcategory, brand, expires_at FROM socialmedia.groups;

[User] Sort the results by subcategory ascending.

[Assistant] SELECT subcategory, brand, expires_at FROM socialmedia.groups ORDER BY subcategory ASC;

[User] Tally up groups by expires_at.

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


[User] Display all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Show the results sorted by visibility ascending.

[Assistant] SELECT * FROM socialmedia.messages ORDER BY visibility ASC;

[User] Can you order these by visibility ascending?

[Assistant] SELECT * FROM socialmedia.messages ORDER BY visibility ASC;


[User] Retrieve all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] List messages with dates from last week.

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

[User] Can you order these by tags ascending?

[Assistant] SELECT * FROM socialmedia.messages WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY tags ASC;


[User] Show me all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Sort the results by display_name descending.

[Assistant] SELECT * FROM socialmedia.users ORDER BY display_name DESC;

[User] Restrict the output to 5 items.

[Assistant] SELECT * FROM socialmedia.users ORDER BY display_name DESC LIMIT 5;


[User] Retrieve name, featured_rank, subcategory for every group.

[Assistant] SELECT name, featured_rank, subcategory FROM socialmedia.groups;

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

[Assistant] SELECT name, featured_rank, subcategory FROM socialmedia.groups WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

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

[Assistant] SELECT name, featured_rank, subcategory FROM socialmedia.groups WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY barcode DESC;


[User] Get all groups.

[Assistant] SELECT * FROM socialmedia.groups;

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

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

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

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


[User] List all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Order the output by expires_at ascending.

[Assistant] SELECT * FROM socialmedia.groups ORDER BY expires_at ASC;

[User] Show me sum of barcode grouped by brand for groups.

[Assistant] SELECT brand, SUM(barcode) AS sum_barcode FROM socialmedia.groups GROUP BY brand;


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.assets (
  sku varchar PRIMARY KEY -- unique identifier,
  expires_at timestamp,
  published_at timestamp,
  reserved character varying(64),
  brand character varying(256),
  popularity_score character varying(256),
  backorder character varying(128),
  video_url text -- identifier for video_url,
  stock_level character varying(128)
)

CREATE TABLE tradingplatform.metadata (
  id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  email char,
  account_status character varying(128),
  country char NOT NULL,
  profile_picture_url text NOT NULL
)

CREATE TABLE tradingplatform.users (
  id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  profile_picture_url character varying(128),
  address character varying(256),
  country char,
  language char,
  asset_id text NOT NULL -- reference to assets.sku,
  FOREIGN KEY (asset_id) REFERENCES assets(sku)
)

CREATE TABLE tradingplatform.logs (
  location_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  updated_at timestamp without time zone,
  name char,
  category varchar,
  location_lat char,
  parking_available character varying(128),
  metadat_id text -- reference to metadata.id,
  asset_id text -- reference to assets.sku,
  FOREIGN KEY (metadat_id) REFERENCES metadata(id),
  FOREIGN KEY (asset_id) REFERENCES assets(sku)
)

[User] What are the id, created_at, profile_picture_url of each user?

[Assistant] SELECT id, created_at, profile_picture_url FROM tradingplatform.users;

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

[Assistant] SELECT id, created_at, profile_picture_url FROM tradingplatform.users WHERE language LIKE 'A%';

[User] Tally up users by language.

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


[User] List asset_id, created_at, category from logs.

[Assistant] SELECT asset_id, created_at, category FROM tradingplatform.logs;

[User] Find logs created yesterday.

[Assistant] SELECT asset_id, created_at, category FROM tradingplatform.logs WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Tally up logs by category.

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


[User] Get metadat_id, location_id, parking_available from all logs.

[Assistant] SELECT metadat_id, location_id, parking_available FROM tradingplatform.logs;

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

[Assistant] SELECT metadat_id, location_id, parking_available FROM tradingplatform.logs ORDER BY category ASC;

[User] Limit the results to 10 rows.

[Assistant] SELECT metadat_id, location_id, parking_available FROM tradingplatform.logs ORDER BY category ASC LIMIT 10;


[User] Retrieve location_id, location_lat, name for every log.

[Assistant] SELECT location_id, location_lat, name FROM tradingplatform.logs;

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

[Assistant] SELECT location_id, location_lat, name FROM tradingplatform.logs ORDER BY parking_available ASC;

[User] Show me the count of logs grouped by asset_id.

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


[User] Show me all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Show the results sorted by location_id descending.

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

[User] Show me the count of logs grouped by parking_available.

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


[User] Retrieve parking_available, location_id, name for every log.

[Assistant] SELECT parking_available, location_id, name FROM tradingplatform.logs;

[User] Order the output by category descending.

[Assistant] SELECT parking_available, location_id, name FROM tradingplatform.logs ORDER BY category DESC;

[User] Order the output by category ascending.

[Assistant] SELECT parking_available, location_id, name FROM tradingplatform.logs ORDER BY category ASC;


[User] Display all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] Show me created_at, asset_id, stock_level, video_url from users and their related assets.

[Assistant] SELECT *, assets.stock_level, assets.video_url FROM tradingplatform.users JOIN tradingplatform.assets ON users.asset_id = assets.sku;

[User] Get min of asset_id by language from users.

[Assistant] SELECT language, MIN(asset_id) AS min_asset_id FROM tradingplatform.users GROUP BY language;


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 (
  account_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  payer_id character varying(128) NOT NULL -- identifier for payer,
  credit character varying(256),
  payee_id varchar -- identifier for payee,
  balance decimal,
  approval_status varchar,
  category character varying(256),
  verification_status character varying(64) NOT NULL,
  payment_id text NOT NULL -- reference to payments.payment_id,
  FOREIGN KEY (payment_id) REFERENCES payments(payment_id)
)

CREATE TABLE finance.investments (
  content_id integer PRIMARY KEY -- unique identifier,
  edited_at date,
  content varchar,
  media_url varchar,
  author_id char -- identifier for author,
  account_id text NOT NULL -- reference to accounts.account_id,
  FOREIGN KEY (account_id) REFERENCES accounts(account_id)
)

CREATE TABLE finance.payments (
  payment_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  delivery_status varchar,
  approval_status text,
  buyer_id character varying(64),
  seller_id varchar,
  quantity character varying(128),
  tax numeric(38,14),
  investment_id integer -- reference to investments.content_id,
  FOREIGN KEY (investment_id) REFERENCES investments(content_id)
)

[User] What are the investment_id, buyer_id, seller_id of each payment?

[Assistant] SELECT investment_id, buyer_id, seller_id FROM finance.payments;

[User] Sort the results by tax ascending.

[Assistant] SELECT investment_id, buyer_id, seller_id FROM finance.payments ORDER BY tax ASC;

[User] Restrict the output to 50 items.

[Assistant] SELECT investment_id, buyer_id, seller_id FROM finance.payments ORDER BY tax ASC LIMIT 50;


[User] List approval_status, payer_id, payee_id from accounts.

[Assistant] SELECT approval_status, payer_id, payee_id FROM finance.accounts;

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

[Assistant] SELECT approval_status, payer_id, payee_id FROM finance.accounts ORDER BY balance DESC;

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

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


[User] Show me verification_status, balance, created_at for all accounts.

[Assistant] SELECT verification_status, balance, created_at FROM finance.accounts;

[User] Get all accounts older than 6 months.

[Assistant] SELECT verification_status, balance, created_at FROM finance.accounts WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Get max of payee_id by verification_status from accounts.

[Assistant] SELECT verification_status, MAX(payee_id) AS max_payee_id FROM finance.accounts GROUP BY verification_status;


[User] Display all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Show me payment_id, balance, investment_id, approval_status from accounts and their related payments.

[Assistant] SELECT *, payments.investment_id, payments.approval_status FROM finance.accounts JOIN finance.payments ON accounts.payment_id = payments.payment_id;

[User] Show me average of verification_status grouped by payer_id for accounts.

[Assistant] SELECT payer_id, AVERAGE(verification_status) AS average_verification_status FROM finance.accounts GROUP BY payer_id;


[User] Retrieve approval_status, balance, payee_id for every account.

[Assistant] SELECT approval_status, balance, payee_id FROM finance.accounts;

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

[Assistant] SELECT approval_status, balance, payee_id FROM finance.accounts WHERE payment_id LIKE 'A%';

[User] Restrict the output to 10 items.

[Assistant] SELECT approval_status, balance, payee_id FROM finance.accounts WHERE payment_id LIKE 'A%' LIMIT 10;


[User] Retrieve all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Order the output by payee_id ascending.

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

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

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


[User] Retrieve all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Retrieve investments where author_id LIKE 'A%'.

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

[User] Calculate count of content for each account_id in investments.

[Assistant] SELECT account_id, COUNT(content) AS count_content FROM finance.investments GROUP BY account_id;


[User] Retrieve content, edited_at, account_id for every investment.

[Assistant] SELECT content, edited_at, account_id FROM finance.investments;

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

[Assistant] SELECT content, edited_at, account_id FROM finance.investments WHERE media_url LIKE 'A%';

[User] Return just 100 rows.

[Assistant] SELECT content, edited_at, account_id FROM finance.investments WHERE media_url LIKE 'A%' LIMIT 100;


[User] Show me all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Can you order these by approval_status ascending?

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

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.trades (
  invoice_id integer PRIMARY KEY -- unique identifier,
  traded_at date,
  payment_method character varying(64),
  user_id character varying(256),
  approval_status character varying(128),
  delivery_status character varying(256),
  quantity character varying(64) NOT NULL,
  wallet_id text -- reference to wallets.id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(id)
)

CREATE TABLE tradingplatform.orders (
  order_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  completed_at date,
  payment_status character varying(64),
  amount integer,
  card_type character varying(128),
  quantity character varying(128),
  buyer_id character varying(256),
  currency text,
  wallet_id text NOT NULL -- reference to wallets.id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(id)
)

CREATE TABLE tradingplatform.wallets (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  updated_at timestamp,
  invoice_number varchar,
  approval_status char,
  debit character varying(256),
  verification_status character varying(256),
  payer_id character varying(64) -- identifier for payer,
  trade_id integer -- reference to trades.invoice_id,
  FOREIGN KEY (trade_id) REFERENCES trades(invoice_id)
)

[User] Get all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

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

[User] Sort the results by amount descending.

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


[User] Get all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] List wallets that have trade_id > 53.

[Assistant] SELECT * FROM tradingplatform.wallets WHERE trade_id > 53;

[User] Show only 10 records.

[Assistant] SELECT * FROM tradingplatform.wallets WHERE trade_id > 53 LIMIT 10;


[User] Display all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Sort the results by currency descending.

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

[User] What is the sum wallet_id for each created_at in orders?

[Assistant] SELECT created_at, SUM(wallet_id) AS sum_wallet_id FROM tradingplatform.orders GROUP BY created_at;


[User] Show me all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

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

[Assistant] SELECT * FROM tradingplatform.trades WHERE traded_at > '2023-01-01';

[User] Calculate average of quantity for each wallet_id in trades.

[Assistant] SELECT wallet_id, AVERAGE(quantity) AS average_quantity FROM tradingplatform.trades GROUP BY wallet_id;


[User] Show me buyer_id, payment_status, created_at for all orders.

[Assistant] SELECT buyer_id, payment_status, created_at FROM tradingplatform.orders;

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

[Assistant] SELECT buyer_id, payment_status, created_at FROM tradingplatform.orders WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Limit the results to 50 rows.

[Assistant] SELECT buyer_id, payment_status, created_at FROM tradingplatform.orders WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 50;


[User] Retrieve all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

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

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

[User] Sort the results by delivery_status descending.

[Assistant] SELECT * FROM tradingplatform.trades WHERE quantity LIKE 'A%' ORDER BY delivery_status DESC;


[User] Show me all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

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

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

[User] Return just 50 rows.

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


[User] List all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Retrieve wallets where payer_id LIKE 'A%'.

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

[User] Get max of invoice_number by created_at from wallets.

[Assistant] SELECT created_at, MAX(invoice_number) AS max_invoice_number FROM tradingplatform.wallets GROUP BY created_at;


[User] Get delivery_status, approval_status, quantity from all trades.

[Assistant] SELECT delivery_status, approval_status, quantity FROM tradingplatform.trades;

[User] List trades with dates from last week.

[Assistant] SELECT delivery_status, approval_status, quantity FROM tradingplatform.trades WHERE traded_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Sort the results by delivery_status descending.

[Assistant] SELECT delivery_status, approval_status, quantity FROM tradingplatform.trades WHERE traded_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY delivery_status DESC;


[User] Show me user_id, delivery_status, payment_method for all trades.

[Assistant] SELECT user_id, delivery_status, payment_method FROM tradingplatform.trades;

[User] List trades with dates created yesterday.

[Assistant] SELECT user_id, delivery_status, payment_method FROM tradingplatform.trades WHERE traded_at = CURRENT_DATE - INTERVAL '1 day';

[User] Order the output by quantity descending.

[Assistant] SELECT user_id, delivery_status, payment_method FROM tradingplatform.trades WHERE traded_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY quantity 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 (
  id varchar PRIMARY KEY -- unique identifier,
  due_date timestamp without time zone,
  payment_date timestamp,
  debit text NOT NULL,
  approval_status text,
  user_id character varying(256) NOT NULL -- identifier for user,
  currency varchar,
  verification_status character varying(64),
  credit character varying(64),
  exchange_rate varchar,
  customer_id integer -- reference to customers.id,
  FOREIGN KEY (customer_id) REFERENCES customers(id)
)

CREATE TABLE finance.customers (
  id integer PRIMARY KEY -- unique identifier,
  last_active timestamp,
  username character varying(64),
  nationality varchar,
  profile_picture_url character varying(64),
  last_name character varying(128)
)

[User] What are the currency, approval_status, customer_id of each account?

[Assistant] SELECT currency, approval_status, customer_id FROM finance.accounts;

[User] Find accounts from 2023.

[Assistant] SELECT currency, approval_status, customer_id FROM finance.accounts WHERE payment_date BETWEEN '2023-01-01' AND '2023-12-31';

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

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


[User] List verification_status, user_id, credit from accounts.

[Assistant] SELECT verification_status, user_id, credit FROM finance.accounts;

[User] List approval_status, currency, profile_picture_url, last_active for each account along with their customer information.

[Assistant] SELECT verification_status, user_id, credit, customers.profile_picture_url, customers.last_active FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.id;

[User] Can you order these by currency descending?

[Assistant] SELECT verification_status, user_id, credit, customers.profile_picture_url, customers.last_active FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.id ORDER BY currency DESC;


[User] Show me all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Show me exchange_rate, currency, profile_picture_url, username from accounts and their related customers.

[Assistant] SELECT *, customers.profile_picture_url, customers.username FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.id;

[User] Show me max of user_id grouped by customer_id for accounts.

[Assistant] SELECT customer_id, MAX(user_id) AS max_user_id FROM finance.accounts GROUP BY customer_id;


[User] What are the payment_date, credit, debit of each account?

[Assistant] SELECT payment_date, credit, debit FROM finance.accounts;

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

[Assistant] SELECT payment_date, credit, debit FROM finance.accounts WHERE verification_status LIKE 'A%';

[User] Group accounts by credit and show the sum of customer_id.

[Assistant] SELECT credit, SUM(customer_id) AS sum_customer_id FROM finance.accounts GROUP BY credit;


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

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

[User] Sort the results by verification_status ascending.

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

[User] Group accounts by credit and show the count of payment_date.

[Assistant] SELECT credit, COUNT(payment_date) AS count_payment_date FROM finance.accounts GROUP BY credit;


[User] List all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

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

[User] Return just 5 rows.

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


[User] Get all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Find accounts where currency LIKE 'A%'.

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

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

[Assistant] SELECT * FROM finance.accounts WHERE currency LIKE 'A%' ORDER BY user_id DESC;


[User] What are the credit, user_id, verification_status of each account?

[Assistant] SELECT credit, user_id, verification_status FROM finance.accounts;

[User] Show the results sorted by exchange_rate ascending.

[Assistant] SELECT credit, user_id, verification_status FROM finance.accounts ORDER BY exchange_rate ASC;

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

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


[User] Show me all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Find accounts older than 6 months.

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

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

[Assistant] SELECT * FROM finance.accounts WHERE payment_date <= CURRENT_DATE - INTERVAL '6 months' ORDER BY due_date ASC;


[User] Get user_id, credit, due_date from all accounts.

[Assistant] SELECT user_id, credit, due_date FROM finance.accounts;

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

[Assistant] SELECT user_id, credit, due_date FROM finance.accounts WHERE due_date > '2023-12-01';

[User] Only show the top 15 results.

[Assistant] SELECT user_id, credit, due_date FROM finance.accounts WHERE due_date > '2023-12-01' LIMIT 15;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.accounts (
  id text PRIMARY KEY -- unique identifier,
  payment_date timestamp,
  created_at timestamp,
  payer_id character varying(128) -- identifier for payer,
  invoice_number text NOT NULL,
  vendor_id varchar -- identifier for vendor,
  status varchar,
  balance numeric NOT NULL,
  user_id text -- identifier for user
)

CREATE TABLE finance.customers (
  employee_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  status varchar,
  display_name varchar,
  website character varying(128),
  account_id text -- reference to accounts.id,
  FOREIGN KEY (account_id) REFERENCES accounts(id)
)

[User] Get all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

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

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


[User] List employee_id, display_name, status from customers.

[Assistant] SELECT employee_id, display_name, status FROM finance.customers;

[User] Find customers modified within the last hour.

[Assistant] SELECT employee_id, display_name, status FROM finance.customers WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] How many customers are there per employee_id?

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


[User] List all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Retrieve status, display_name, balance, created_at showing the relationship between customers and accounts.

[Assistant] SELECT *, accounts.balance, accounts.created_at FROM finance.customers JOIN finance.accounts ON customers.account_id = accounts.id;

[User] Get average of website by employee_id from customers.

[Assistant] SELECT employee_id, AVERAGE(website) AS average_website FROM finance.customers GROUP BY employee_id;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Get min of account_id by website from customers.

[Assistant] SELECT website, MIN(account_id) AS min_account_id FROM finance.customers GROUP BY website;


[User] Retrieve all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Find customers between January and March.

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

[User] Get sum of website by created_at from customers.

[Assistant] SELECT created_at, SUM(website) AS sum_website FROM finance.customers GROUP BY created_at;


[User] Retrieve all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] What is the count created_at for each account_id in customers?

[Assistant] SELECT account_id, COUNT(created_at) AS count_created_at FROM finance.customers GROUP BY account_id;


[User] Retrieve employee_id, account_id, website for every customer.

[Assistant] SELECT employee_id, account_id, website FROM finance.customers;

[User] Retrieve created_at, website, payment_date, balance showing the relationship between customers and accounts.

[Assistant] SELECT employee_id, account_id, website, accounts.payment_date, accounts.balance FROM finance.customers JOIN finance.accounts ON customers.account_id = accounts.id;

[User] How many customers are there per status?

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


[User] Show me created_at, account_id, status for all customers.

[Assistant] SELECT created_at, account_id, status FROM finance.customers;

[User] Can you order these by website ascending?

[Assistant] SELECT created_at, account_id, status FROM finance.customers ORDER BY website ASC;

[User] Show me average of created_at grouped by display_name for customers.

[Assistant] SELECT display_name, AVERAGE(created_at) AS average_created_at FROM finance.customers GROUP BY display_name;


[User] List all customers.

[Assistant] SELECT * FROM finance.customers;

[User] List account_id, created_at, created_at, status for each customer along with their account information.

[Assistant] SELECT *, accounts.created_at, accounts.status FROM finance.customers JOIN finance.accounts ON customers.account_id = accounts.id;

[User] Get the distribution of customers across different status values.

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


[User] Retrieve all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Show the results sorted by website ascending.

[Assistant] SELECT * FROM finance.customers WHERE created_at > '2023-12-01' ORDER BY website 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.prescriptions (
  id integer PRIMARY KEY -- unique identifier,
  joined_at date,
  last_active timestamp,
  birth_date timestamp,
  password_hash character varying(128) NOT NULL,
  country char NOT NULL,
  website character varying(256),
  gender character varying(256),
  appointment_id text NOT NULL -- reference to appointments.id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(id)
)

CREATE TABLE healthcare.billing (
  id text PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  created_at date,
  last_name char,
  nationality character varying(256),
  email character varying(64) NOT NULL,
  timezone varchar,
  membership_level character varying(256),
  profile_picture_url character varying(128),
  is_verified boolean NOT NULL -- indicates if verified is true
)

CREATE TABLE healthcare.appointments (
  id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  cancelled_at date,
  user_id character varying(256) -- identifier for user,
  card_type character varying(128),
  discount smallint NOT NULL,
  currency character varying(64),
  payment_method varchar NOT NULL,
  prescription_id integer -- reference to prescriptions.id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(id)
)

[User] Retrieve all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Order the output by currency descending.

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

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM healthcare.appointments ORDER BY currency DESC LIMIT 10;


[User] List discount, cancelled_at, currency from appointments.

[Assistant] SELECT discount, cancelled_at, currency FROM healthcare.appointments;

[User] Find appointments created yesterday.

[Assistant] SELECT discount, cancelled_at, currency FROM healthcare.appointments WHERE processed_at = CURRENT_DATE - INTERVAL '1 day';

[User] What is the count card_type for each processed_at in appointments?

[Assistant] SELECT processed_at, COUNT(card_type) AS count_card_type FROM healthcare.appointments GROUP BY processed_at;


[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Order the output by card_type descending.

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

[User] Limit the results to 15 rows.

[Assistant] SELECT * FROM healthcare.appointments ORDER BY card_type DESC LIMIT 15;


[User] Get all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Show me joined_at, last_active, cancelled_at, card_type from prescriptions and their related appointments.

[Assistant] SELECT *, appointments.cancelled_at, appointments.card_type FROM healthcare.prescriptions JOIN healthcare.appointments ON prescriptions.appointment_id = appointments.id;

[User] Show me sum of appointment_id grouped by appointment_id for prescriptions.

[Assistant] SELECT appointment_id, SUM(appointment_id) AS sum_appointment_id FROM healthcare.prescriptions GROUP BY appointment_id;


[User] Get all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Retrieve appointments where prescription_id > 57.

[Assistant] SELECT * FROM healthcare.appointments WHERE prescription_id > 57;

[User] Get min of user_id by cancelled_at from appointments.

[Assistant] SELECT cancelled_at, MIN(user_id) AS min_user_id FROM healthcare.appointments GROUP BY cancelled_at;


[User] Retrieve card_type, discount, currency for every appointment.

[Assistant] SELECT card_type, discount, currency FROM healthcare.appointments;

[User] List appointments that have prescription_id > 93.

[Assistant] SELECT card_type, discount, currency FROM healthcare.appointments WHERE prescription_id > 93;

[User] Only show the top 100 results.

[Assistant] SELECT card_type, discount, currency FROM healthcare.appointments WHERE prescription_id > 93 LIMIT 100;


[User] List processed_at, discount, card_type from appointments.

[Assistant] SELECT processed_at, discount, card_type FROM healthcare.appointments;

[User] List appointments that have discount > 41.

[Assistant] SELECT processed_at, discount, card_type FROM healthcare.appointments WHERE discount > 41;

[User] Order the output by cancelled_at descending.

[Assistant] SELECT processed_at, discount, card_type FROM healthcare.appointments WHERE discount > 41 ORDER BY cancelled_at DESC;


[User] Display all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Show me birth_date, gender, discount, currency from prescriptions and their related appointments.

[Assistant] SELECT *, appointments.discount, appointments.currency FROM healthcare.prescriptions JOIN healthcare.appointments ON prescriptions.appointment_id = appointments.id;

[User] Return just 5 rows.

[Assistant] SELECT *, appointments.discount, appointments.currency FROM healthcare.prescriptions JOIN healthcare.appointments ON prescriptions.appointment_id = appointments.id LIMIT 5;


[User] Retrieve discount, currency, card_type for every appointment.

[Assistant] SELECT discount, currency, card_type FROM healthcare.appointments;

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

[Assistant] SELECT discount, currency, card_type FROM healthcare.appointments WHERE cancelled_at > '2023-01-01';

[User] How many appointments are there per cancelled_at?

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE humanresources.messages (
  content_id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  published_at date,
  visibility char,
  format varchar,
  keywords char,
  user_id character varying(128) -- identifier for user,
  reply_to_id character varying(128) -- identifier for reply_to,
  views char,
  catalo_id text -- reference to catalog.item_id,
  FOREIGN KEY (catalo_id) REFERENCES catalog(item_id)
)

CREATE TABLE humanresources.catalog (
  item_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  thumbnail_url varchar NOT NULL,
  image_url varchar,
  media_url character varying(256),
  currency char
)

CREATE TABLE humanresources.finances (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  customer_id character varying(64),
  verification_status character varying(64),
  invoice_number char,
  payer_id character varying(64),
  user_id varchar -- identifier for user,
  vendor_id character varying(128) NOT NULL -- identifier for vendor,
  catalo_id text NOT NULL -- reference to catalog.item_id,
  message_id integer NOT NULL -- reference to messages.content_id,
  FOREIGN KEY (catalo_id) REFERENCES catalog(item_id),
  FOREIGN KEY (message_id) REFERENCES messages(content_id)
)

[User] Get all finances.

[Assistant] SELECT * FROM humanresources.finances;

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

[Assistant] SELECT * FROM humanresources.finances WHERE user_id LIKE 'A%';

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

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


[User] List all messages.

[Assistant] SELECT * FROM humanresources.messages;

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

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

[User] Limit the results to 25 rows.

[Assistant] SELECT * FROM humanresources.messages WHERE published_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 25;


[User] Get visibility, published_at, catalo_id from all messages.

[Assistant] SELECT visibility, published_at, catalo_id FROM humanresources.messages;

[User] Show the results sorted by views descending.

[Assistant] SELECT visibility, published_at, catalo_id FROM humanresources.messages ORDER BY views DESC;

[User] How many messages are there per published_at?

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


[User] Get catalo_id, user_id, customer_id from all finances.

[Assistant] SELECT catalo_id, user_id, customer_id FROM humanresources.finances;

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

[Assistant] SELECT catalo_id, user_id, customer_id FROM humanresources.finances WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Restrict the output to 20 items.

[Assistant] SELECT catalo_id, user_id, customer_id FROM humanresources.finances WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 20;


[User] Retrieve all messages.

[Assistant] SELECT * FROM humanresources.messages;

[User] Show the results sorted by published_at ascending.

[Assistant] SELECT * FROM humanresources.messages ORDER BY published_at ASC;

[User] Show only 15 records.

[Assistant] SELECT * FROM humanresources.messages ORDER BY published_at ASC LIMIT 15;


[User] Retrieve all messages.

[Assistant] SELECT * FROM humanresources.messages;

[User] Retrieve views, visibility, created_at, image_url showing the relationship between messages and catalog.

[Assistant] SELECT *, catalog.created_at, catalog.image_url FROM humanresources.messages JOIN humanresources.catalog ON messages.catalo_id = catalog.item_id;

[User] Calculate max of edited_at for each catalo_id in messages.

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


[User] List catalo_id, published_at, reply_to_id from messages.

[Assistant] SELECT catalo_id, published_at, reply_to_id FROM humanresources.messages;

[User] Get all messages created yesterday.

[Assistant] SELECT catalo_id, published_at, reply_to_id FROM humanresources.messages WHERE published_at = CURRENT_DATE - INTERVAL '1 day';

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

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


[User] Show me all messages.

[Assistant] SELECT * FROM humanresources.messages;

[User] Find messages where catalo_id LIKE 'A%'.

[Assistant] SELECT * FROM humanresources.messages WHERE catalo_id LIKE 'A%';

[User] Show me the count of messages grouped by user_id.

[Assistant] SELECT user_id, COUNT(*) AS count FROM humanresources.messages 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 education.enrollments (
  address_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  operating_hours character varying(128),
  geo_point char NOT NULL,
  accessibility char NOT NULL,
  address_line2 character varying(128),
  grade_id text NOT NULL -- reference to grades.payment_id,
  FOREIGN KEY (grade_id) REFERENCES grades(payment_id)
)

CREATE TABLE education.grades (
  payment_id text PRIMARY KEY -- unique identifier,
  traded_at timestamp,
  card_type character varying(64),
  buyer_id varchar -- identifier for buyer,
  payment_method varchar NOT NULL,
  payment_status character varying(128)
)

[User] Get all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Get geo_point, created_at, buyer_id, payment_status by joining enrollments with grades.

[Assistant] SELECT *, grades.buyer_id, grades.payment_status FROM education.enrollments JOIN education.grades ON enrollments.grade_id = grades.payment_id;

[User] Calculate min of address_line2 for each address_line2 in enrollments.

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


[User] Get all enrollments.

[Assistant] SELECT * FROM education.enrollments;

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

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

[User] How many enrollments are there per address_id?

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


[User] Get address_id, address_line2, grade_id from all enrollments.

[Assistant] SELECT address_id, address_line2, grade_id FROM education.enrollments;

[User] Retrieve enrollments where geo_point LIKE 'A%'.

[Assistant] SELECT address_id, address_line2, grade_id FROM education.enrollments WHERE geo_point LIKE 'A%';

[User] Sort the results by accessibility ascending.

[Assistant] SELECT address_id, address_line2, grade_id FROM education.enrollments WHERE geo_point LIKE 'A%' ORDER BY accessibility ASC;


[User] List address_line2, address_id, accessibility from enrollments.

[Assistant] SELECT address_line2, address_id, accessibility FROM education.enrollments;

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

[Assistant] SELECT address_line2, address_id, accessibility FROM education.enrollments WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Show me count of operating_hours grouped by accessibility for enrollments.

[Assistant] SELECT accessibility, COUNT(operating_hours) AS count_operating_hours FROM education.enrollments GROUP BY accessibility;


[User] Get all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Retrieve enrollments where geo_point LIKE 'A%'.

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

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

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


[User] Get grade_id, address_line2, created_at from all enrollments.

[Assistant] SELECT grade_id, address_line2, created_at FROM education.enrollments;

[User] Get all enrollments between January and March.

[Assistant] SELECT grade_id, address_line2, created_at FROM education.enrollments WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

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

[Assistant] SELECT operating_hours, MIN(address_line2) AS min_address_line2 FROM education.enrollments GROUP BY operating_hours;


[User] Display all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Find enrollments older than 6 months.

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

[User] Only show the top 5 results.

[Assistant] SELECT * FROM education.enrollments WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 5;


[User] List operating_hours, address_line2, geo_point from enrollments.

[Assistant] SELECT operating_hours, address_line2, geo_point FROM education.enrollments;

[User] List enrollments with dates created yesterday.

[Assistant] SELECT operating_hours, address_line2, geo_point FROM education.enrollments WHERE created_at = CURRENT_DATE - INTERVAL '1 day';

[User] Group enrollments by geo_point and show the sum of operating_hours.

[Assistant] SELECT geo_point, SUM(operating_hours) AS sum_operating_hours FROM education.enrollments GROUP BY geo_point;


[User] List operating_hours, address_line2, grade_id from enrollments.

[Assistant] SELECT operating_hours, address_line2, grade_id FROM education.enrollments;

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

[Assistant] SELECT operating_hours, address_line2, grade_id FROM education.enrollments WHERE address_id LIKE 'A%';

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

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


[User] Retrieve all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] What geo_point, created_at, traded_at, payment_status do we have for enrollments and their associated grades?

[Assistant] SELECT *, grades.traded_at, grades.payment_status FROM education.enrollments JOIN education.grades ON enrollments.grade_id = grades.payment_id;

[User] Only show the top 20 results.

[Assistant] SELECT *, grades.traded_at, grades.payment_status FROM education.enrollments JOIN education.grades ON enrollments.grade_id = grades.payment_id 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.courses (
  venue_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  last_inspected date,
  capacity char,
  location_lat text,
  type char,
  geo_point varchar NOT NULL,
  category varchar,
  enrollment_id text NOT NULL -- reference to enrollments.person_id,
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(person_id)
)

CREATE TABLE education.departments (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  coordinates char,
  name character varying(256),
  timezone character varying(64),
  longitude character varying(64) NOT NULL,
  parking_available character varying(128),
  operating_hours char NOT NULL,
  location_lon character varying(64),
  assignment_id text NOT NULL -- reference to assignments.id,
  enrollment_id text -- reference to enrollments.person_id,
  FOREIGN KEY (assignment_id) REFERENCES assignments(id),
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(person_id)
)

CREATE TABLE education.assignments (
  id text PRIMARY KEY -- unique identifier,
  created_at date,
  type text NOT NULL,
  latitude character varying(128),
  category character varying(256)
)

CREATE TABLE education.enrollments (
  person_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  website character varying(64),
  is_active bit,
  state varchar NOT NULL,
  city varchar
)

[User] Retrieve last_inspected, venue_id, geo_point for every course.

[Assistant] SELECT last_inspected, venue_id, geo_point FROM education.courses;

[User] Can you order these by venue_id descending?

[Assistant] SELECT last_inspected, venue_id, geo_point FROM education.courses ORDER BY venue_id DESC;

[User] Calculate average of location_lat for each category in courses.

[Assistant] SELECT category, AVERAGE(location_lat) AS average_location_lat FROM education.courses GROUP BY category;


[User] Retrieve all courses.

[Assistant] SELECT * FROM education.courses;

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

[Assistant] SELECT * FROM education.courses ORDER BY geo_point DESC;

[User] Restrict the output to 50 items.

[Assistant] SELECT * FROM education.courses ORDER BY geo_point DESC LIMIT 50;


[User] List all courses.

[Assistant] SELECT * FROM education.courses;

[User] Find courses from 2023.

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

[User] Tally up courses by venue_id.

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


[User] Retrieve all courses.

[Assistant] SELECT * FROM education.courses;

[User] Order the output by last_inspected descending.

[Assistant] SELECT * FROM education.courses ORDER BY last_inspected DESC;

[User] Can you order these by location_lat descending?

[Assistant] SELECT * FROM education.courses ORDER BY location_lat DESC;


[User] List all departments.

[Assistant] SELECT * FROM education.departments;

[User] Find departments where name LIKE 'A%'.

[Assistant] SELECT * FROM education.departments WHERE name LIKE 'A%';

[User] Calculate min of location_lon for each updated_at in departments.

[Assistant] SELECT updated_at, MIN(location_lon) AS min_location_lon FROM education.departments GROUP BY updated_at;


[User] Retrieve last_inspected, type, updated_at for every course.

[Assistant] SELECT last_inspected, type, updated_at FROM education.courses;

[User] Get all courses created yesterday.

[Assistant] SELECT last_inspected, type, updated_at FROM education.courses WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Tally up courses by updated_at.

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


[User] Show me all courses.

[Assistant] SELECT * FROM education.courses;

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

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

[User] Calculate max of capacity for each venue_id in courses.

[Assistant] SELECT venue_id, MAX(capacity) AS max_capacity FROM education.courses GROUP BY venue_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.transactions (
  id varchar PRIMARY KEY -- unique identifier,
  completed_at date,
  payment_method text,
  quantity character varying(256),
  payment_id text NOT NULL -- reference to payments.payment_id,
  FOREIGN KEY (payment_id) REFERENCES payments(payment_id)
)

CREATE TABLE finance.loans (
  venue_id character varying(64) NOT NULL -- unique identifier,
  last_inspected timestamp,
  accessibility char,
  latitude varchar,
  account_id text -- reference to accounts.invoice_id,
  FOREIGN KEY (account_id) REFERENCES accounts(invoice_id)
)

CREATE TABLE finance.payments (
  payment_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  updated_at timestamp without time zone,
  currency text,
  status character varying(256),
  user_id character varying(64) -- identifier for user,
  product_id character varying(256),
  transaction_id text NOT NULL -- reference to transactions.id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(id)
)

CREATE TABLE finance.accounts (
  invoice_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  payer_id character varying(128) -- identifier for payer,
  debit character varying(256) NOT NULL,
  customer_id character varying(256) NOT NULL,
  reconciliation_status varchar,
  notes character varying(128),
  transaction_id text -- reference to transactions.id,
  payment_id text -- reference to payments.payment_id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(id),
  FOREIGN KEY (payment_id) REFERENCES payments(payment_id)
)

[User] List all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Show the results sorted by payer_id descending.

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

[User] Order the output by updated_at ascending.

[Assistant] SELECT * FROM finance.accounts 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.messages (
  comment_id integer PRIMARY KEY -- unique identifier,
  published_at timestamp,
  tags character varying(64) NOT NULL,
  score character varying(256),
  author_id character varying(64) -- identifier for author,
  media_url character varying(256),
  shares character varying(128),
  post_id text -- reference to posts.comment_id,
  FOREIGN KEY (post_id) REFERENCES posts(comment_id)
)

CREATE TABLE socialmedia.posts (
  comment_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  subject character varying(64) NOT NULL,
  categories character varying(128) NOT NULL,
  description varchar
)

[User] List all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] What score, published_at, categories, updated_at do we have for messages and their associated posts?

[Assistant] SELECT *, posts.categories, posts.updated_at FROM socialmedia.messages JOIN socialmedia.posts ON messages.post_id = posts.comment_id;

[User] Get max of media_url by author_id from messages.

[Assistant] SELECT author_id, MAX(media_url) AS max_media_url FROM socialmedia.messages GROUP BY author_id;


[User] Get score, post_id, published_at from all messages.

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

[User] Find messages from last week.

[Assistant] SELECT score, post_id, published_at FROM socialmedia.messages WHERE published_at >= CURRENT_DATE - INTERVAL '7 days';

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

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


[User] Show me all messages.

[Assistant] SELECT * FROM socialmedia.messages;

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

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

[User] Sort the results by tags ascending.

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


[User] Retrieve all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Find messages older than 6 months.

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

[User] Calculate average of published_at for each author_id in messages.

[Assistant] SELECT author_id, AVERAGE(published_at) AS average_published_at FROM socialmedia.messages GROUP BY author_id;


[User] List post_id, shares, published_at from messages.

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

[User] Find messages modified within the last hour.

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

[User] Get the distribution of messages across different media_url values.

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