[User] What are the published_at, created_at, likes of each notification?

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

[User] What description, trade_id, payment_method, traded_at do we have for notifications and their associated trades?

[Assistant] SELECT published_at, created_at, likes, trades.payment_method, trades.traded_at FROM tradingplatform.notifications JOIN tradingplatform.trades ON notifications.trade_id = trades.id;

[User] Show me max of published_at grouped by trade_id for notifications.

[Assistant] SELECT trade_id, MAX(published_at) AS max_published_at FROM tradingplatform.notifications GROUP BY trade_id;


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

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

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

[User] List likes, description, visibility from notifications.

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

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

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

[User] Limit the results to 5 rows.

[Assistant] SELECT likes, description, visibility FROM tradingplatform.notifications WHERE likes 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 socialmedia.groups (
  venue_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  created_at date,
  location_lon varchar NOT NULL,
  postal_code char,
  geo_point varchar,
  type varchar,
  message_id text NOT NULL -- reference to messages.message_id,
  like_id text -- reference to likes.employee_id,
  FOREIGN KEY (message_id) REFERENCES messages(message_id),
  FOREIGN KEY (like_id) REFERENCES likes(employee_id)
)

CREATE TABLE socialmedia.likes (
  employee_id varchar PRIMARY KEY -- unique identifier,
  joined_at date,
  last_active timestamp without time zone,
  username varchar NOT NULL,
  zip_code character varying(128) NOT NULL,
  api_key text NOT NULL,
  bio char NOT NULL,
  timezone character varying(128),
  age character varying(64) NOT NULL
)

CREATE TABLE socialmedia.messages (
  message_id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp,
  attachment_url char NOT NULL,
  image_url character varying(256),
  description character varying(128)
)

[User] List updated_at, geo_point, postal_code from groups.

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

[User] Retrieve like_id, postal_code, attachment_url, image_url showing the relationship between groups and messages.

[Assistant] SELECT updated_at, geo_point, postal_code, messages.attachment_url, messages.image_url FROM socialmedia.groups JOIN socialmedia.messages ON groups.message_id = messages.message_id;

[User] Order the output by message_id ascending.

[Assistant] SELECT updated_at, geo_point, postal_code, messages.attachment_url, messages.image_url FROM socialmedia.groups JOIN socialmedia.messages ON groups.message_id = messages.message_id ORDER BY message_id ASC;


[User] List all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Find groups between January and March.

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

[User] Calculate count of location_lon for each updated_at in groups.

[Assistant] SELECT updated_at, COUNT(location_lon) AS count_location_lon FROM socialmedia.groups GROUP BY updated_at;


[User] Retrieve type, postal_code, message_id for every group.

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

[User] Sort the results by type ascending.

[Assistant] SELECT type, postal_code, message_id FROM socialmedia.groups ORDER BY type ASC;

[User] Show me min of postal_code grouped by message_id for groups.

[Assistant] SELECT message_id, MIN(postal_code) AS min_postal_code FROM socialmedia.groups GROUP BY message_id;


[User] List all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] List postal_code, geo_point, attachment_url, published_at for each group along with their message information.

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

[User] Only show the top 20 results.

[Assistant] SELECT *, messages.attachment_url, messages.published_at FROM socialmedia.groups JOIN socialmedia.messages ON groups.message_id = messages.message_id LIMIT 20;


[User] Retrieve all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Sort the results by like_id ascending.

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

[User] Return just 10 rows.

[Assistant] SELECT * FROM socialmedia.groups ORDER BY like_id ASC LIMIT 10;


[User] Get all groups.

[Assistant] SELECT * FROM socialmedia.groups;

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

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

[User] How many groups are there per updated_at?

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


[User] List updated_at, postal_code, created_at from groups.

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

[User] Can you order these by postal_code ascending?

[Assistant] SELECT updated_at, postal_code, created_at FROM socialmedia.groups ORDER BY postal_code ASC;

[User] Tally up groups by message_id.

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


[User] List type, like_id, location_lon from groups.

[Assistant] SELECT type, like_id, location_lon FROM socialmedia.groups;

[User] What like_id, venue_id, description, attachment_url do we have for groups and their associated messages?

[Assistant] SELECT type, like_id, location_lon, messages.description, messages.attachment_url FROM socialmedia.groups JOIN socialmedia.messages ON groups.message_id = messages.message_id;

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

[Assistant] SELECT postal_code, MAX(message_id) AS max_message_id FROM socialmedia.groups GROUP BY postal_code;


[User] What are the venue_id, like_id, updated_at of each group?

[Assistant] SELECT venue_id, like_id, updated_at FROM socialmedia.groups;

[User] What postal_code, created_at, image_url, attachment_url do we have for groups and their associated messages?

[Assistant] SELECT venue_id, like_id, updated_at, messages.image_url, messages.attachment_url FROM socialmedia.groups JOIN socialmedia.messages ON groups.message_id = messages.message_id;

[User] Can you order these by venue_id ascending?

[Assistant] SELECT venue_id, like_id, updated_at, messages.image_url, messages.attachment_url FROM socialmedia.groups JOIN socialmedia.messages ON groups.message_id = messages.message_id ORDER BY venue_id ASC;


[User] Retrieve all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Show the results sorted by created_at ascending.

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

[User] What is the max created_at for each type in groups?

[Assistant] SELECT type, MAX(created_at) AS max_created_at FROM socialmedia.groups GROUP BY type;


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 (
  id character varying(64) NOT NULL -- unique identifier,
  completed_at timestamp without time zone,
  created_at timestamp without time zone,
  tax integer,
  currency character varying(128),
  status text NOT NULL,
  amount decimal,
  trade_id text -- reference to trades.transaction_id,
  FOREIGN KEY (trade_id) REFERENCES trades(transaction_id)
)

CREATE TABLE tradingplatform.trades (
  transaction_id text PRIMARY KEY -- unique identifier,
  traded_at date,
  customer_id character varying(128),
  amount integer,
  quantity text,
  buyer_id character varying(256) NOT NULL -- identifier for buyer,
  delivery_status text NOT NULL
)

[User] Retrieve all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

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

[Assistant] SELECT * FROM tradingplatform.logs WHERE currency LIKE 'A%';

[User] Group logs by amount and show the max of amount.

[Assistant] SELECT amount, MAX(amount) AS max_amount FROM tradingplatform.logs GROUP BY amount;


[User] Show me all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Order the output by amount descending.

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

[User] Return just 100 rows.

[Assistant] SELECT * FROM tradingplatform.logs ORDER BY amount DESC LIMIT 100;


[User] Show me all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Get logs that match id LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.logs WHERE id LIKE 'A%';

[User] Limit the results to 15 rows.

[Assistant] SELECT * FROM tradingplatform.logs WHERE id LIKE 'A%' LIMIT 15;


[User] List id, amount, completed_at from logs.

[Assistant] SELECT id, amount, completed_at FROM tradingplatform.logs;

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

[Assistant] SELECT id, amount, completed_at FROM tradingplatform.logs WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Can you order these by tax ascending?

[Assistant] SELECT id, amount, completed_at FROM tradingplatform.logs WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY tax ASC;


[User] What are the completed_at, currency, amount of each log?

[Assistant] SELECT completed_at, currency, amount FROM tradingplatform.logs;

[User] Retrieve currency, created_at, delivery_status, customer_id showing the relationship between logs and trades.

[Assistant] SELECT completed_at, currency, amount, trades.delivery_status, trades.customer_id FROM tradingplatform.logs JOIN tradingplatform.trades ON logs.trade_id = trades.transaction_id;

[User] What is the min status for each tax in logs?

[Assistant] SELECT tax, MIN(status) AS min_status FROM tradingplatform.logs GROUP BY tax;


[User] Get status, tax, created_at from all logs.

[Assistant] SELECT status, tax, created_at FROM tradingplatform.logs;

[User] List logs that have trade_id LIKE 'A%'.

[Assistant] SELECT status, tax, created_at FROM tradingplatform.logs WHERE trade_id LIKE 'A%';

[User] Limit the results to 10 rows.

[Assistant] SELECT status, tax, created_at FROM tradingplatform.logs WHERE trade_id LIKE 'A%' LIMIT 10;


[User] Get all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

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

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

[User] Sort the results by tax descending.

[Assistant] SELECT * FROM tradingplatform.logs WHERE completed_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY tax DESC;


[User] List all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

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

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

[User] Get average of tax by status from logs.

[Assistant] SELECT status, AVERAGE(tax) AS average_tax FROM tradingplatform.logs GROUP BY status;


[User] Display all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

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

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

[User] Can you order these by created_at descending?

[Assistant] SELECT * FROM tradingplatform.logs WHERE completed_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY created_at DESC;


[User] Get all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

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

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

[User] Can you order these by status descending?

[Assistant] SELECT * FROM tradingplatform.logs WHERE completed_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY 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 healthcare.appointments (
  content_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  thumbnail character varying(256),
  message char,
  image_url character varying(256),
  title char NOT NULL
)

CREATE TABLE healthcare.patients (
  person_id character varying(64) NOT NULL -- unique identifier,
  last_active date,
  timezone character varying(64),
  nationality varchar,
  website char NOT NULL,
  username character varying(256)
)

CREATE TABLE healthcare.doctors (
  employee_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  last_name char NOT NULL,
  status character varying(256),
  nationality varchar NOT NULL
)

CREATE TABLE healthcare.billing (
  store_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  accessibility character varying(128) NOT NULL,
  category character varying(256),
  timezone character varying(128) NOT NULL,
  description character varying(64) NOT NULL,
  longitude text,
  appointment_id text -- reference to appointments.content_id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(content_id)
)

[User] List all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] Only show the top 25 results.

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


[User] What are the store_id, longitude, appointment_id of each billing?

[Assistant] SELECT store_id, longitude, appointment_id FROM healthcare.billing;

[User] What accessibility, description, image_url, message do we have for billing and their associated appointments?

[Assistant] SELECT store_id, longitude, appointment_id, appointments.image_url, appointments.message FROM healthcare.billing JOIN healthcare.appointments ON billing.appointment_id = appointments.content_id;

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

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


[User] What are the description, created_at, store_id of each billing?

[Assistant] SELECT description, created_at, store_id FROM healthcare.billing;

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

[Assistant] SELECT description, created_at, store_id FROM healthcare.billing WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] How many billing are there per accessibility?

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


[User] Retrieve created_at, appointment_id, description for every billing.

[Assistant] SELECT created_at, appointment_id, description FROM healthcare.billing;

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

[Assistant] SELECT created_at, appointment_id, description FROM healthcare.billing WHERE store_id LIKE 'A%';

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

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


[User] List all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Sort the results by category descending.

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

[User] Limit the results to 5 rows.

[Assistant] SELECT * FROM healthcare.billing ORDER BY category DESC LIMIT 5;


[User] Get all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Sort the results by store_id descending.

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

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

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


[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] What description, category, message, thumbnail do we have for billing and their associated appointments?

[Assistant] SELECT *, appointments.message, appointments.thumbnail FROM healthcare.billing JOIN healthcare.appointments ON billing.appointment_id = appointments.content_id;

[User] Return just 5 rows.

[Assistant] SELECT *, appointments.message, appointments.thumbnail FROM healthcare.billing JOIN healthcare.appointments ON billing.appointment_id = appointments.content_id LIMIT 5;


[User] What are the description, longitude, appointment_id of each billing?

[Assistant] SELECT description, longitude, appointment_id FROM healthcare.billing;

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

[Assistant] SELECT description, longitude, appointment_id FROM healthcare.billing WHERE longitude LIKE 'A%';

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

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


[User] Get all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Sort the results by accessibility ascending.

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

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

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


[User] Get store_id, accessibility, timezone from all billing.

[Assistant] SELECT store_id, accessibility, timezone FROM healthcare.billing;

[User] Show me billing with store_id LIKE 'A%'.

[Assistant] SELECT store_id, accessibility, timezone FROM healthcare.billing WHERE store_id LIKE 'A%';

[User] Group billing by accessibility and show the average of description.

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


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 (
  barcode integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  manufacturer character varying(64),
  price integer,
  discount numeric,
  user_id text NOT NULL -- reference to users.person_id,
  FOREIGN KEY (user_id) REFERENCES users(person_id)
)

CREATE TABLE tradingplatform.wallets (
  id character varying(64) NOT NULL -- unique identifier,
  payment_date date,
  processed_at timestamp without time zone,
  payer_id character varying(128) NOT NULL,
  vendor_id character varying(256) -- identifier for vendor,
  approval_status character varying(256),
  asset_id integer -- reference to assets.barcode,
  FOREIGN KEY (asset_id) REFERENCES assets(barcode)
)

CREATE TABLE tradingplatform.users (
  person_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  joined_at timestamp,
  username character varying(128),
  zip_code varchar,
  nationality char
)

[User] Get all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

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

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

[User] Tally up wallets by processed_at.

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


[User] Retrieve all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Order the output by user_id ascending.

[Assistant] SELECT * FROM tradingplatform.assets ORDER BY user_id ASC;

[User] How many assets are there per price?

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


[User] List all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Order the output by id ascending.

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

[User] Show only 100 records.

[Assistant] SELECT * FROM tradingplatform.wallets ORDER BY id ASC LIMIT 100;


[User] List user_id, created_at, manufacturer from assets.

[Assistant] SELECT user_id, created_at, manufacturer FROM tradingplatform.assets;

[User] Find assets where discount > 11.

[Assistant] SELECT user_id, created_at, manufacturer FROM tradingplatform.assets WHERE discount > 11;

[User] Return just 100 rows.

[Assistant] SELECT user_id, created_at, manufacturer FROM tradingplatform.assets WHERE discount > 11 LIMIT 100;


[User] Retrieve all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Show the results sorted by created_at descending.

[Assistant] SELECT * FROM tradingplatform.assets ORDER BY created_at DESC;

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

[Assistant] SELECT * FROM tradingplatform.assets ORDER BY manufacturer DESC;


[User] Display all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

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

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

[User] Limit the results to 50 rows.

[Assistant] SELECT * FROM tradingplatform.wallets WHERE payment_date >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 50;


[User] Retrieve all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

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

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

[User] Show only 10 records.

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


[User] Get all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Retrieve id, approval_status, price, created_at showing the relationship between wallets and assets.

[Assistant] SELECT *, assets.price, assets.created_at FROM tradingplatform.wallets JOIN tradingplatform.assets ON wallets.asset_id = assets.barcode;

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

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


[User] Display all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Sort the results by id ascending.

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

[User] Show me the count of wallets grouped by vendor_id.

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


[User] Get user_id, price, created_at from all assets.

[Assistant] SELECT user_id, price, created_at FROM tradingplatform.assets;

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

[Assistant] SELECT user_id, price, created_at FROM tradingplatform.assets ORDER BY user_id ASC;

[User] How many assets are there per manufacturer?

[Assistant] SELECT manufacturer, COUNT(*) AS count FROM tradingplatform.assets GROUP BY manufacturer 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.assets (
  id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  updated_at timestamp,
  subcategory character varying(256) NOT NULL,
  featured_rank char,
  image_url varchar,
  order_id integer -- reference to orders.invoice_id,
  FOREIGN KEY (order_id) REFERENCES orders(invoice_id)
)

CREATE TABLE tradingplatform.orders (
  invoice_id integer PRIMARY KEY -- unique identifier,
  completed_at date,
  status character varying(64) NOT NULL,
  payment_status character varying(64),
  quantity character varying(128) NOT NULL,
  seller_id character varying(256) -- identifier for seller,
  delivery_status character varying(256) NOT NULL,
  approval_status text,
  user_id text NOT NULL -- reference to users.person_id,
  FOREIGN KEY (user_id) REFERENCES users(person_id)
)

CREATE TABLE tradingplatform.users (
  person_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  password_hash char,
  profile_picture_url varchar,
  email character varying(64),
  birth_date timestamp,
  token text NOT NULL,
  language varchar,
  timezone varchar NOT NULL,
  order_id integer NOT NULL -- reference to orders.invoice_id,
  FOREIGN KEY (order_id) REFERENCES orders(invoice_id)
)

[User] List all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

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

[User] Return just 20 rows.

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY user_id DESC LIMIT 20;


[User] What are the payment_status, completed_at, user_id of each order?

[Assistant] SELECT payment_status, completed_at, user_id FROM tradingplatform.orders;

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

[Assistant] SELECT payment_status, completed_at, user_id FROM tradingplatform.orders WHERE completed_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Show the results sorted by seller_id descending.

[Assistant] SELECT payment_status, completed_at, user_id FROM tradingplatform.orders WHERE completed_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY seller_id DESC;


[User] Display all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] What order_id, published_at, seller_id, approval_status do we have for assets and their associated orders?

[Assistant] SELECT *, orders.seller_id, orders.approval_status FROM tradingplatform.assets JOIN tradingplatform.orders ON assets.order_id = orders.invoice_id;

[User] Can you order these by image_url ascending?

[Assistant] SELECT *, orders.seller_id, orders.approval_status FROM tradingplatform.assets JOIN tradingplatform.orders ON assets.order_id = orders.invoice_id ORDER BY image_url ASC;


[User] Get all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

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

[User] Sort the results by approval_status ascending.

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


[User] Retrieve profile_picture_url, language, order_id for every user.

[Assistant] SELECT profile_picture_url, language, order_id FROM tradingplatform.users;

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

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

[User] Calculate average of email for each language in users.

[Assistant] SELECT language, AVERAGE(email) AS average_email FROM tradingplatform.users GROUP BY language;


[User] Retrieve featured_rank, updated_at, order_id for every asset.

[Assistant] SELECT featured_rank, updated_at, order_id FROM tradingplatform.assets;

[User] Get all assets from last week.

[Assistant] SELECT featured_rank, updated_at, order_id FROM tradingplatform.assets WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Limit the results to 15 rows.

[Assistant] SELECT featured_rank, updated_at, order_id FROM tradingplatform.assets WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 15;


[User] Get all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] What published_at, updated_at, completed_at, status do we have for assets and their associated orders?

[Assistant] SELECT *, orders.completed_at, orders.status FROM tradingplatform.assets JOIN tradingplatform.orders ON assets.order_id = orders.invoice_id;

[User] Limit the results to 20 rows.

[Assistant] SELECT *, orders.completed_at, orders.status FROM tradingplatform.assets JOIN tradingplatform.orders ON assets.order_id = orders.invoice_id LIMIT 20;


[User] Get status, quantity, delivery_status from all orders.

[Assistant] SELECT status, quantity, delivery_status FROM tradingplatform.orders;

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

[Assistant] SELECT status, quantity, delivery_status FROM tradingplatform.orders WHERE completed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Sort the results by quantity descending.

[Assistant] SELECT status, quantity, delivery_status FROM tradingplatform.orders WHERE completed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' 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 logistics.content (
  content_id integer PRIMARY KEY -- unique identifier,
  edited_at date,
  published_at timestamp,
  likes character varying(128),
  image_url character varying(256),
  categories character varying(256) NOT NULL,
  attachment_url character varying(64) NOT NULL,
  parent_id character varying(256) -- identifier for parent,
  thumbnail character varying(256)
)

CREATE TABLE logistics.orders (
  id character varying(64) NOT NULL -- unique identifier,
  traded_at date,
  processed_at timestamp,
  payment_method character varying(256),
  price numeric(38,14) NOT NULL,
  payment_status char NOT NULL,
  status character varying(256),
  seller_id char -- identifier for seller,
  product_id character varying(128) -- identifier for product
)

[User] Show me all content.

[Assistant] SELECT * FROM logistics.content;

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

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

[User] Calculate count of thumbnail for each published_at in content.

[Assistant] SELECT published_at, COUNT(thumbnail) AS count_thumbnail FROM logistics.content GROUP BY published_at;


[User] Retrieve categories, attachment_url, image_url for every content.

[Assistant] SELECT categories, attachment_url, image_url FROM logistics.content;

[User] Get content that match image_url LIKE 'A%'.

[Assistant] SELECT categories, attachment_url, image_url FROM logistics.content WHERE image_url LIKE 'A%';

[User] Only show the top 10 results.

[Assistant] SELECT categories, attachment_url, image_url FROM logistics.content WHERE image_url LIKE 'A%' LIMIT 10;


[User] Display all content.

[Assistant] SELECT * FROM logistics.content;

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

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

[User] Show the results sorted by parent_id ascending.

[Assistant] SELECT * FROM logistics.content WHERE edited_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY parent_id ASC;


[User] List likes, image_url, published_at from content.

[Assistant] SELECT likes, image_url, published_at FROM logistics.content;

[User] Get content that match edited_at > '2023-01-01'.

[Assistant] SELECT likes, image_url, published_at FROM logistics.content WHERE edited_at > '2023-01-01';

[User] What is the sum edited_at for each attachment_url in content?

[Assistant] SELECT attachment_url, SUM(edited_at) AS sum_edited_at FROM logistics.content GROUP BY attachment_url;


[User] Display all orders.

[Assistant] SELECT * FROM logistics.orders;

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

[Assistant] SELECT * FROM logistics.orders ORDER BY seller_id DESC;

[User] Limit the results to 10 rows.

[Assistant] SELECT * FROM logistics.orders ORDER BY seller_id DESC LIMIT 10;


[User] What are the attachment_url, image_url, thumbnail of each content?

[Assistant] SELECT attachment_url, image_url, thumbnail FROM logistics.content;

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

[Assistant] SELECT attachment_url, image_url, thumbnail FROM logistics.content WHERE likes LIKE 'A%';

[User] Show the results sorted by categories descending.

[Assistant] SELECT attachment_url, image_url, thumbnail FROM logistics.content WHERE likes LIKE 'A%' ORDER BY categories DESC;


[User] Get all content.

[Assistant] SELECT * FROM logistics.content;

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

[Assistant] SELECT * FROM logistics.content ORDER BY image_url DESC;

[User] Can you order these by published_at descending?

[Assistant] SELECT * FROM logistics.content ORDER BY published_at DESC;


[User] List parent_id, likes, thumbnail from content.

[Assistant] SELECT parent_id, likes, thumbnail FROM logistics.content;

[User] Can you order these by parent_id ascending?

[Assistant] SELECT parent_id, likes, thumbnail FROM logistics.content ORDER BY parent_id ASC;

[User] Calculate average of categories for each thumbnail in content.

[Assistant] SELECT thumbnail, AVERAGE(categories) AS average_categories FROM logistics.content GROUP BY thumbnail;


[User] Display all orders.

[Assistant] SELECT * FROM logistics.orders;

[User] Find orders from last week.

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

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

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


[User] Show me edited_at, thumbnail, categories for all content.

[Assistant] SELECT edited_at, thumbnail, categories FROM logistics.content;

[User] Get content that match attachment_url LIKE 'A%'.

[Assistant] SELECT edited_at, thumbnail, categories FROM logistics.content WHERE attachment_url LIKE 'A%';

[User] Return just 20 rows.

[Assistant] SELECT edited_at, thumbnail, categories FROM logistics.content WHERE attachment_url LIKE 'A%' LIMIT 20;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.products (
  id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  featured_rank char,
  video_url char NOT NULL,
  reserved character varying(128),
  name varchar,
  category char,
  order_item_id text -- reference to order_items.store_id,
  FOREIGN KEY (order_item_id) REFERENCES order_items(store_id)
)

CREATE TABLE e-commerce.order_items (
  store_id varchar PRIMARY KEY -- unique identifier,
  last_inspected timestamp without time zone,
  latitude varchar,
  operating_hours text,
  name text,
  accessibility character varying(256),
  product_id text -- reference to products.id,
  FOREIGN KEY (product_id) REFERENCES products(id)
)

[User] What are the name, operating_hours, accessibility of each order_item?

[Assistant] SELECT name, operating_hours, accessibility FROM e-commerce.order_items;

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

[Assistant] SELECT name, operating_hours, accessibility FROM e-commerce.order_items ORDER BY name ASC;

[User] Group order_items by last_inspected and show the count of name.

[Assistant] SELECT last_inspected, COUNT(name) AS count_name FROM e-commerce.order_items GROUP BY last_inspected;


[User] Show me accessibility, last_inspected, product_id for all order_items.

[Assistant] SELECT accessibility, last_inspected, product_id FROM e-commerce.order_items;

[User] Get order_items that match operating_hours LIKE 'A%'.

[Assistant] SELECT accessibility, last_inspected, product_id FROM e-commerce.order_items WHERE operating_hours LIKE 'A%';

[User] Group order_items by latitude and show the average of last_inspected.

[Assistant] SELECT latitude, AVERAGE(last_inspected) AS average_last_inspected FROM e-commerce.order_items GROUP BY latitude;


[User] List latitude, last_inspected, accessibility from order_items.

[Assistant] SELECT latitude, last_inspected, accessibility FROM e-commerce.order_items;

[User] Get product_id, operating_hours, featured_rank, updated_at by joining order_items with products.

[Assistant] SELECT latitude, last_inspected, accessibility, products.featured_rank, products.updated_at FROM e-commerce.order_items JOIN e-commerce.products ON order_items.product_id = products.id;

[User] Restrict the output to 50 items.

[Assistant] SELECT latitude, last_inspected, accessibility, products.featured_rank, products.updated_at FROM e-commerce.order_items JOIN e-commerce.products ON order_items.product_id = products.id LIMIT 50;


[User] Retrieve all order_items.

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

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

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

[User] Show only 15 records.

[Assistant] SELECT * FROM e-commerce.order_items ORDER BY name DESC LIMIT 15;


[User] Get all products.

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

[User] Show me products with reserved LIKE 'A%'.

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

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

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


[User] Show me featured_rank, reserved, name for all products.

[Assistant] SELECT featured_rank, reserved, name FROM e-commerce.products;

[User] List order_item_id, video_url, accessibility, name for each product along with their order_item information.

[Assistant] SELECT featured_rank, reserved, name, order_items.accessibility, order_items.name FROM e-commerce.products JOIN e-commerce.order_items ON products.order_item_id = order_items.store_id;

[User] Restrict the output to 20 items.

[Assistant] SELECT featured_rank, reserved, name, order_items.accessibility, order_items.name FROM e-commerce.products JOIN e-commerce.order_items ON products.order_item_id = order_items.store_id LIMIT 20;


[User] What are the order_item_id, video_url, category of each product?

[Assistant] SELECT order_item_id, video_url, category FROM e-commerce.products;

[User] Sort the results by reserved descending.

[Assistant] SELECT order_item_id, video_url, category FROM e-commerce.products ORDER BY reserved DESC;

[User] What is the max reserved for each category in products?

[Assistant] SELECT category, MAX(reserved) AS max_reserved FROM e-commerce.products GROUP BY category;


[User] Show me name, reserved, order_item_id for all products.

[Assistant] SELECT name, reserved, order_item_id FROM e-commerce.products;

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

[Assistant] SELECT name, reserved, order_item_id FROM e-commerce.products ORDER BY category DESC;

[User] Restrict the output to 50 items.

[Assistant] SELECT name, reserved, order_item_id FROM e-commerce.products ORDER BY category DESC LIMIT 50;


[User] List all order_items.

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

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

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

[User] Show the results sorted by operating_hours ascending.

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


[User] List category, reserved, featured_rank from products.

[Assistant] SELECT category, reserved, featured_rank FROM e-commerce.products;

[User] Get name, reserved, name, latitude by joining products with order_items.

[Assistant] SELECT category, reserved, featured_rank, order_items.name, order_items.latitude FROM e-commerce.products JOIN e-commerce.order_items ON products.order_item_id = order_items.store_id;

[User] Order the output by order_item_id ascending.

[Assistant] SELECT category, reserved, featured_rank, order_items.name, order_items.latitude FROM e-commerce.products JOIN e-commerce.order_items ON products.order_item_id = order_items.store_id ORDER BY order_item_id ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.teachers (
  payment_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  processed_at timestamp without time zone,
  payment_status varchar,
  approval_status varchar,
  payment_method character varying(256),
  card_type character varying(128)
)

CREATE TABLE education.departments (
  id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  available text,
  subcategory char NOT NULL,
  tax_rate varchar,
  brand character varying(64) NOT NULL
)

CREATE TABLE education.assignments (
  location_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  description char NOT NULL,
  zip_code varchar NOT NULL,
  address_line2 character varying(64),
  location_lat varchar,
  department_id text -- reference to departments.id,
  FOREIGN KEY (department_id) REFERENCES departments(id)
)

[User] Show me all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Sort the results by location_lat ascending.

[Assistant] SELECT * FROM education.assignments ORDER BY location_lat ASC;

[User] Group assignments by department_id and show the average of department_id.

[Assistant] SELECT department_id, AVERAGE(department_id) AS average_department_id FROM education.assignments GROUP BY department_id;


[User] What are the department_id, location_id, zip_code of each assignment?

[Assistant] SELECT department_id, location_id, zip_code FROM education.assignments;

[User] Show the results sorted by created_at descending.

[Assistant] SELECT department_id, location_id, zip_code FROM education.assignments ORDER BY created_at DESC;

[User] Show only 15 records.

[Assistant] SELECT department_id, location_id, zip_code FROM education.assignments ORDER BY created_at DESC LIMIT 15;


[User] Retrieve zip_code, address_line2, location_lat for every assignment.

[Assistant] SELECT zip_code, address_line2, location_lat FROM education.assignments;

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

[Assistant] SELECT zip_code, address_line2, location_lat FROM education.assignments WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Restrict the output to 15 items.

[Assistant] SELECT zip_code, address_line2, location_lat FROM education.assignments WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 15;


[User] List address_line2, zip_code, location_lat from assignments.

[Assistant] SELECT address_line2, zip_code, location_lat FROM education.assignments;

[User] List location_id, location_lat, created_at, tax_rate for each assignment along with their department information.

[Assistant] SELECT address_line2, zip_code, location_lat, departments.created_at, departments.tax_rate FROM education.assignments JOIN education.departments ON assignments.department_id = departments.id;

[User] Order the output by zip_code ascending.

[Assistant] SELECT address_line2, zip_code, location_lat, departments.created_at, departments.tax_rate FROM education.assignments JOIN education.departments ON assignments.department_id = departments.id ORDER BY zip_code ASC;


[User] Get created_at, department_id, location_id from all assignments.

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

[User] Show the results sorted by description ascending.

[Assistant] SELECT created_at, department_id, location_id FROM education.assignments ORDER BY description ASC;

[User] Group assignments by location_lat and show the max of location_id.

[Assistant] SELECT location_lat, MAX(location_id) AS max_location_id FROM education.assignments GROUP BY location_lat;


[User] Show me all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Find assignments where zip_code LIKE 'A%'.

[Assistant] SELECT * FROM education.assignments WHERE zip_code LIKE 'A%';

[User] Group assignments by address_line2 and show the sum of zip_code.

[Assistant] SELECT address_line2, SUM(zip_code) AS sum_zip_code FROM education.assignments GROUP BY address_line2;


[User] Display all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Get description, location_id, available, brand by joining assignments with departments.

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

[User] Return just 50 rows.

[Assistant] SELECT *, departments.available, departments.brand FROM education.assignments JOIN education.departments ON assignments.department_id = departments.id LIMIT 50;


[User] Retrieve all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Can you order these by address_line2 descending?

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

[User] Show only 25 records.

[Assistant] SELECT * FROM education.assignments ORDER BY address_line2 DESC LIMIT 25;


[User] Retrieve all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Find assignments older than 6 months.

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

[User] How many assignments are there per location_lat?

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


[User] Show me all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Show the results sorted by location_lat ascending.

[Assistant] SELECT * FROM education.assignments ORDER BY location_lat ASC;

[User] Limit the results to 25 rows.

[Assistant] SELECT * FROM education.assignments ORDER BY location_lat ASC LIMIT 25;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.students (
  id varchar PRIMARY KEY -- unique identifier,
  joined_at date,
  last_active timestamp without time zone,
  timezone character varying(64),
  gender text,
  last_name text,
  department_id integer NOT NULL -- reference to departments.id,
  FOREIGN KEY (department_id) REFERENCES departments(id)
)

CREATE TABLE education.grades (
  id character varying(64) NOT NULL -- unique identifier,
  cancelled_at timestamp,
  traded_at date,
  price decimal NOT NULL,
  payment_method char,
  product_id character varying(256) NOT NULL,
  quantity char,
  department_id integer NOT NULL -- reference to departments.id,
  FOREIGN KEY (department_id) REFERENCES departments(id)
)

CREATE TABLE education.departments (
  id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at date,
  image_url varchar NOT NULL,
  user_id varchar -- identifier for user,
  media_url varchar,
  views character varying(128),
  parent_id character varying(128) -- identifier for parent
)

[User] What are the id, product_id, price of each grade?

[Assistant] SELECT id, product_id, price FROM education.grades;

[User] Retrieve grades where price > 62.

[Assistant] SELECT id, product_id, price FROM education.grades WHERE price > 62;

[User] Group grades by id and show the average of department_id.

[Assistant] SELECT id, AVERAGE(department_id) AS average_department_id FROM education.grades GROUP BY id;


[User] Display all grades.

[Assistant] SELECT * FROM education.grades;

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

[Assistant] SELECT * FROM education.grades WHERE quantity LIKE 'A%';

[User] Count the number of grades in each payment_method category.

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


[User] List all students.

[Assistant] SELECT * FROM education.students;

[User] Show me students with department_id > 7.

[Assistant] SELECT * FROM education.students WHERE department_id > 7;

[User] Calculate min of timezone for each timezone in students.

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


[User] Show me all students.

[Assistant] SELECT * FROM education.students;

[User] Show the results sorted by last_active descending.

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

[User] What is the average last_active for each gender in students?

[Assistant] SELECT gender, AVERAGE(last_active) AS average_last_active FROM education.students GROUP BY gender;


[User] Show me price, department_id, quantity for all grades.

[Assistant] SELECT price, department_id, quantity FROM education.grades;

[User] Show the results sorted by traded_at ascending.

[Assistant] SELECT price, department_id, quantity FROM education.grades ORDER BY traded_at ASC;

[User] Count the number of grades in each price category.

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


[User] Display all grades.

[Assistant] SELECT * FROM education.grades;

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

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

[User] Count the number of grades in each quantity category.

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


[User] Display all students.

[Assistant] SELECT * FROM education.students;

[User] Can you order these by last_name descending?

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

[User] Tally up students by gender.

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


[User] Show me last_active, last_name, joined_at for all students.

[Assistant] SELECT last_active, last_name, joined_at FROM education.students;

[User] Retrieve timezone, department_id, image_url, user_id showing the relationship between students and departments.

[Assistant] SELECT last_active, last_name, joined_at, departments.image_url, departments.user_id FROM education.students JOIN education.departments ON students.department_id = departments.id;

[User] What is the count last_name for each last_active in students?

[Assistant] SELECT last_active, COUNT(last_name) AS count_last_name FROM education.students GROUP BY last_active;


[User] Show me all grades.

[Assistant] SELECT * FROM education.grades;

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

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

[User] Sort the results by department_id ascending.

[Assistant] SELECT * FROM education.grades WHERE traded_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY department_id ASC;


[User] List department_id, timezone, joined_at from students.

[Assistant] SELECT department_id, timezone, joined_at FROM education.students;

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

[Assistant] SELECT department_id, timezone, joined_at FROM education.students ORDER BY joined_at ASC;

[User] Show the results sorted by last_active descending.

[Assistant] SELECT department_id, timezone, joined_at FROM education.students ORDER BY last_active DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.followers (
  id integer PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at date,
  last_login timestamp,
  timezone character varying(64) NOT NULL,
  profile_picture_url character varying(64),
  event_id text -- reference to events.person_id,
  FOREIGN KEY (event_id) REFERENCES events(person_id)
)

CREATE TABLE socialmedia.posts (
  message_id varchar PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  updated_at date,
  likes character varying(128),
  content char NOT NULL,
  parent_id character varying(64) NOT NULL -- identifier for parent
)

CREATE TABLE socialmedia.events (
  person_id text PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at timestamp without time zone,
  timezone text,
  is_active bit NOT NULL,
  bio character varying(64),
  nationality text
)

[User] Show me all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Get profile_picture_url, updated_at, created_at, timezone by joining followers with events.

[Assistant] SELECT *, events.created_at, events.timezone FROM socialmedia.followers JOIN socialmedia.events ON followers.event_id = events.person_id;

[User] Only show the top 100 results.

[Assistant] SELECT *, events.created_at, events.timezone FROM socialmedia.followers JOIN socialmedia.events ON followers.event_id = events.person_id LIMIT 100;


[User] Retrieve created_at, timezone, profile_picture_url for every follower.

[Assistant] SELECT created_at, timezone, profile_picture_url FROM socialmedia.followers;

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

[Assistant] SELECT created_at, timezone, profile_picture_url FROM socialmedia.followers WHERE timezone LIKE 'A%';

[User] Show me min of event_id grouped by timezone for followers.

[Assistant] SELECT timezone, MIN(event_id) AS min_event_id FROM socialmedia.followers GROUP BY timezone;


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

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

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


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Can you order these by created_at descending?

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

[User] Limit the results to 20 rows.

[Assistant] SELECT * FROM socialmedia.followers ORDER BY created_at DESC LIMIT 20;


[User] Retrieve updated_at, profile_picture_url, last_login for every follower.

[Assistant] SELECT updated_at, profile_picture_url, last_login FROM socialmedia.followers;

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

[Assistant] SELECT updated_at, profile_picture_url, last_login FROM socialmedia.followers WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Restrict the output to 15 items.

[Assistant] SELECT updated_at, profile_picture_url, last_login FROM socialmedia.followers WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 15;


[User] List timezone, last_login, event_id from followers.

[Assistant] SELECT timezone, last_login, event_id FROM socialmedia.followers;

[User] Can you order these by last_login descending?

[Assistant] SELECT timezone, last_login, event_id FROM socialmedia.followers ORDER BY last_login DESC;

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

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


[User] Show me updated_at, created_at, timezone for all followers.

[Assistant] SELECT updated_at, created_at, timezone FROM socialmedia.followers;

[User] What last_login, event_id, timezone, is_active do we have for followers and their associated events?

[Assistant] SELECT updated_at, created_at, timezone, events.timezone, events.is_active FROM socialmedia.followers JOIN socialmedia.events ON followers.event_id = events.person_id;

[User] Show only 100 records.

[Assistant] SELECT updated_at, created_at, timezone, events.timezone, events.is_active FROM socialmedia.followers JOIN socialmedia.events ON followers.event_id = events.person_id LIMIT 100;


[User] List profile_picture_url, updated_at, event_id from followers.

[Assistant] SELECT profile_picture_url, updated_at, event_id FROM socialmedia.followers;

[User] Can you order these by last_login descending?

[Assistant] SELECT profile_picture_url, updated_at, event_id FROM socialmedia.followers ORDER BY last_login DESC;

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

[Assistant] SELECT profile_picture_url, updated_at, event_id FROM socialmedia.followers ORDER BY event_id DESC;


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Sort the results by timezone descending.

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

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

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


[User] Show me all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

[Assistant] SELECT * FROM socialmedia.followers ORDER BY event_id ASC;

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.billing (
  id text PRIMARY KEY -- unique identifier,
  completed_at date,
  processed_at date,
  seller_id character varying(128) -- identifier for seller,
  discount numeric(38,14),
  user_id character varying(64) NOT NULL -- identifier for user,
  payment_status character varying(128),
  total smallint NOT NULL,
  amount decimal
)

CREATE TABLE healthcare.prescriptions (
  id character varying(64) NOT NULL -- unique identifier,
  last_active timestamp without time zone,
  full_name character varying(64),
  language varchar,
  api_key char,
  last_login timestamp,
  phone character varying(64) NOT NULL,
  billin_id text NOT NULL -- reference to billing.id,
  FOREIGN KEY (billin_id) REFERENCES billing(id)
)

[User] Retrieve all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Retrieve api_key, last_active, seller_id, completed_at showing the relationship between prescriptions and billing.

[Assistant] SELECT *, billing.seller_id, billing.completed_at FROM healthcare.prescriptions JOIN healthcare.billing ON prescriptions.billin_id = billing.id;

[User] How many prescriptions are there per id?

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


[User] What are the full_name, phone, billin_id of each prescription?

[Assistant] SELECT full_name, phone, billin_id FROM healthcare.prescriptions;

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

[Assistant] SELECT full_name, phone, billin_id FROM healthcare.prescriptions WHERE last_active >= CURRENT_DATE - INTERVAL '7 days';

[User] Count the number of prescriptions in each billin_id category.

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


[User] List last_active, api_key, billin_id from prescriptions.

[Assistant] SELECT last_active, api_key, billin_id FROM healthcare.prescriptions;

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

[Assistant] SELECT last_active, api_key, billin_id FROM healthcare.prescriptions WHERE billin_id LIKE 'A%';

[User] Get the distribution of prescriptions across different language values.

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


[User] List billin_id, full_name, language from prescriptions.

[Assistant] SELECT billin_id, full_name, language FROM healthcare.prescriptions;

[User] List billin_id, last_active, user_id, processed_at for each prescription along with their billing information.

[Assistant] SELECT billin_id, full_name, language, billing.user_id, billing.processed_at FROM healthcare.prescriptions JOIN healthcare.billing ON prescriptions.billin_id = billing.id;

[User] Show me average of last_login grouped by api_key for prescriptions.

[Assistant] SELECT api_key, AVERAGE(last_login) AS average_last_login FROM healthcare.prescriptions GROUP BY api_key;


[User] Retrieve all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Order the output by last_login ascending.

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

[User] Return just 10 rows.

[Assistant] SELECT * FROM healthcare.prescriptions ORDER BY last_login ASC LIMIT 10;


[User] Get all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Show the results sorted by last_login ascending.

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

[User] Limit the results to 5 rows.

[Assistant] SELECT * FROM healthcare.prescriptions ORDER BY last_login ASC LIMIT 5;


[User] Retrieve all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

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

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

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

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


[User] What are the language, billin_id, phone of each prescription?

[Assistant] SELECT language, billin_id, phone FROM healthcare.prescriptions;

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

[Assistant] SELECT language, billin_id, phone FROM healthcare.prescriptions WHERE api_key LIKE 'A%';

[User] Limit the results to 100 rows.

[Assistant] SELECT language, billin_id, phone FROM healthcare.prescriptions WHERE api_key LIKE 'A%' LIMIT 100;


[User] Retrieve all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Retrieve prescriptions where language LIKE 'A%'.

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

[User] Return just 50 rows.

[Assistant] SELECT * FROM healthcare.prescriptions WHERE language LIKE 'A%' LIMIT 50;


[User] Show me all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

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

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

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

[Assistant] SELECT * FROM healthcare.prescriptions WHERE last_login >= CURRENT_DATE - INTERVAL '30 days' ORDER BY api_key DESC;


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

CREATE TABLE finance.investments (
  message_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp without time zone,
  updated_at timestamp,
  message character varying(64) NOT NULL,
  attachment_url char,
  image_url character varying(128) NOT NULL,
  views char,
  reply_to_id varchar NOT NULL -- identifier for reply_to,
  customer_id text NOT NULL -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

CREATE TABLE finance.payments (
  payment_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  cancelled_at date,
  customer_id character varying(128) NOT NULL,
  user_id character varying(256),
  product_id text NOT NULL,
  payment_method varchar NOT NULL
)

CREATE TABLE finance.customers (
  employee_id varchar PRIMARY KEY -- unique identifier,
  last_active date,
  birth_date timestamp,
  username varchar,
  age varchar,
  last_login timestamp without time zone NOT NULL,
  account_id text NOT NULL -- reference to accounts.invoice_id,
  FOREIGN KEY (account_id) REFERENCES accounts(invoice_id)
)

[User] Get all investments.

[Assistant] SELECT * FROM finance.investments;

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

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

[User] Order the output by message_id ascending.

[Assistant] SELECT * FROM finance.investments WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY message_id ASC;


[User] Retrieve all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Show the results sorted by customer_id ascending.

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

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM finance.accounts ORDER BY customer_id ASC LIMIT 10;


[User] Get all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Return just 20 rows.

[Assistant] SELECT * FROM finance.customers WHERE last_login > '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.events (
  id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  user_id varchar,
  categories character varying(64),
  rating char NOT NULL,
  visibility varchar
)

CREATE TABLE socialmedia.followers (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  processed_at timestamp,
  payee_id character varying(256) -- identifier for payee,
  user_id character varying(64) -- identifier for user,
  reference_number character varying(64) NOT NULL,
  approval_status char,
  currency text,
  event_id text -- reference to events.id,
  FOREIGN KEY (event_id) REFERENCES events(id)
)

[User] Get processed_at, event_id, approval_status from all followers.

[Assistant] SELECT processed_at, event_id, approval_status FROM socialmedia.followers;

[User] Find followers created yesterday.

[Assistant] SELECT processed_at, event_id, approval_status FROM socialmedia.followers WHERE processed_at = CURRENT_DATE - INTERVAL '1 day';

[User] Can you order these by user_id descending?

[Assistant] SELECT processed_at, event_id, approval_status FROM socialmedia.followers WHERE processed_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY user_id DESC;


[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show me followers with reference_number LIKE 'A%'.

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

[User] Limit the results to 20 rows.

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


[User] Retrieve event_id, processed_at, currency for every follower.

[Assistant] SELECT event_id, processed_at, currency FROM socialmedia.followers;

[User] Sort the results by payee_id descending.

[Assistant] SELECT event_id, processed_at, currency FROM socialmedia.followers ORDER BY payee_id DESC;

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

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


[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

[User] Sort the results by user_id descending.

[Assistant] SELECT * FROM socialmedia.followers WHERE payee_id LIKE 'A%' ORDER BY user_id DESC;


[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show the results sorted by payee_id descending.

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

[User] How many followers are there per currency?

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


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] What payee_id, event_id, user_id, categories do we have for followers and their associated events?

[Assistant] SELECT *, events.user_id, events.categories FROM socialmedia.followers JOIN socialmedia.events ON followers.event_id = events.id;

[User] Sort the results by reference_number descending.

[Assistant] SELECT *, events.user_id, events.categories FROM socialmedia.followers JOIN socialmedia.events ON followers.event_id = events.id ORDER BY reference_number DESC;


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] What transaction_id, event_id, categories, rating do we have for followers and their associated events?

[Assistant] SELECT *, events.categories, events.rating FROM socialmedia.followers JOIN socialmedia.events ON followers.event_id = events.id;

[User] Get sum of approval_status by processed_at from followers.

[Assistant] SELECT processed_at, SUM(approval_status) AS sum_approval_status FROM socialmedia.followers GROUP BY processed_at;


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] List processed_at, user_id, updated_at, categories for each follower along with their event information.

[Assistant] SELECT *, events.updated_at, events.categories FROM socialmedia.followers JOIN socialmedia.events ON followers.event_id = events.id;

[User] Count the number of followers in each transaction_id category.

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


[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

[User] Only show the top 5 results.

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


[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show the results sorted by reference_number descending.

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

[User] Get min of transaction_id by approval_status from followers.

[Assistant] SELECT approval_status, MIN(transaction_id) AS min_transaction_id FROM socialmedia.followers GROUP BY approval_status;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.events (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  processed_at date,
  account_id varchar NOT NULL -- identifier for account,
  user_id text NOT NULL,
  fee text,
  message_id text -- reference to messages.comment_id,
  FOREIGN KEY (message_id) REFERENCES messages(comment_id)
)

CREATE TABLE socialmedia.messages (
  comment_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  attachment_url varchar,
  image_url character varying(128),
  title character varying(256) NOT NULL,
  format char,
  message varchar NOT NULL,
  rating text,
  thumbnail character varying(128)
)

CREATE TABLE socialmedia.comments (
  content_id text PRIMARY KEY -- unique identifier,
  edited_at timestamp without time zone,
  keywords character varying(64),
  views character varying(64),
  user_id character varying(256),
  shares char,
  text character varying(128)
)

[User] List user_id, fee, updated_at from events.

[Assistant] SELECT user_id, fee, updated_at FROM socialmedia.events;

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

[Assistant] SELECT user_id, fee, updated_at FROM socialmedia.events WHERE updated_at > '2023-01-01';

[User] Restrict the output to 50 items.

[Assistant] SELECT user_id, fee, updated_at FROM socialmedia.events WHERE updated_at > '2023-01-01' LIMIT 50;


[User] List all events.

[Assistant] SELECT * FROM socialmedia.events;

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

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

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

[Assistant] SELECT * FROM socialmedia.events WHERE processed_at > '2023-12-01' ORDER BY user_id DESC;


[User] What are the updated_at, account_id, user_id of each event?

[Assistant] SELECT updated_at, account_id, user_id FROM socialmedia.events;

[User] Sort the results by updated_at descending.

[Assistant] SELECT updated_at, account_id, user_id FROM socialmedia.events ORDER BY updated_at DESC;

[User] Order the output by processed_at ascending.

[Assistant] SELECT updated_at, account_id, user_id FROM socialmedia.events ORDER BY processed_at ASC;


[User] Show me fee, updated_at, message_id for all events.

[Assistant] SELECT fee, updated_at, message_id FROM socialmedia.events;

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

[Assistant] SELECT fee, updated_at, message_id FROM socialmedia.events WHERE updated_at > '2023-01-01';

[User] Restrict the output to 15 items.

[Assistant] SELECT fee, updated_at, message_id FROM socialmedia.events WHERE updated_at > '2023-01-01' LIMIT 15;


[User] Retrieve processed_at, updated_at, message_id for every event.

[Assistant] SELECT processed_at, updated_at, message_id FROM socialmedia.events;

[User] Show me updated_at, account_id, title, message from events and their related messages.

[Assistant] SELECT processed_at, updated_at, message_id, messages.title, messages.message FROM socialmedia.events JOIN socialmedia.messages ON events.message_id = messages.comment_id;

[User] Sort the results by message_id descending.

[Assistant] SELECT processed_at, updated_at, message_id, messages.title, messages.message FROM socialmedia.events JOIN socialmedia.messages ON events.message_id = messages.comment_id ORDER BY message_id DESC;


[User] Retrieve all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Can you order these by account_id descending?

[Assistant] SELECT * FROM socialmedia.events ORDER BY account_id DESC;

[User] Can you order these by updated_at descending?

[Assistant] SELECT * FROM socialmedia.events ORDER BY updated_at DESC;


[User] Display all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Show the results sorted by fee descending.

[Assistant] SELECT * FROM socialmedia.events ORDER BY fee DESC;

[User] Group events by processed_at and show the average of processed_at.

[Assistant] SELECT processed_at, AVERAGE(processed_at) AS average_processed_at FROM socialmedia.events GROUP BY processed_at;


[User] What are the account_id, user_id, processed_at of each event?

[Assistant] SELECT account_id, user_id, processed_at FROM socialmedia.events;

[User] Retrieve events where processed_at > '2023-01-01'.

[Assistant] SELECT account_id, user_id, processed_at FROM socialmedia.events WHERE processed_at > '2023-01-01';

[User] Get the distribution of events across different fee values.

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


[User] Show me account_id, updated_at, fee for all events.

[Assistant] SELECT account_id, updated_at, fee FROM socialmedia.events;

[User] List events with dates created yesterday.

[Assistant] SELECT account_id, updated_at, fee FROM socialmedia.events WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Limit the results to 100 rows.

[Assistant] SELECT account_id, updated_at, fee FROM socialmedia.events WHERE updated_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 100;


[User] Get all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Can you order these by account_id descending?

[Assistant] SELECT * FROM socialmedia.events ORDER BY account_id DESC;

[User] Restrict the output to 25 items.

[Assistant] SELECT * FROM socialmedia.events ORDER BY account_id DESC LIMIT 25;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.messages (
  comment_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp,
  visibility character varying(64),
  user_id character varying(64) NOT NULL -- identifier for user,
  thumbnail varchar,
  attachment_url varchar,
  post_id text NOT NULL -- reference to posts.content_id,
  FOREIGN KEY (post_id) REFERENCES posts(content_id)
)

CREATE TABLE socialmedia.comments (
  message_id integer PRIMARY KEY -- unique identifier,
  published_at timestamp,
  media_url character varying(128),
  visibility text,
  image_url character varying(128)
)

CREATE TABLE socialmedia.users (
  user_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  joined_at date,
  first_name varchar NOT NULL,
  last_login timestamp,
  profile_picture_url character varying(256),
  comment_id integer -- reference to comments.message_id,
  FOREIGN KEY (comment_id) REFERENCES comments(message_id)
)

CREATE TABLE socialmedia.posts (
  content_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  views character varying(128) NOT NULL,
  reply_to_id varchar,
  tags character varying(64) NOT NULL,
  thumbnail character varying(64),
  author_id text NOT NULL -- identifier for author
)

[User] Show me all messages.

[Assistant] SELECT * FROM socialmedia.messages;

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

[Assistant] SELECT * FROM socialmedia.messages WHERE attachment_url LIKE 'A%';

[User] Sort the results by comment_id ascending.

[Assistant] SELECT * FROM socialmedia.messages WHERE attachment_url LIKE 'A%' ORDER BY comment_id ASC;


[User] Get first_name, created_at, last_login from all users.

[Assistant] SELECT first_name, created_at, last_login FROM socialmedia.users;

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

[Assistant] SELECT first_name, created_at, last_login FROM socialmedia.users WHERE first_name LIKE 'A%';

[User] Group users by first_name and show the sum of user_id.

[Assistant] SELECT first_name, SUM(user_id) AS sum_user_id FROM socialmedia.users GROUP BY first_name;


[User] Get all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Find users from last week.

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

[User] Show the results sorted by created_at descending.

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


[User] Get all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] List user_id, comment_id, visibility, image_url for each user along with their comment information.

[Assistant] SELECT *, comments.visibility, comments.image_url FROM socialmedia.users JOIN socialmedia.comments ON users.comment_id = comments.message_id;

[User] Limit the results to 50 rows.

[Assistant] SELECT *, comments.visibility, comments.image_url FROM socialmedia.users JOIN socialmedia.comments ON users.comment_id = comments.message_id LIMIT 50;


[User] Display all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] What last_login, created_at, media_url, visibility do we have for users and their associated comments?

[Assistant] SELECT *, comments.media_url, comments.visibility FROM socialmedia.users JOIN socialmedia.comments ON users.comment_id = comments.message_id;

[User] Show the results sorted by comment_id ascending.

[Assistant] SELECT *, comments.media_url, comments.visibility FROM socialmedia.users JOIN socialmedia.comments ON users.comment_id = comments.message_id ORDER BY comment_id ASC;


[User] List user_id, last_login, comment_id from users.

[Assistant] SELECT user_id, last_login, comment_id FROM socialmedia.users;

[User] Sort the results by profile_picture_url descending.

[Assistant] SELECT user_id, last_login, comment_id FROM socialmedia.users ORDER BY profile_picture_url DESC;

[User] Group users by profile_picture_url and show the average of created_at.

[Assistant] SELECT profile_picture_url, AVERAGE(created_at) AS average_created_at FROM socialmedia.users GROUP BY profile_picture_url;


[User] Get all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Order the output by thumbnail descending.

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

[User] Return just 10 rows.

[Assistant] SELECT * FROM socialmedia.messages ORDER BY thumbnail DESC LIMIT 10;


[User] Retrieve attachment_url, thumbnail, visibility for every message.

[Assistant] SELECT attachment_url, thumbnail, visibility FROM socialmedia.messages;

[User] Sort the results by attachment_url descending.

[Assistant] SELECT attachment_url, thumbnail, visibility FROM socialmedia.messages ORDER BY attachment_url DESC;

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

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


[User] Get all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Find messages created yesterday.

[Assistant] SELECT * FROM socialmedia.messages WHERE published_at = CURRENT_DATE - INTERVAL '1 day';

[User] Order the output by thumbnail descending.

[Assistant] SELECT * FROM socialmedia.messages WHERE published_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY thumbnail DESC;


[User] Retrieve all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Can you order these by profile_picture_url ascending?

[Assistant] SELECT * FROM socialmedia.users ORDER BY profile_picture_url ASC;

[User] Get average of profile_picture_url by first_name from users.

[Assistant] SELECT first_name, AVERAGE(profile_picture_url) AS average_profile_picture_url FROM socialmedia.users GROUP BY first_name;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.products (
  barcode varchar PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  expires_at date,
  quantity character varying(64),
  views character varying(256),
  popularity_score character varying(128),
  price numeric,
  rating char NOT NULL,
  user_id text NOT NULL -- reference to users.person_id,
  FOREIGN KEY (user_id) REFERENCES users(person_id)
)

CREATE TABLE e-commerce.categories (
  id text PRIMARY KEY -- unique identifier,
  updated_at date,
  last_active date,
  avatar character varying(64),
  is_verified boolean -- indicates if verified is true,
  last_login timestamp without time zone,
  api_key character varying(256) NOT NULL,
  language text NOT NULL
)

CREATE TABLE e-commerce.users (
  person_id text PRIMARY KEY -- unique identifier,
  last_active timestamp,
  avatar character varying(64) NOT NULL,
  website character varying(64),
  status char NOT NULL,
  age text,
  display_name character varying(64),
  token character varying(128),
  last_name character varying(128),
  categorie_id text -- reference to categories.id,
  FOREIGN KEY (categorie_id) REFERENCES categories(id)
)

[User] List all products.

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

[User] Show me quantity, views, token, age from products and their related users.

[Assistant] SELECT *, users.token, users.age FROM e-commerce.products JOIN e-commerce.users ON products.user_id = users.person_id;

[User] Show the results sorted by quantity ascending.

[Assistant] SELECT *, users.token, users.age FROM e-commerce.products JOIN e-commerce.users ON products.user_id = users.person_id ORDER BY quantity ASC;


[User] Get status, last_active, website from all users.

[Assistant] SELECT status, last_active, website FROM e-commerce.users;

[User] Get users that match age LIKE 'A%'.

[Assistant] SELECT status, last_active, website FROM e-commerce.users WHERE age LIKE 'A%';

[User] Show me sum of last_name grouped by display_name for users.

[Assistant] SELECT display_name, SUM(last_name) AS sum_last_name FROM e-commerce.users GROUP BY display_name;


[User] Retrieve published_at, price, user_id for every product.

[Assistant] SELECT published_at, price, user_id FROM e-commerce.products;

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

[Assistant] SELECT published_at, price, user_id FROM e-commerce.products ORDER BY published_at DESC;

[User] Get max of views by popularity_score from products.

[Assistant] SELECT popularity_score, MAX(views) AS max_views FROM e-commerce.products GROUP BY popularity_score;


[User] Show me all products.

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

[User] Get price, user_id, website, categorie_id by joining products with users.

[Assistant] SELECT *, users.website, users.categorie_id FROM e-commerce.products JOIN e-commerce.users ON products.user_id = users.person_id;

[User] What is the average popularity_score for each price in products?

[Assistant] SELECT price, AVERAGE(popularity_score) AS average_popularity_score FROM e-commerce.products GROUP BY price;


[User] Retrieve all products.

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

[User] What quantity, popularity_score, categorie_id, age do we have for products and their associated users?

[Assistant] SELECT *, users.categorie_id, users.age FROM e-commerce.products JOIN e-commerce.users ON products.user_id = users.person_id;

[User] Get average of expires_at by quantity from products.

[Assistant] SELECT quantity, AVERAGE(expires_at) AS average_expires_at FROM e-commerce.products GROUP BY quantity;


[User] Show me last_active, website, display_name for all users.

[Assistant] SELECT last_active, website, display_name FROM e-commerce.users;

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

[Assistant] SELECT last_active, website, display_name FROM e-commerce.users ORDER BY last_active ASC;

[User] Return just 20 rows.

[Assistant] SELECT last_active, website, display_name FROM e-commerce.users ORDER BY last_active ASC LIMIT 20;


[User] Show me expires_at, views, user_id for all products.

[Assistant] SELECT expires_at, views, user_id FROM e-commerce.products;

[User] Show me views, price, last_name, display_name from products and their related users.

[Assistant] SELECT expires_at, views, user_id, users.last_name, users.display_name FROM e-commerce.products JOIN e-commerce.users ON products.user_id = users.person_id;

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

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


[User] Show me all users.

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

[User] Find users created yesterday.

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

[User] Show the results sorted by last_active descending.

[Assistant] SELECT * FROM e-commerce.users WHERE last_active = CURRENT_DATE - INTERVAL '1 day' ORDER BY last_active DESC;


[User] Show me categorie_id, token, display_name for all users.

[Assistant] SELECT categorie_id, token, display_name FROM e-commerce.users;

[User] What website, avatar, api_key, language do we have for users and their associated categories?

[Assistant] SELECT categorie_id, token, display_name, categories.api_key, categories.language FROM e-commerce.users JOIN e-commerce.categories ON users.categorie_id = categories.id;

[User] How many users are there per token?

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


[User] List price, popularity_score, views from products.

[Assistant] SELECT price, popularity_score, views FROM e-commerce.products;

[User] Find products created yesterday.

[Assistant] SELECT price, popularity_score, views FROM e-commerce.products WHERE expires_at = CURRENT_DATE - INTERVAL '1 day';

[User] Order the output by published_at descending.

[Assistant] SELECT price, popularity_score, views FROM e-commerce.products WHERE expires_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY published_at 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.audits (
  payment_id text PRIMARY KEY -- unique identifier,
  cancelled_at timestamp without time zone,
  completed_at timestamp,
  payment_method text NOT NULL,
  currency character varying(256),
  product_id character varying(256) -- identifier for product,
  quantity character varying(128) NOT NULL,
  loan_id text -- reference to loans.account_id,
  FOREIGN KEY (loan_id) REFERENCES loans(account_id)
)

CREATE TABLE finance.payments (
  order_id character varying(64) NOT NULL -- unique identifier,
  processed_at timestamp without time zone,
  traded_at date,
  payment_method text,
  card_type varchar,
  price numeric,
  discount numeric NOT NULL
)

CREATE TABLE finance.loans (
  account_id text PRIMARY KEY -- unique identifier,
  due_date date,
  debit character varying(128) NOT NULL,
  payee_id character varying(256),
  payer_id varchar -- identifier for payer,
  currency text,
  reference_number varchar,
  vendor_id text -- identifier for vendor,
  approval_status varchar,
  transaction_id text NOT NULL -- reference to transactions.invoice_id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(invoice_id)
)

CREATE TABLE finance.transactions (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  status varchar,
  card_type character varying(256),
  delivery_status varchar
)

[User] Get payer_id, approval_status, debit from all loans.

[Assistant] SELECT payer_id, approval_status, debit FROM finance.loans;

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

[Assistant] SELECT payer_id, approval_status, debit FROM finance.loans ORDER BY transaction_id DESC;

[User] Tally up loans by vendor_id.

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


[User] Get payment_method, product_id, currency from all audits.

[Assistant] SELECT payment_method, product_id, currency FROM finance.audits;

[User] Order the output by product_id ascending.

[Assistant] SELECT payment_method, product_id, currency FROM finance.audits ORDER BY product_id ASC;

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

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


[User] List all audits.

[Assistant] SELECT * FROM finance.audits;

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

[Assistant] SELECT * FROM finance.audits WHERE cancelled_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Show only 10 records.

[Assistant] SELECT * FROM finance.audits WHERE cancelled_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 10;


[User] Get all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Retrieve audits where completed_at > '2023-01-01'.

[Assistant] SELECT * FROM finance.audits WHERE completed_at > '2023-01-01';

[User] Order the output by loan_id ascending.

[Assistant] SELECT * FROM finance.audits WHERE completed_at > '2023-01-01' ORDER BY loan_id ASC;


[User] Get all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Can you order these by quantity ascending?

[Assistant] SELECT * FROM finance.audits ORDER BY quantity ASC;

[User] Can you order these by completed_at ascending?

[Assistant] SELECT * FROM finance.audits ORDER BY completed_at ASC;


[User] Display all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Retrieve audits where loan_id LIKE 'A%'.

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

[User] Show only 25 records.

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


[User] Retrieve all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Find audits from last week.

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

[User] Limit the results to 100 rows.

[Assistant] SELECT * FROM finance.audits WHERE completed_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 100;


[User] Get all audits.

[Assistant] SELECT * FROM finance.audits;

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

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

[User] Get average of completed_at by quantity from audits.

[Assistant] SELECT quantity, AVERAGE(completed_at) AS average_completed_at FROM finance.audits GROUP BY quantity;


[User] List due_date, reference_number, payee_id from loans.

[Assistant] SELECT due_date, reference_number, payee_id FROM finance.loans;

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

[Assistant] SELECT due_date, reference_number, payee_id FROM finance.loans WHERE due_date > '2023-12-01';

[User] Show the results sorted by payee_id descending.

[Assistant] SELECT due_date, reference_number, payee_id FROM finance.loans WHERE due_date > '2023-12-01' ORDER BY payee_id DESC;


[User] List product_id, quantity, cancelled_at from audits.

[Assistant] SELECT product_id, quantity, cancelled_at FROM finance.audits;

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

[Assistant] SELECT product_id, quantity, cancelled_at FROM finance.audits WHERE completed_at > '2023-01-01';

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

[Assistant] SELECT product_id, quantity, cancelled_at FROM finance.audits WHERE completed_at > '2023-01-01' 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.customers (
  id integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at timestamp,
  salt character varying(128) NOT NULL,
  age varchar,
  birth_date timestamp without time zone NOT NULL,
  gender character varying(256),
  full_name text,
  payment_id text NOT NULL -- reference to payments.id,
  FOREIGN KEY (payment_id) REFERENCES payments(id)
)

CREATE TABLE finance.payments (
  id text PRIMARY KEY -- unique identifier,
  completed_at date,
  traded_at timestamp without time zone,
  card_type text,
  payment_method character varying(128),
  status char,
  buyer_id character varying(64) -- identifier for buyer,
  amount integer NOT NULL,
  currency character varying(128),
  customer_id integer -- reference to customers.id,
  FOREIGN KEY (customer_id) REFERENCES customers(id)
)

[User] Retrieve buyer_id, card_type, status for every payment.

[Assistant] SELECT buyer_id, card_type, status FROM finance.payments;

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

[Assistant] SELECT buyer_id, card_type, status FROM finance.payments WHERE traded_at > '2023-12-01';

[User] Can you order these by currency ascending?

[Assistant] SELECT buyer_id, card_type, status FROM finance.payments WHERE traded_at > '2023-12-01' ORDER BY currency ASC;


[User] List all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Calculate average of customer_id for each buyer_id in payments.

[Assistant] SELECT buyer_id, AVERAGE(customer_id) AS average_customer_id FROM finance.payments GROUP BY buyer_id;


[User] Get all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] How many customers are there per payment_id?

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


[User] List all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Find payments where completed_at > '2023-01-01'.

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

[User] Show the results sorted by card_type ascending.

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


[User] Retrieve traded_at, completed_at, amount for every payment.

[Assistant] SELECT traded_at, completed_at, amount FROM finance.payments;

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

[Assistant] SELECT traded_at, completed_at, amount FROM finance.payments WHERE completed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Show the results sorted by buyer_id ascending.

[Assistant] SELECT traded_at, completed_at, amount FROM finance.payments WHERE completed_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY buyer_id ASC;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

[User] List customers with dates from last week.

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

[User] Get sum of salt by full_name from customers.

[Assistant] SELECT full_name, SUM(salt) AS sum_salt FROM finance.customers GROUP BY full_name;