[User] List all comments.

[Assistant] SELECT * FROM government.comments;

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

[Assistant] SELECT * FROM government.comments ORDER BY keywords DESC;

[User] Count the number of comments in each visibility category.

[Assistant] SELECT visibility, COUNT(*) AS count FROM government.comments GROUP BY visibility 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 government.comments (
  comment_id text PRIMARY KEY -- unique identifier,
  published_at date,
  updated_at timestamp,
  user_id character varying(256) -- identifier for user,
  body character varying(64),
  description varchar NOT NULL,
  thumbnail text,
  visibility varchar,
  keywords character varying(128),
  location_id text -- reference to locations.venue_id,
  FOREIGN KEY (location_id) REFERENCES locations(venue_id)
)

CREATE TABLE government.locations (
  venue_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  created_at date,
  accessibility char,
  address_line2 character varying(256),
  comment_id text -- reference to comments.comment_id,
  FOREIGN KEY (comment_id) REFERENCES comments(comment_id)
)

CREATE TABLE government.payments (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  payment_date date,
  payee_id varchar NOT NULL -- identifier for payee,
  reconciliation_status text NOT NULL,
  vendor_id char -- identifier for vendor,
  payer_id character varying(128) -- identifier for payer,
  category character varying(256),
  balance decimal
)

[User] Retrieve all locations.

[Assistant] SELECT * FROM government.locations;

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

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

[User] Get min of comment_id by updated_at from locations.

[Assistant] SELECT updated_at, MIN(comment_id) AS min_comment_id FROM government.locations GROUP BY updated_at;


[User] What are the updated_at, keywords, visibility of each comment?

[Assistant] SELECT updated_at, keywords, visibility FROM government.comments;

[User] Can you order these by keywords ascending?

[Assistant] SELECT updated_at, keywords, visibility FROM government.comments ORDER BY keywords ASC;

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

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


[User] Get keywords, body, description from all comments.

[Assistant] SELECT keywords, body, description FROM government.comments;

[User] Get thumbnail, location_id, created_at, comment_id by joining comments with locations.

[Assistant] SELECT keywords, body, description, locations.created_at, locations.comment_id FROM government.comments JOIN government.locations ON comments.location_id = locations.venue_id;

[User] Get max of user_id by description from comments.

[Assistant] SELECT description, MAX(user_id) AS max_user_id FROM government.comments GROUP BY description;


[User] What are the created_at, comment_id, accessibility of each location?

[Assistant] SELECT created_at, comment_id, accessibility FROM government.locations;

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

[Assistant] SELECT created_at, comment_id, accessibility FROM government.locations WHERE created_at > '2023-01-01';

[User] Order the output by accessibility ascending.

[Assistant] SELECT created_at, comment_id, accessibility FROM government.locations WHERE created_at > '2023-01-01' ORDER BY accessibility 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 marketing.content (
  id integer PRIMARY KEY -- unique identifier,
  published_at timestamp,
  shares text,
  views text,
  description char,
  invoice_id integer NOT NULL -- reference to invoices.invoice_id,
  FOREIGN KEY (invoice_id) REFERENCES invoices(invoice_id)
)

CREATE TABLE marketing.invoices (
  invoice_id integer PRIMARY KEY -- unique identifier,
  due_date date,
  reference_number text,
  status char,
  balance numeric(38,14),
  exchange_rate varchar,
  invoice_number text NOT NULL,
  conten_id integer -- reference to content.id,
  FOREIGN KEY (conten_id) REFERENCES content(id)
)

[User] List invoice_id, published_at, shares from content.

[Assistant] SELECT invoice_id, published_at, shares FROM marketing.content;

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

[Assistant] SELECT invoice_id, published_at, shares FROM marketing.content ORDER BY invoice_id DESC;

[User] Show only 20 records.

[Assistant] SELECT invoice_id, published_at, shares FROM marketing.content ORDER BY invoice_id DESC LIMIT 20;


[User] Retrieve published_at, views, description for every content.

[Assistant] SELECT published_at, views, description FROM marketing.content;

[User] Get all content created yesterday.

[Assistant] SELECT published_at, views, description FROM marketing.content WHERE published_at = CURRENT_DATE - INTERVAL '1 day';

[User] What is the sum description for each shares in content?

[Assistant] SELECT shares, SUM(description) AS sum_description FROM marketing.content GROUP BY shares;


[User] List published_at, shares, views from content.

[Assistant] SELECT published_at, shares, views FROM marketing.content;

[User] Sort the results by shares ascending.

[Assistant] SELECT published_at, shares, views FROM marketing.content ORDER BY shares ASC;

[User] Only show the top 100 results.

[Assistant] SELECT published_at, shares, views FROM marketing.content ORDER BY shares ASC LIMIT 100;


[User] Display all invoices.

[Assistant] SELECT * FROM marketing.invoices;

[User] Get conten_id, reference_number, shares, description by joining invoices with content.

[Assistant] SELECT *, content.shares, content.description FROM marketing.invoices JOIN marketing.content ON invoices.conten_id = content.id;

[User] Sort the results by due_date ascending.

[Assistant] SELECT *, content.shares, content.description FROM marketing.invoices JOIN marketing.content ON invoices.conten_id = content.id ORDER BY due_date ASC;


[User] List all content.

[Assistant] SELECT * FROM marketing.content;

[User] Can you order these by description ascending?

[Assistant] SELECT * FROM marketing.content ORDER BY description ASC;

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

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


[User] Display all content.

[Assistant] SELECT * FROM marketing.content;

[User] Retrieve description, invoice_id, exchange_rate, balance showing the relationship between content and invoices.

[Assistant] SELECT *, invoices.exchange_rate, invoices.balance FROM marketing.content JOIN marketing.invoices ON content.invoice_id = invoices.invoice_id;

[User] Sort the results by published_at ascending.

[Assistant] SELECT *, invoices.exchange_rate, invoices.balance FROM marketing.content JOIN marketing.invoices ON content.invoice_id = invoices.invoice_id ORDER BY published_at ASC;


[User] Display all invoices.

[Assistant] SELECT * FROM marketing.invoices;

[User] List conten_id, balance, description, invoice_id for each invoice along with their content information.

[Assistant] SELECT *, content.description, content.invoice_id FROM marketing.invoices JOIN marketing.content ON invoices.conten_id = content.id;

[User] Only show the top 20 results.

[Assistant] SELECT *, content.description, content.invoice_id FROM marketing.invoices JOIN marketing.content ON invoices.conten_id = content.id LIMIT 20;


[User] Display all invoices.

[Assistant] SELECT * FROM marketing.invoices;

[User] Get invoices that match exchange_rate LIKE 'A%'.

[Assistant] SELECT * FROM marketing.invoices WHERE exchange_rate LIKE 'A%';

[User] Get average of reference_number by reference_number from invoices.

[Assistant] SELECT reference_number, AVERAGE(reference_number) AS average_reference_number FROM marketing.invoices GROUP BY reference_number;


[User] Retrieve exchange_rate, status, balance for every invoice.

[Assistant] SELECT exchange_rate, status, balance FROM marketing.invoices;

[User] List exchange_rate, conten_id, published_at, shares for each invoice along with their content information.

[Assistant] SELECT exchange_rate, status, balance, content.published_at, content.shares FROM marketing.invoices JOIN marketing.content ON invoices.conten_id = content.id;

[User] Show me average of exchange_rate grouped by status for invoices.

[Assistant] SELECT status, AVERAGE(exchange_rate) AS average_exchange_rate FROM marketing.invoices GROUP BY status;


[User] Show me all invoices.

[Assistant] SELECT * FROM marketing.invoices;

[User] What due_date, status, invoice_id, published_at do we have for invoices and their associated content?

[Assistant] SELECT *, content.invoice_id, content.published_at FROM marketing.invoices JOIN marketing.content ON invoices.conten_id = content.id;

[User] Can you order these by exchange_rate descending?

[Assistant] SELECT *, content.invoice_id, content.published_at FROM marketing.invoices JOIN marketing.content ON invoices.conten_id = content.id ORDER BY exchange_rate 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.transactions (
  id text PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  subtotal smallint NOT NULL,
  exchange_rate varchar,
  card_type character varying(64) NOT NULL,
  customer_id integer -- reference to customers.employee_id,
  FOREIGN KEY (customer_id) REFERENCES customers(employee_id)
)

CREATE TABLE finance.loans (
  id integer PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  status varchar,
  amount numeric,
  debit varchar NOT NULL,
  approval_status character varying(128) NOT NULL,
  notes text,
  description character varying(256) NOT NULL,
  payee_id character varying(64),
  transaction_id text -- reference to transactions.id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(id)
)

CREATE TABLE finance.customers (
  employee_id integer PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  created_at timestamp without time zone,
  token text,
  zip_code varchar NOT NULL,
  phone character varying(256),
  last_login date,
  full_name character varying(128),
  transaction_id text -- reference to transactions.id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(id)
)

[User] Get all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] Show me transactions that were created yesterday.

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

[User] Only show the top 100 results.

[Assistant] SELECT * FROM finance.transactions WHERE processed_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 100;


[User] Get all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Show me customers that were from 2023.

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

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

[Assistant] SELECT created_at, MAX(created_at) AS max_created_at FROM finance.customers GROUP BY created_at;


[User] What are the description, processed_at, status of each loan?

[Assistant] SELECT description, processed_at, status FROM finance.loans;

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

[Assistant] SELECT description, processed_at, status FROM finance.loans WHERE status LIKE 'A%';

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

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


[User] List processed_at, transaction_id, approval_status from loans.

[Assistant] SELECT processed_at, transaction_id, approval_status FROM finance.loans;

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

[Assistant] SELECT processed_at, transaction_id, approval_status FROM finance.loans WHERE processed_at <= CURRENT_DATE - INTERVAL '6 months';

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

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


[User] Display all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Retrieve loans where notes LIKE 'A%'.

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

[User] Can you order these by debit ascending?

[Assistant] SELECT * FROM finance.loans WHERE notes LIKE 'A%' ORDER BY debit ASC;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Group customers by last_login and show the sum of zip_code.

[Assistant] SELECT last_login, SUM(zip_code) AS sum_zip_code FROM finance.customers GROUP BY last_login;


[User] Show me debit, payee_id, status for all loans.

[Assistant] SELECT debit, payee_id, status FROM finance.loans;

[User] Can you order these by debit ascending?

[Assistant] SELECT debit, payee_id, status FROM finance.loans ORDER BY debit ASC;

[User] How many loans are there per debit?

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


[User] What are the notes, transaction_id, processed_at of each loan?

[Assistant] SELECT notes, transaction_id, processed_at FROM finance.loans;

[User] Order the output by payee_id ascending.

[Assistant] SELECT notes, transaction_id, processed_at FROM finance.loans ORDER BY payee_id ASC;

[User] Restrict the output to 10 items.

[Assistant] SELECT notes, transaction_id, processed_at FROM finance.loans ORDER BY payee_id ASC LIMIT 10;


[User] Get description, status, amount from all loans.

[Assistant] SELECT description, status, amount FROM finance.loans;

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

[Assistant] SELECT description, status, amount FROM finance.loans WHERE debit LIKE 'A%';

[User] Tally up loans by processed_at.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE library.accounts (
  invoice_id integer PRIMARY KEY -- unique identifier,
  created_at date,
  reference_number char NOT NULL,
  verification_status text,
  vendor_id text NOT NULL,
  category character varying(256),
  amount decimal,
  exchange_rate text NOT NULL,
  user_id text -- reference to users.customer_id,
  FOREIGN KEY (user_id) REFERENCES users(customer_id)
)

CREATE TABLE library.addresses (
  address_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  category char NOT NULL,
  geo_point char NOT NULL,
  accessibility varchar,
  description char,
  timezone character varying(128) NOT NULL,
  postal_code varchar,
  account_id integer -- reference to accounts.invoice_id,
  FOREIGN KEY (account_id) REFERENCES accounts(invoice_id)
)

CREATE TABLE library.users (
  customer_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  last_active timestamp,
  last_login date,
  timezone character varying(64),
  zip_code character varying(128),
  is_active boolean,
  account_id integer NOT NULL -- reference to accounts.invoice_id,
  FOREIGN KEY (account_id) REFERENCES accounts(invoice_id)
)

[User] Display all addresses.

[Assistant] SELECT * FROM library.addresses;

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

[Assistant] SELECT * FROM library.addresses WHERE postal_code LIKE 'A%';

[User] Can you order these by description descending?

[Assistant] SELECT * FROM library.addresses WHERE postal_code LIKE 'A%' ORDER BY description DESC;


[User] List timezone, is_active, account_id from users.

[Assistant] SELECT timezone, is_active, account_id FROM library.users;

[User] Get users that match is_active = TRUE.

[Assistant] SELECT timezone, is_active, account_id FROM library.users WHERE is_active = TRUE;

[User] Show me sum of zip_code grouped by account_id for users.

[Assistant] SELECT account_id, SUM(zip_code) AS sum_zip_code FROM library.users GROUP BY account_id;


[User] Display all addresses.

[Assistant] SELECT * FROM library.addresses;

[User] Order the output by timezone ascending.

[Assistant] SELECT * FROM library.addresses ORDER BY timezone ASC;

[User] How many addresses are there per category?

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


[User] Show me geo_point, accessibility, description for all addresses.

[Assistant] SELECT geo_point, accessibility, description FROM library.addresses;

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

[Assistant] SELECT geo_point, accessibility, description FROM library.addresses WHERE updated_at > '2023-12-01';

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

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


[User] Get is_active, last_login, zip_code from all users.

[Assistant] SELECT is_active, last_login, zip_code FROM library.users;

[User] Retrieve users where the date is created yesterday.

[Assistant] SELECT is_active, last_login, zip_code FROM library.users WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Can you order these by zip_code descending?

[Assistant] SELECT is_active, last_login, zip_code FROM library.users WHERE updated_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY zip_code DESC;


[User] List all addresses.

[Assistant] SELECT * FROM library.addresses;

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

[Assistant] SELECT * FROM library.addresses WHERE geo_point LIKE 'A%';

[User] Only show the top 100 results.

[Assistant] SELECT * FROM library.addresses WHERE geo_point LIKE 'A%' LIMIT 100;


[User] Show me all addresses.

[Assistant] SELECT * FROM library.addresses;

[User] Can you order these by category descending?

[Assistant] SELECT * FROM library.addresses ORDER BY category DESC;

[User] Order the output by description ascending.

[Assistant] SELECT * FROM library.addresses ORDER BY description ASC;


[User] Show me all addresses.

[Assistant] SELECT * FROM library.addresses;

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

[Assistant] SELECT * FROM library.addresses WHERE description LIKE 'A%';

[User] Sort the results by description descending.

[Assistant] SELECT * FROM library.addresses WHERE description LIKE 'A%' ORDER BY description DESC;


[User] List category, timezone, geo_point from addresses.

[Assistant] SELECT category, timezone, geo_point FROM library.addresses;

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

[Assistant] SELECT category, timezone, geo_point FROM library.addresses WHERE geo_point LIKE 'A%';

[User] Can you order these by timezone ascending?

[Assistant] SELECT category, timezone, geo_point FROM library.addresses WHERE geo_point LIKE 'A%' ORDER BY timezone ASC;


[User] Get all users.

[Assistant] SELECT * FROM library.users;

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

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

[User] Sort the results by timezone descending.

[Assistant] SELECT * FROM library.users WHERE last_login >= CURRENT_DATE - INTERVAL '30 days' ORDER BY timezone 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.notifications (
  payment_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  due_date timestamp without time zone,
  exchange_rate character varying(128),
  approval_status char,
  category character varying(256) NOT NULL,
  invoice_number character varying(256),
  log_id text NOT NULL -- reference to logs.post_id,
  FOREIGN KEY (log_id) REFERENCES logs(post_id)
)

CREATE TABLE tradingplatform.logs (
  post_id text PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  created_at timestamp without time zone,
  message char,
  image_url character varying(64),
  description character varying(128),
  parent_id varchar -- identifier for parent
)

CREATE TABLE tradingplatform.trades (
  payment_id varchar PRIMARY KEY -- unique identifier,
  traded_at timestamp,
  created_at timestamp,
  currency character varying(128),
  delivery_status character varying(128),
  status text
)

[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

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

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

[User] Limit the results to 10 rows.

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


[User] Retrieve all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Can you order these by created_at ascending?

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

[User] Group notifications by category and show the average of category.

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


[User] Display all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

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

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

[User] Group notifications by category and show the min of invoice_number.

[Assistant] SELECT category, MIN(invoice_number) AS min_invoice_number FROM tradingplatform.notifications GROUP BY category;


[User] Retrieve invoice_number, category, created_at for every notification.

[Assistant] SELECT invoice_number, category, created_at FROM tradingplatform.notifications;

[User] Show me payment_id, log_id, edited_at, image_url from notifications and their related logs.

[Assistant] SELECT invoice_number, category, created_at, logs.edited_at, logs.image_url FROM tradingplatform.notifications JOIN tradingplatform.logs ON notifications.log_id = logs.post_id;

[User] Only show the top 50 results.

[Assistant] SELECT invoice_number, category, created_at, logs.edited_at, logs.image_url FROM tradingplatform.notifications JOIN tradingplatform.logs ON notifications.log_id = logs.post_id LIMIT 50;


[User] Get all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Get log_id, due_date, message, description by joining notifications with logs.

[Assistant] SELECT *, logs.message, logs.description FROM tradingplatform.notifications JOIN tradingplatform.logs ON notifications.log_id = logs.post_id;

[User] Limit the results to 10 rows.

[Assistant] SELECT *, logs.message, logs.description FROM tradingplatform.notifications JOIN tradingplatform.logs ON notifications.log_id = logs.post_id LIMIT 10;


[User] Display all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Retrieve due_date, category, created_at, message showing the relationship between notifications and logs.

[Assistant] SELECT *, logs.created_at, logs.message FROM tradingplatform.notifications JOIN tradingplatform.logs ON notifications.log_id = logs.post_id;

[User] Calculate max of payment_id for each approval_status in notifications.

[Assistant] SELECT approval_status, MAX(payment_id) AS max_payment_id FROM tradingplatform.notifications GROUP BY approval_status;


[User] Retrieve exchange_rate, log_id, created_at for every notification.

[Assistant] SELECT exchange_rate, log_id, created_at FROM tradingplatform.notifications;

[User] Retrieve due_date, invoice_number, image_url, message showing the relationship between notifications and logs.

[Assistant] SELECT exchange_rate, log_id, created_at, logs.image_url, logs.message FROM tradingplatform.notifications JOIN tradingplatform.logs ON notifications.log_id = logs.post_id;

[User] Limit the results to 5 rows.

[Assistant] SELECT exchange_rate, log_id, created_at, logs.image_url, logs.message FROM tradingplatform.notifications JOIN tradingplatform.logs ON notifications.log_id = logs.post_id LIMIT 5;


[User] What are the category, log_id, approval_status of each notification?

[Assistant] SELECT category, log_id, approval_status FROM tradingplatform.notifications;

[User] Find notifications where due_date > '2023-01-01'.

[Assistant] SELECT category, log_id, approval_status FROM tradingplatform.notifications WHERE due_date > '2023-01-01';

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

[Assistant] SELECT category, log_id, approval_status FROM tradingplatform.notifications WHERE due_date > '2023-01-01' ORDER BY exchange_rate ASC;


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

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

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

[User] Show me count of exchange_rate grouped by created_at for notifications.

[Assistant] SELECT created_at, COUNT(exchange_rate) AS count_exchange_rate FROM tradingplatform.notifications GROUP BY created_at;


[User] Display all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] List approval_status, category, created_at, parent_id for each notification along with their log information.

[Assistant] SELECT *, logs.created_at, logs.parent_id FROM tradingplatform.notifications JOIN tradingplatform.logs ON notifications.log_id = logs.post_id;

[User] Sort the results by log_id descending.

[Assistant] SELECT *, logs.created_at, logs.parent_id FROM tradingplatform.notifications JOIN tradingplatform.logs ON notifications.log_id = logs.post_id ORDER BY log_id DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.products (
  sku varchar PRIMARY KEY -- unique identifier,
  expires_at timestamp without time zone,
  updated_at timestamp without time zone,
  stock_level character varying(256),
  price numeric(38,14) NOT NULL,
  backorder character varying(64),
  currency text NOT NULL,
  featured_rank char,
  tax_rate character varying(256),
  user_id text NOT NULL -- reference to users.id,
  FOREIGN KEY (user_id) REFERENCES users(id)
)

CREATE TABLE e-commerce.users (
  id text PRIMARY KEY -- unique identifier,
  last_active date,
  api_key text,
  password_hash varchar,
  birth_date timestamp,
  product_id text NOT NULL -- reference to products.sku,
  FOREIGN KEY (product_id) REFERENCES products(sku)
)

[User] List all products.

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

[User] List price, expires_at, api_key, password_hash for each product along with their user information.

[Assistant] SELECT *, users.api_key, users.password_hash FROM e-commerce.products JOIN e-commerce.users ON products.user_id = users.id;

[User] Sort the results by expires_at descending.

[Assistant] SELECT *, users.api_key, users.password_hash FROM e-commerce.products JOIN e-commerce.users ON products.user_id = users.id ORDER BY expires_at DESC;


[User] List all products.

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

[User] Get all products created yesterday.

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

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

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


[User] What are the last_active, product_id, password_hash of each user?

[Assistant] SELECT last_active, product_id, password_hash FROM e-commerce.users;

[User] Find users created yesterday.

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

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

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


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

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

[User] Get all users from last week.

[Assistant] SELECT birth_date, api_key, last_active FROM e-commerce.users WHERE last_active >= CURRENT_DATE - INTERVAL '7 days';

[User] Limit the results to 5 rows.

[Assistant] SELECT birth_date, api_key, last_active FROM e-commerce.users WHERE last_active >= CURRENT_DATE - INTERVAL '7 days' LIMIT 5;


[User] Show me all users.

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

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

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

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

[Assistant] SELECT * FROM e-commerce.users WHERE product_id LIKE 'A%' ORDER BY birth_date ASC;


[User] What are the product_id, password_hash, last_active of each user?

[Assistant] SELECT product_id, password_hash, last_active FROM e-commerce.users;

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

[Assistant] SELECT product_id, password_hash, last_active FROM e-commerce.users WHERE birth_date <= CURRENT_DATE - INTERVAL '6 months';

[User] How many users are there per api_key?

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


[User] Show me all products.

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

[User] Sort the results by featured_rank descending.

[Assistant] SELECT * FROM e-commerce.products ORDER BY featured_rank DESC;

[User] Show only 100 records.

[Assistant] SELECT * FROM e-commerce.products ORDER BY featured_rank DESC LIMIT 100;


[User] List product_id, password_hash, api_key from users.

[Assistant] SELECT product_id, password_hash, api_key FROM e-commerce.users;

[User] Can you order these by password_hash descending?

[Assistant] SELECT product_id, password_hash, api_key FROM e-commerce.users ORDER BY password_hash DESC;

[User] Restrict the output to 20 items.

[Assistant] SELECT product_id, password_hash, api_key FROM e-commerce.users ORDER BY password_hash DESC LIMIT 20;


[User] Display all products.

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

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

[Assistant] SELECT * FROM e-commerce.products ORDER BY backorder ASC;

[User] Show me average of currency grouped by user_id for products.

[Assistant] SELECT user_id, AVERAGE(currency) AS average_currency FROM e-commerce.products GROUP BY user_id;


[User] Get all users.

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

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

[Assistant] SELECT * FROM e-commerce.users ORDER BY product_id ASC;

[User] Get sum of birth_date by password_hash from users.

[Assistant] SELECT password_hash, SUM(birth_date) AS sum_birth_date FROM e-commerce.users GROUP BY password_hash;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.departments (
  message_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at timestamp,
  image_url text,
  author_id text -- identifier for author,
  views text,
  parent_id varchar -- identifier for parent,
  thumbnail char,
  patient_id text -- reference to patients.id,
  FOREIGN KEY (patient_id) REFERENCES patients(id)
)

CREATE TABLE healthcare.prescriptions (
  id integer PRIMARY KEY -- unique identifier,
  cancelled_at date,
  created_at timestamp,
  status character varying(256) NOT NULL,
  delivery_status character varying(256),
  approval_status character varying(256),
  seller_id character varying(128) -- identifier for seller,
  tax smallint,
  currency text NOT NULL,
  amount numeric,
  department_id text NOT NULL -- reference to departments.message_id,
  FOREIGN KEY (department_id) REFERENCES departments(message_id)
)

CREATE TABLE healthcare.patients (
  id text PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at timestamp without time zone,
  website character varying(256) NOT NULL,
  profile_picture_url character varying(128),
  age character varying(64),
  country text
)

[User] Retrieve seller_id, amount, department_id for every prescription.

[Assistant] SELECT seller_id, amount, department_id FROM healthcare.prescriptions;

[User] Find prescriptions older than 6 months.

[Assistant] SELECT seller_id, amount, department_id FROM healthcare.prescriptions WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Only show the top 20 results.

[Assistant] SELECT seller_id, amount, department_id FROM healthcare.prescriptions WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 20;


[User] Get all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Find departments from 2023.

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

[User] How many departments are there per patient_id?

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


[User] Display all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] List departments with dates from last week.

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

[User] Group departments by parent_id and show the min of created_at.

[Assistant] SELECT parent_id, MIN(created_at) AS min_created_at FROM healthcare.departments GROUP BY parent_id;


[User] Display all departments.

[Assistant] SELECT * FROM healthcare.departments;

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

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

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

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


[User] What are the status, delivery_status, cancelled_at of each prescription?

[Assistant] SELECT status, delivery_status, cancelled_at FROM healthcare.prescriptions;

[User] Get all prescriptions older than 6 months.

[Assistant] SELECT status, delivery_status, cancelled_at FROM healthcare.prescriptions WHERE cancelled_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Limit the results to 20 rows.

[Assistant] SELECT status, delivery_status, cancelled_at FROM healthcare.prescriptions WHERE cancelled_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 20;


[User] Show me currency, cancelled_at, tax for all prescriptions.

[Assistant] SELECT currency, cancelled_at, tax FROM healthcare.prescriptions;

[User] Can you order these by tax descending?

[Assistant] SELECT currency, cancelled_at, tax FROM healthcare.prescriptions ORDER BY tax DESC;

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

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


[User] Display all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Retrieve status, tax, created_at, updated_at showing the relationship between prescriptions and departments.

[Assistant] SELECT *, departments.created_at, departments.updated_at FROM healthcare.prescriptions JOIN healthcare.departments ON prescriptions.department_id = departments.message_id;

[User] Calculate min of status for each department_id in prescriptions.

[Assistant] SELECT department_id, MIN(status) AS min_status FROM healthcare.prescriptions GROUP BY department_id;


[User] List all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Find departments from 2023.

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

[User] Order the output by author_id descending.

[Assistant] SELECT * FROM healthcare.departments WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY author_id DESC;


[User] Get department_id, approval_status, status from all prescriptions.

[Assistant] SELECT department_id, approval_status, status FROM healthcare.prescriptions;

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

[Assistant] SELECT department_id, approval_status, status FROM healthcare.prescriptions WHERE approval_status LIKE 'A%';

[User] Show only 15 records.

[Assistant] SELECT department_id, approval_status, status FROM healthcare.prescriptions WHERE approval_status LIKE 'A%' LIMIT 15;


[User] Display all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] List departments with dates from 2023.

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

[User] Order the output by image_url descending.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.products (
  barcode character varying(64) NOT NULL -- unique identifier,
  published_at timestamp without time zone,
  created_at timestamp,
  video_url text -- identifier for video_url,
  backorder character varying(256),
  views text,
  stock_level character varying(128) NOT NULL,
  cost integer,
  price numeric,
  order_id text -- reference to orders.payment_id,
  FOREIGN KEY (order_id) REFERENCES orders(payment_id)
)

CREATE TABLE e-commerce.orders (
  payment_id text PRIMARY KEY -- unique identifier,
  created_at date,
  completed_at timestamp without time zone,
  total numeric(38,14),
  tax decimal
)

CREATE TABLE e-commerce.users (
  user_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at date,
  nationality varchar,
  is_verified boolean NOT NULL,
  profile_picture_url character varying(64) NOT NULL
)

CREATE TABLE e-commerce.reviews (
  message_id integer PRIMARY KEY -- unique identifier,
  edited_at date,
  reply_to_id character varying(256),
  thumbnail character varying(256),
  parent_id character varying(64) -- identifier for parent
)

[User] List all products.

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

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

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

[User] Show me count of cost grouped by created_at for products.

[Assistant] SELECT created_at, COUNT(cost) AS count_cost FROM e-commerce.products GROUP BY created_at;


[User] Display all products.

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

[User] Find products between January and March.

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

[User] Sort the results by published_at ascending.

[Assistant] SELECT * FROM e-commerce.products WHERE published_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY published_at ASC;


[User] List all products.

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

[User] List products with dates from 2023.

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

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

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


[User] Show me created_at, published_at, stock_level for all products.

[Assistant] SELECT created_at, published_at, stock_level FROM e-commerce.products;

[User] List video_url, order_id, total, completed_at for each product along with their order information.

[Assistant] SELECT created_at, published_at, stock_level, orders.total, orders.completed_at FROM e-commerce.products JOIN e-commerce.orders ON products.order_id = orders.payment_id;

[User] How many products are there per published_at?

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


[User] Retrieve all products.

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

[User] What views, order_id, tax, completed_at do we have for products and their associated orders?

[Assistant] SELECT *, orders.tax, orders.completed_at FROM e-commerce.products JOIN e-commerce.orders ON products.order_id = orders.payment_id;

[User] Limit the results to 20 rows.

[Assistant] SELECT *, orders.tax, orders.completed_at FROM e-commerce.products JOIN e-commerce.orders ON products.order_id = orders.payment_id LIMIT 20;


[User] What are the price, published_at, views of each product?

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

[User] List products that have price > 22.

[Assistant] SELECT price, published_at, views FROM e-commerce.products WHERE price > 22;

[User] Show the results sorted by views descending.

[Assistant] SELECT price, published_at, views FROM e-commerce.products WHERE price > 22 ORDER BY views DESC;


[User] List all products.

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

[User] Can you order these by video_url ascending?

[Assistant] SELECT * FROM e-commerce.products ORDER BY video_url ASC;

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

[Assistant] SELECT order_id, MIN(stock_level) AS min_stock_level FROM e-commerce.products GROUP BY order_id;


[User] Show me backorder, views, created_at for all products.

[Assistant] SELECT backorder, views, created_at FROM e-commerce.products;

[User] Get products that match stock_level LIKE 'A%'.

[Assistant] SELECT backorder, views, created_at FROM e-commerce.products WHERE stock_level LIKE 'A%';

[User] Restrict the output to 50 items.

[Assistant] SELECT backorder, views, created_at FROM e-commerce.products WHERE stock_level LIKE 'A%' LIMIT 50;


[User] List barcode, cost, price from products.

[Assistant] SELECT barcode, cost, price FROM e-commerce.products;

[User] Can you order these by published_at descending?

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

[User] Return just 25 rows.

[Assistant] SELECT barcode, cost, price FROM e-commerce.products ORDER BY published_at DESC LIMIT 25;


[User] Show me all products.

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

[User] What cost, barcode, total, created_at do we have for products and their associated orders?

[Assistant] SELECT *, orders.total, orders.created_at FROM e-commerce.products JOIN e-commerce.orders ON products.order_id = orders.payment_id;

[User] Group products by barcode and show the max of cost.

[Assistant] SELECT barcode, MAX(cost) AS max_cost FROM e-commerce.products GROUP BY barcode;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.courses (
  location_id text PRIMARY KEY -- unique identifier,
  last_inspected date,
  created_at timestamp without time zone,
  postal_code character varying(128),
  capacity varchar,
  type character varying(128),
  parking_available character varying(64) NOT NULL,
  longitude character varying(256),
  teacher_id integer -- reference to teachers.content_id,
  FOREIGN KEY (teacher_id) REFERENCES teachers(content_id)
)

CREATE TABLE education.teachers (
  content_id integer PRIMARY KEY -- unique identifier,
  created_at date,
  attachment_url text,
  tags varchar,
  parent_id text -- identifier for parent,
  course_id text NOT NULL -- reference to courses.location_id,
  FOREIGN KEY (course_id) REFERENCES courses(location_id)
)

[User] Show me all courses.

[Assistant] SELECT * FROM education.courses;

[User] Find courses created yesterday.

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

[User] What is the count longitude for each type in courses?

[Assistant] SELECT type, COUNT(longitude) AS count_longitude FROM education.courses GROUP BY type;


[User] Get longitude, teacher_id, type from all courses.

[Assistant] SELECT longitude, teacher_id, type FROM education.courses;

[User] What capacity, parking_available, created_at, parent_id do we have for courses and their associated teachers?

[Assistant] SELECT longitude, teacher_id, type, teachers.created_at, teachers.parent_id FROM education.courses JOIN education.teachers ON courses.teacher_id = teachers.content_id;

[User] Show me count of created_at grouped by created_at for courses.

[Assistant] SELECT created_at, COUNT(created_at) AS count_created_at FROM education.courses GROUP BY created_at;


[User] Get all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

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

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


[User] Show me teacher_id, longitude, type for all courses.

[Assistant] SELECT teacher_id, longitude, type FROM education.courses;

[User] List type, longitude, attachment_url, course_id for each course along with their teacher information.

[Assistant] SELECT teacher_id, longitude, type, teachers.attachment_url, teachers.course_id FROM education.courses JOIN education.teachers ON courses.teacher_id = teachers.content_id;

[User] Sort the results by type descending.

[Assistant] SELECT teacher_id, longitude, type, teachers.attachment_url, teachers.course_id FROM education.courses JOIN education.teachers ON courses.teacher_id = teachers.content_id ORDER BY type DESC;


[User] Show me all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] List teachers with dates from last week.

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

[User] Only show the top 20 results.

[Assistant] SELECT * FROM education.teachers WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 20;


[User] What are the teacher_id, postal_code, parking_available of each course?

[Assistant] SELECT teacher_id, postal_code, parking_available FROM education.courses;

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

[Assistant] SELECT teacher_id, postal_code, parking_available FROM education.courses WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] How many courses are there per capacity?

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


[User] Get all courses.

[Assistant] SELECT * FROM education.courses;

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

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

[User] Tally up courses by parking_available.

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


[User] List all courses.

[Assistant] SELECT * FROM education.courses;

[User] Get courses that match postal_code LIKE 'A%'.

[Assistant] SELECT * FROM education.courses WHERE postal_code LIKE 'A%';

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

[Assistant] SELECT * FROM education.courses WHERE postal_code LIKE 'A%' ORDER BY longitude DESC;


[User] Retrieve attachment_url, parent_id, course_id for every teacher.

[Assistant] SELECT attachment_url, parent_id, course_id FROM education.teachers;

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

[Assistant] SELECT attachment_url, parent_id, course_id FROM education.teachers WHERE tags LIKE 'A%';

[User] Tally up teachers by attachment_url.

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


[User] Show me parking_available, capacity, created_at for all courses.

[Assistant] SELECT parking_available, capacity, created_at FROM education.courses;

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

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

[User] Tally up courses by parking_available.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.followers (
  barcode varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  popularity_score varchar,
  msrp char,
  available varchar,
  comment_id integer -- reference to comments.content_id,
  FOREIGN KEY (comment_id) REFERENCES comments(content_id)
)

CREATE TABLE socialmedia.posts (
  content_id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp without time zone,
  published_at date,
  keywords text,
  shares character varying(64),
  media_url varchar NOT NULL,
  score text,
  thumbnail character varying(256) NOT NULL,
  content text
)

CREATE TABLE socialmedia.comments (
  content_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  subject char,
  thumbnail char,
  shares char,
  follower_id text NOT NULL -- reference to followers.barcode,
  FOREIGN KEY (follower_id) REFERENCES followers(barcode)
)

[User] List all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

[Assistant] SELECT * FROM socialmedia.comments ORDER BY shares DESC;

[User] What is the count subject for each shares in comments?

[Assistant] SELECT shares, COUNT(subject) AS count_subject FROM socialmedia.comments GROUP BY shares;


[User] Show me updated_at, follower_id, shares for all comments.

[Assistant] SELECT updated_at, follower_id, shares FROM socialmedia.comments;

[User] Show me follower_id, updated_at, available, msrp from comments and their related followers.

[Assistant] SELECT updated_at, follower_id, shares, followers.available, followers.msrp FROM socialmedia.comments JOIN socialmedia.followers ON comments.follower_id = followers.barcode;

[User] Calculate count of subject for each follower_id in comments.

[Assistant] SELECT follower_id, COUNT(subject) AS count_subject FROM socialmedia.comments GROUP BY follower_id;


[User] Display all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Sort the results by popularity_score descending.

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

[User] Only show the top 25 results.

[Assistant] SELECT * FROM socialmedia.followers ORDER BY popularity_score DESC LIMIT 25;


[User] Display all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

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

[User] Calculate average of thumbnail for each follower_id in comments.

[Assistant] SELECT follower_id, AVERAGE(thumbnail) AS average_thumbnail FROM socialmedia.comments GROUP BY follower_id;


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

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

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


[User] Show me shares, updated_at, thumbnail for all comments.

[Assistant] SELECT shares, updated_at, thumbnail FROM socialmedia.comments;

[User] Show me comments with subject LIKE 'A%'.

[Assistant] SELECT shares, updated_at, thumbnail FROM socialmedia.comments WHERE subject LIKE 'A%';

[User] What is the max updated_at for each follower_id in comments?

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


[User] Show me all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Get all followers from 2023.

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

[User] What is the count popularity_score for each available in followers?

[Assistant] SELECT available, COUNT(popularity_score) AS count_popularity_score FROM socialmedia.followers GROUP BY available;


[User] List created_at, comment_id, popularity_score from followers.

[Assistant] SELECT created_at, comment_id, popularity_score FROM socialmedia.followers;

[User] List popularity_score, comment_id, follower_id, thumbnail for each follower along with their comment information.

[Assistant] SELECT created_at, comment_id, popularity_score, comments.follower_id, comments.thumbnail FROM socialmedia.followers JOIN socialmedia.comments ON followers.comment_id = comments.content_id;

[User] Order the output by msrp ascending.

[Assistant] SELECT created_at, comment_id, popularity_score, comments.follower_id, comments.thumbnail FROM socialmedia.followers JOIN socialmedia.comments ON followers.comment_id = comments.content_id ORDER BY msrp ASC;


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] List followers with dates created yesterday.

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

[User] What is the max available for each msrp in followers?

[Assistant] SELECT msrp, MAX(available) AS max_available FROM socialmedia.followers GROUP BY msrp;


[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM socialmedia.followers WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 10;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.grades (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  created_at timestamp,
  name character varying(64),
  location_lon character varying(128),
  type character varying(128) NOT NULL,
  coordinates character varying(128) NOT NULL,
  parking_available character varying(128),
  capacity character varying(128),
  category character varying(256) NOT NULL,
  student_id text NOT NULL -- reference to students.employee_id,
  FOREIGN KEY (student_id) REFERENCES students(employee_id)
)

CREATE TABLE education.students (
  employee_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  created_at timestamp,
  first_name char,
  username character varying(256),
  city varchar NOT NULL,
  password_hash varchar
)

[User] Display all grades.

[Assistant] SELECT * FROM education.grades;

[User] Sort the results by created_at descending.

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

[User] Show only 5 records.

[Assistant] SELECT * FROM education.grades ORDER BY created_at DESC LIMIT 5;


[User] Get type, parking_available, created_at from all grades.

[Assistant] SELECT type, parking_available, created_at FROM education.grades;

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

[Assistant] SELECT type, parking_available, created_at FROM education.grades WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Sort the results by updated_at descending.

[Assistant] SELECT type, parking_available, created_at FROM education.grades WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY updated_at DESC;


[User] Display all grades.

[Assistant] SELECT * FROM education.grades;

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

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

[User] Tally up grades by student_id.

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


[User] Retrieve all grades.

[Assistant] SELECT * FROM education.grades;

[User] Get all grades created yesterday.

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

[User] Calculate min of type for each type in grades.

[Assistant] SELECT type, MIN(type) AS min_type FROM education.grades GROUP BY type;


[User] Show me location_lon, category, student_id for all grades.

[Assistant] SELECT location_lon, category, student_id FROM education.grades;

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

[Assistant] SELECT location_lon, category, student_id FROM education.grades WHERE type LIKE 'A%';

[User] Tally up grades by coordinates.

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


[User] Display all grades.

[Assistant] SELECT * FROM education.grades;

[User] List category, parking_available, first_name, created_at for each grade along with their student information.

[Assistant] SELECT *, students.first_name, students.created_at FROM education.grades JOIN education.students ON grades.student_id = students.employee_id;

[User] Order the output by parking_available descending.

[Assistant] SELECT *, students.first_name, students.created_at FROM education.grades JOIN education.students ON grades.student_id = students.employee_id ORDER BY parking_available DESC;


[User] Get all grades.

[Assistant] SELECT * FROM education.grades;

[User] Find grades where category LIKE 'A%'.

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

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

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


[User] Show me parking_available, category, coordinates for all grades.

[Assistant] SELECT parking_available, category, coordinates FROM education.grades;

[User] Show me parking_available, category, username, password_hash from grades and their related students.

[Assistant] SELECT parking_available, category, coordinates, students.username, students.password_hash FROM education.grades JOIN education.students ON grades.student_id = students.employee_id;

[User] Order the output by updated_at ascending.

[Assistant] SELECT parking_available, category, coordinates, students.username, students.password_hash FROM education.grades JOIN education.students ON grades.student_id = students.employee_id ORDER BY updated_at ASC;


[User] List created_at, type, capacity from grades.

[Assistant] SELECT created_at, type, capacity FROM education.grades;

[User] Get all grades between January and March.

[Assistant] SELECT created_at, type, capacity FROM education.grades WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Calculate max of capacity for each coordinates in grades.

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


[User] List all grades.

[Assistant] SELECT * FROM education.grades;

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

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

[User] Show me sum of name grouped by name for grades.

[Assistant] SELECT name, SUM(name) AS sum_name FROM education.grades GROUP BY 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 education.grades (
  invoice_id integer PRIMARY KEY -- unique identifier,
  traded_at timestamp,
  completed_at date,
  seller_id character varying(64) -- identifier for seller,
  status character varying(256),
  card_type character varying(128),
  quantity char,
  currency character varying(128)
)

CREATE TABLE education.teachers (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  delivery_status char,
  approval_status char NOT NULL,
  subtotal numeric(38,14),
  payment_method text
)

CREATE TABLE education.enrollments (
  location_id character varying(64) NOT NULL -- unique identifier,
  last_inspected date,
  created_at timestamp,
  longitude varchar,
  description character varying(256) NOT NULL,
  coordinates char,
  street varchar NOT NULL,
  geo_point character varying(64),
  teacher_id text -- reference to teachers.invoice_id,
  FOREIGN KEY (teacher_id) REFERENCES teachers(invoice_id)
)

[User] Retrieve teacher_id, longitude, created_at for every enrollment.

[Assistant] SELECT teacher_id, longitude, created_at FROM education.enrollments;

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

[Assistant] SELECT teacher_id, longitude, created_at FROM education.enrollments ORDER BY description ASC;

[User] Return just 25 rows.

[Assistant] SELECT teacher_id, longitude, created_at FROM education.enrollments ORDER BY description ASC LIMIT 25;


[User] Retrieve all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] List coordinates, created_at, delivery_status, cancelled_at for each enrollment along with their teacher information.

[Assistant] SELECT *, teachers.delivery_status, teachers.cancelled_at FROM education.enrollments JOIN education.teachers ON enrollments.teacher_id = teachers.invoice_id;

[User] Sort the results by teacher_id descending.

[Assistant] SELECT *, teachers.delivery_status, teachers.cancelled_at FROM education.enrollments JOIN education.teachers ON enrollments.teacher_id = teachers.invoice_id ORDER BY teacher_id DESC;


[User] Show me all enrollments.

[Assistant] SELECT * FROM education.enrollments;

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

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

[User] Show only 100 records.

[Assistant] SELECT * FROM education.enrollments WHERE last_inspected >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 100;


[User] Retrieve created_at, location_id, longitude for every enrollment.

[Assistant] SELECT created_at, location_id, longitude FROM education.enrollments;

[User] List enrollments with dates from last week.

[Assistant] SELECT created_at, location_id, longitude FROM education.enrollments WHERE last_inspected >= CURRENT_DATE - INTERVAL '7 days';

[User] Return just 50 rows.

[Assistant] SELECT created_at, location_id, longitude FROM education.enrollments WHERE last_inspected >= CURRENT_DATE - INTERVAL '7 days' LIMIT 50;


[User] Get location_id, street, created_at from all enrollments.

[Assistant] SELECT location_id, street, created_at FROM education.enrollments;

[User] Show me enrollments with teacher_id LIKE 'A%'.

[Assistant] SELECT location_id, street, created_at FROM education.enrollments WHERE teacher_id LIKE 'A%';

[User] Group enrollments by created_at and show the count of street.

[Assistant] SELECT created_at, COUNT(street) AS count_street FROM education.enrollments GROUP BY created_at;


[User] Get all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Retrieve longitude, location_id, approval_status, cancelled_at showing the relationship between enrollments and teachers.

[Assistant] SELECT *, teachers.approval_status, teachers.cancelled_at FROM education.enrollments JOIN education.teachers ON enrollments.teacher_id = teachers.invoice_id;

[User] Only show the top 10 results.

[Assistant] SELECT *, teachers.approval_status, teachers.cancelled_at FROM education.enrollments JOIN education.teachers ON enrollments.teacher_id = teachers.invoice_id LIMIT 10;


[User] Retrieve coordinates, geo_point, location_id for every enrollment.

[Assistant] SELECT coordinates, geo_point, location_id FROM education.enrollments;

[User] What teacher_id, created_at, approval_status, subtotal do we have for enrollments and their associated teachers?

[Assistant] SELECT coordinates, geo_point, location_id, teachers.approval_status, teachers.subtotal FROM education.enrollments JOIN education.teachers ON enrollments.teacher_id = teachers.invoice_id;

[User] Show me sum of geo_point grouped by street for enrollments.

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


[User] Retrieve geo_point, street, created_at for every enrollment.

[Assistant] SELECT geo_point, street, created_at FROM education.enrollments;

[User] Show the results sorted by description ascending.

[Assistant] SELECT geo_point, street, created_at FROM education.enrollments ORDER BY description ASC;

[User] Limit the results to 15 rows.

[Assistant] SELECT geo_point, street, created_at FROM education.enrollments ORDER BY description ASC LIMIT 15;


[User] Retrieve all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Get all enrollments created yesterday.

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

[User] What is the sum created_at for each teacher_id in enrollments?

[Assistant] SELECT teacher_id, SUM(created_at) AS sum_created_at FROM education.enrollments GROUP BY teacher_id;


[User] Show me all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Retrieve description, last_inspected, payment_method, approval_status showing the relationship between enrollments and teachers.

[Assistant] SELECT *, teachers.payment_method, teachers.approval_status FROM education.enrollments JOIN education.teachers ON enrollments.teacher_id = teachers.invoice_id;

[User] Calculate max of geo_point for each geo_point in enrollments.

[Assistant] SELECT geo_point, MAX(geo_point) AS max_geo_point FROM education.enrollments GROUP BY geo_point;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.metadata (
  id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at timestamp without time zone,
  description character varying(128),
  location_lat varchar NOT NULL,
  accessibility char,
  geo_point character varying(256),
  order_id text NOT NULL -- reference to orders.invoice_id,
  FOREIGN KEY (order_id) REFERENCES orders(invoice_id)
)

CREATE TABLE tradingplatform.logs (
  user_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  email char,
  website character varying(128),
  address character varying(128),
  order_id text -- reference to orders.invoice_id,
  FOREIGN KEY (order_id) REFERENCES orders(invoice_id)
)

CREATE TABLE tradingplatform.orders (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  product_id character varying(256),
  card_type text,
  currency varchar,
  approval_status text,
  seller_id character varying(256) NOT NULL -- identifier for seller,
  delivery_status char NOT NULL
)

CREATE TABLE tradingplatform.trades (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  cancelled_at timestamp,
  currency varchar,
  card_type character varying(256) NOT NULL,
  seller_id character varying(256)
)

[User] Show me last_active, website, email for all logs.

[Assistant] SELECT last_active, website, email FROM tradingplatform.logs;

[User] Find logs between January and March.

[Assistant] SELECT last_active, website, email FROM tradingplatform.logs WHERE last_active BETWEEN '2023-01-01' AND '2023-03-31';

[User] Restrict the output to 15 items.

[Assistant] SELECT last_active, website, email FROM tradingplatform.logs WHERE last_active BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 15;


[User] List all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] List metadata with dates from 2023.

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

[User] Show me sum of created_at grouped by order_id for metadata.

[Assistant] SELECT order_id, SUM(created_at) AS sum_created_at FROM tradingplatform.metadata GROUP BY order_id;


[User] Retrieve all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Find logs between January and March.

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

[User] Tally up logs by order_id.

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


[User] Retrieve all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] List last_active, address, card_type, created_at for each log along with their order information.

[Assistant] SELECT *, orders.card_type, orders.created_at FROM tradingplatform.logs JOIN tradingplatform.orders ON logs.order_id = orders.invoice_id;

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

[Assistant] SELECT *, orders.card_type, orders.created_at FROM tradingplatform.logs JOIN tradingplatform.orders ON logs.order_id = orders.invoice_id ORDER BY order_id DESC;


[User] List all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Sort the results by email ascending.

[Assistant] SELECT * FROM tradingplatform.logs ORDER BY email ASC;

[User] Calculate average of order_id for each address in logs.

[Assistant] SELECT address, AVERAGE(order_id) AS average_order_id FROM tradingplatform.logs GROUP BY address;


[User] Display all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] List location_lat, created_at, created_at, card_type for each metadata along with their order information.

[Assistant] SELECT *, orders.created_at, orders.card_type FROM tradingplatform.metadata JOIN tradingplatform.orders ON metadata.order_id = orders.invoice_id;

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

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


[User] Get all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Get metadata that match order_id LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.metadata WHERE order_id LIKE 'A%';

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

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


[User] Get all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Retrieve email, order_id, product_id, delivery_status showing the relationship between logs and orders.

[Assistant] SELECT *, orders.product_id, orders.delivery_status FROM tradingplatform.logs JOIN tradingplatform.orders ON logs.order_id = orders.invoice_id;

[User] Limit the results to 10 rows.

[Assistant] SELECT *, orders.product_id, orders.delivery_status FROM tradingplatform.logs JOIN tradingplatform.orders ON logs.order_id = orders.invoice_id LIMIT 10;


[User] List geo_point, description, accessibility from metadata.

[Assistant] SELECT geo_point, description, accessibility FROM tradingplatform.metadata;

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

[Assistant] SELECT geo_point, description, accessibility FROM tradingplatform.metadata ORDER BY geo_point DESC;

[User] Limit the results to 10 rows.

[Assistant] SELECT geo_point, description, accessibility FROM tradingplatform.metadata ORDER BY geo_point DESC LIMIT 10;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.posts (
  message_id integer PRIMARY KEY -- unique identifier,
  published_at timestamp,
  visibility text,
  body char,
  thumbnail varchar,
  reply_to_id text -- identifier for reply_to,
  comment_id text -- reference to comments.comment_id,
  FOREIGN KEY (comment_id) REFERENCES comments(comment_id)
)

CREATE TABLE socialmedia.comments (
  comment_id varchar PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  format character varying(256) NOT NULL,
  visibility char,
  attachment_url character varying(64) NOT NULL,
  image_url char,
  post_id integer -- reference to posts.message_id,
  FOREIGN KEY (post_id) REFERENCES posts(message_id)
)

[User] Retrieve all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Get all comments older than 6 months.

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

[User] Show the results sorted by format descending.

[Assistant] SELECT * FROM socialmedia.comments WHERE edited_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY format DESC;


[User] What are the reply_to_id, body, published_at of each post?

[Assistant] SELECT reply_to_id, body, published_at FROM socialmedia.posts;

[User] Find posts where thumbnail LIKE 'A%'.

[Assistant] SELECT reply_to_id, body, published_at FROM socialmedia.posts WHERE thumbnail LIKE 'A%';

[User] Order the output by body descending.

[Assistant] SELECT reply_to_id, body, published_at FROM socialmedia.posts WHERE thumbnail LIKE 'A%' ORDER BY body DESC;


[User] Retrieve all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Show me image_url, attachment_url, visibility, published_at from comments and their related posts.

[Assistant] SELECT *, posts.visibility, posts.published_at FROM socialmedia.comments JOIN socialmedia.posts ON comments.post_id = posts.message_id;

[User] Count the number of comments in each format category.

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


[User] Display all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

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

[User] Return just 50 rows.

[Assistant] SELECT * FROM socialmedia.comments WHERE edited_at > '2023-12-01' LIMIT 50;


[User] What are the image_url, post_id, visibility of each comment?

[Assistant] SELECT image_url, post_id, visibility FROM socialmedia.comments;

[User] Order the output by image_url descending.

[Assistant] SELECT image_url, post_id, visibility FROM socialmedia.comments ORDER BY image_url DESC;

[User] Only show the top 50 results.

[Assistant] SELECT image_url, post_id, visibility FROM socialmedia.comments ORDER BY image_url DESC LIMIT 50;


[User] Retrieve all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

[Assistant] SELECT * FROM socialmedia.comments WHERE visibility LIKE 'A%';

[User] Restrict the output to 20 items.

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


[User] Get all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Get post_id, visibility, comment_id, body by joining comments with posts.

[Assistant] SELECT *, posts.comment_id, posts.body FROM socialmedia.comments JOIN socialmedia.posts ON comments.post_id = posts.message_id;

[User] Limit the results to 10 rows.

[Assistant] SELECT *, posts.comment_id, posts.body FROM socialmedia.comments JOIN socialmedia.posts ON comments.post_id = posts.message_id LIMIT 10;


[User] Get all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

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

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

[Assistant] SELECT * FROM socialmedia.comments WHERE edited_at > '2023-01-01' ORDER BY attachment_url ASC;


[User] List all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

[Assistant] SELECT * FROM socialmedia.comments ORDER BY edited_at DESC;

[User] Tally up comments by post_id.

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


[User] What are the image_url, post_id, format of each comment?

[Assistant] SELECT image_url, post_id, format FROM socialmedia.comments;

[User] List comments that have image_url LIKE 'A%'.

[Assistant] SELECT image_url, post_id, format FROM socialmedia.comments WHERE image_url LIKE 'A%';

[User] Restrict the output to 20 items.

[Assistant] SELECT image_url, post_id, format FROM socialmedia.comments WHERE image_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 finance.customers (
  id text PRIMARY KEY -- unique identifier,
  last_active timestamp,
  joined_at date,
  token char,
  avatar character varying(128),
  display_name text NOT NULL,
  country character varying(64),
  bio character varying(128),
  transaction_id integer -- reference to transactions.transaction_id,
  payment_id text NOT NULL -- reference to payments.invoice_id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(transaction_id),
  FOREIGN KEY (payment_id) REFERENCES payments(invoice_id)
)

CREATE TABLE finance.transactions (
  transaction_id integer PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  updated_at timestamp,
  approval_status character varying(128) NOT NULL,
  currency character varying(128),
  price bigint NOT NULL,
  discount integer NOT NULL,
  total decimal
)

CREATE TABLE finance.payments (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  subtotal numeric(38,14),
  card_type character varying(64),
  payment_status char,
  discount bigint
)

CREATE TABLE finance.accounts (
  payment_id character varying(64) NOT NULL -- unique identifier,
  due_date date,
  category character varying(64),
  notes text,
  user_id varchar -- identifier for user,
  status character varying(64)
)

[User] Get all customers.

[Assistant] SELECT * FROM finance.customers;

[User] What avatar, bio, approval_status, discount do we have for customers and their associated transactions?

[Assistant] SELECT *, transactions.approval_status, transactions.discount FROM finance.customers JOIN finance.transactions ON customers.transaction_id = transactions.transaction_id;

[User] Restrict the output to 10 items.

[Assistant] SELECT *, transactions.approval_status, transactions.discount FROM finance.customers JOIN finance.transactions ON customers.transaction_id = transactions.transaction_id LIMIT 10;


[User] Get avatar, token, country from all customers.

[Assistant] SELECT avatar, token, country FROM finance.customers;

[User] Sort the results by country ascending.

[Assistant] SELECT avatar, token, country FROM finance.customers ORDER BY country ASC;

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

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


[User] Retrieve all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Find customers created yesterday.

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

[User] Only show the top 100 results.

[Assistant] SELECT * FROM finance.customers WHERE joined_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 100;


[User] Retrieve all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Show me payment_id, token, currency, approval_status from customers and their related transactions.

[Assistant] SELECT *, transactions.currency, transactions.approval_status FROM finance.customers JOIN finance.transactions ON customers.transaction_id = transactions.transaction_id;

[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 customers.

[Assistant] SELECT * FROM finance.customers;

[User] Retrieve customers where display_name LIKE 'A%'.

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

[User] Can you order these by joined_at descending?

[Assistant] SELECT * FROM finance.customers WHERE display_name LIKE 'A%' ORDER BY joined_at DESC;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Show me display_name, token, price, updated_at from customers and their related transactions.

[Assistant] SELECT *, transactions.price, transactions.updated_at FROM finance.customers JOIN finance.transactions ON customers.transaction_id = transactions.transaction_id;

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

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


[User] Get display_name, avatar, payment_id from all customers.

[Assistant] SELECT display_name, avatar, payment_id FROM finance.customers;

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

[Assistant] SELECT display_name, avatar, payment_id FROM finance.customers ORDER BY country DESC;

[User] Show me max of last_active grouped by joined_at for customers.

[Assistant] SELECT joined_at, MAX(last_active) AS max_last_active FROM finance.customers GROUP BY joined_at;


[User] List transaction_id, joined_at, bio from customers.

[Assistant] SELECT transaction_id, joined_at, bio FROM finance.customers;

[User] Sort the results by transaction_id descending.

[Assistant] SELECT transaction_id, joined_at, bio FROM finance.customers ORDER BY transaction_id DESC;

[User] Restrict the output to 5 items.

[Assistant] SELECT transaction_id, joined_at, bio FROM finance.customers ORDER BY transaction_id DESC LIMIT 5;


[User] Show me all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Get country, payment_id, cancelled_at, discount by joining customers with transactions.

[Assistant] SELECT *, transactions.cancelled_at, transactions.discount FROM finance.customers JOIN finance.transactions ON customers.transaction_id = transactions.transaction_id;

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

[Assistant] SELECT *, transactions.cancelled_at, transactions.discount FROM finance.customers JOIN finance.transactions ON customers.transaction_id = transactions.transaction_id ORDER BY bio DESC;


[User] List all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Sort the results by bio ascending.

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

[User] What is the sum payment_id for each token in customers?

[Assistant] SELECT token, SUM(payment_id) AS sum_payment_id FROM finance.customers GROUP BY token;


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 (
  address_id integer PRIMARY KEY -- unique identifier,
  last_inspected date,
  street varchar,
  location_lat text,
  address_line2 char,
  follower_id text -- reference to followers.transaction_id,
  FOREIGN KEY (follower_id) REFERENCES followers(transaction_id)
)

CREATE TABLE socialmedia.comments (
  content_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  text character varying(256),
  image_url character varying(64),
  body char,
  visibility char,
  rating character varying(64) NOT NULL,
  score text
)

CREATE TABLE socialmedia.followers (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  processed_at timestamp,
  approval_status varchar,
  vendor_id text,
  invoice_number character varying(64),
  event_id integer NOT NULL -- reference to events.address_id,
  FOREIGN KEY (event_id) REFERENCES events(address_id)
)

[User] Retrieve all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Find events from 2023.

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

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

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


[User] Retrieve approval_status, invoice_number, processed_at for every follower.

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

[User] Order the output by created_at descending.

[Assistant] SELECT approval_status, invoice_number, processed_at FROM socialmedia.followers ORDER BY created_at DESC;

[User] Show only 25 records.

[Assistant] SELECT approval_status, invoice_number, processed_at FROM socialmedia.followers ORDER BY created_at DESC LIMIT 25;


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] List event_id, processed_at, last_inspected, follower_id for each follower along with their event information.

[Assistant] SELECT *, events.last_inspected, events.follower_id FROM socialmedia.followers JOIN socialmedia.events ON followers.event_id = events.address_id;

[User] Order the output by vendor_id descending.

[Assistant] SELECT *, events.last_inspected, events.follower_id FROM socialmedia.followers JOIN socialmedia.events ON followers.event_id = events.address_id ORDER BY vendor_id DESC;


[User] Show me street, last_inspected, address_line2 for all events.

[Assistant] SELECT street, last_inspected, address_line2 FROM socialmedia.events;

[User] Show me events with street LIKE 'A%'.

[Assistant] SELECT street, last_inspected, address_line2 FROM socialmedia.events WHERE street LIKE 'A%';

[User] Order the output by address_line2 ascending.

[Assistant] SELECT street, last_inspected, address_line2 FROM socialmedia.events WHERE street LIKE 'A%' ORDER BY address_line2 ASC;


[User] Show me all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

[User] Show only 10 records.

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


[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

[User] Show the results sorted by vendor_id ascending.

[Assistant] SELECT * FROM socialmedia.followers WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY vendor_id ASC;


[User] Retrieve all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Sort the results by street descending.

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

[User] How many events are there per location_lat?

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


[User] List last_inspected, street, location_lat from events.

[Assistant] SELECT last_inspected, street, location_lat FROM socialmedia.events;

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

[Assistant] SELECT last_inspected, street, location_lat FROM socialmedia.events WHERE address_line2 LIKE 'A%';

[User] Restrict the output to 100 items.

[Assistant] SELECT last_inspected, street, location_lat FROM socialmedia.events WHERE address_line2 LIKE 'A%' LIMIT 100;


[User] Get street, address_line2, location_lat from all events.

[Assistant] SELECT street, address_line2, location_lat FROM socialmedia.events;

[User] What street, address_line2, event_id, created_at do we have for events and their associated followers?

[Assistant] SELECT street, address_line2, location_lat, followers.event_id, followers.created_at FROM socialmedia.events JOIN socialmedia.followers ON events.follower_id = followers.transaction_id;

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

[Assistant] SELECT street, address_line2, location_lat, followers.event_id, followers.created_at FROM socialmedia.events JOIN socialmedia.followers ON events.follower_id = followers.transaction_id ORDER BY address_line2 DESC;


[User] List all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] What follower_id, address_line2, created_at, invoice_number do we have for events and their associated followers?

[Assistant] SELECT *, followers.created_at, followers.invoice_number FROM socialmedia.events JOIN socialmedia.followers ON events.follower_id = followers.transaction_id;

[User] Return just 15 rows.

[Assistant] SELECT *, followers.created_at, followers.invoice_number FROM socialmedia.events JOIN socialmedia.followers ON events.follower_id = followers.transaction_id LIMIT 15;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.inventory (
  item_id character varying(64) NOT NULL -- unique identifier,
  expires_at timestamp without time zone,
  created_at timestamp,
  brand character varying(256),
  price decimal,
  video_url character varying(64),
  views varchar,
  category character varying(256)
)

CREATE TABLE e-commerce.products (
  sku character varying(64) NOT NULL -- unique identifier,
  published_at date,
  subcategory character varying(64),
  brand character varying(128),
  discount smallint,
  video_url character varying(128) NOT NULL,
  manufacturer character varying(64),
  cost smallint,
  image_url varchar
)

CREATE TABLE e-commerce.order_items (
  message_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  created_at date,
  categories varchar NOT NULL,
  title character varying(256),
  user_id text NOT NULL -- identifier for user,
  visibility character varying(64) NOT NULL,
  media_url character varying(256)
)

[User] What are the discount, sku, cost of each product?

[Assistant] SELECT discount, sku, cost FROM e-commerce.products;

[User] List products with dates from 2023.

[Assistant] SELECT discount, sku, cost FROM e-commerce.products WHERE published_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Show only 100 records.

[Assistant] SELECT discount, sku, cost FROM e-commerce.products WHERE published_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 100;


[User] Retrieve brand, discount, video_url for every product.

[Assistant] SELECT brand, discount, video_url FROM e-commerce.products;

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

[Assistant] SELECT brand, discount, video_url FROM e-commerce.products WHERE brand LIKE 'A%';

[User] Sort the results by brand descending.

[Assistant] SELECT brand, discount, video_url FROM e-commerce.products WHERE brand LIKE 'A%' ORDER BY brand DESC;


[User] Get all products.

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

[User] Show me products with published_at > '2023-01-01'.

[Assistant] SELECT * FROM e-commerce.products WHERE published_at > '2023-01-01';

[User] Return just 5 rows.

[Assistant] SELECT * FROM e-commerce.products WHERE published_at > '2023-01-01' LIMIT 5;


[User] Get all inventory.

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

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

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

[User] Show me min of price grouped by views for inventory.

[Assistant] SELECT views, MIN(price) AS min_price FROM e-commerce.inventory GROUP BY views;


[User] Show me brand, price, created_at for all inventory.

[Assistant] SELECT brand, price, created_at FROM e-commerce.inventory;

[User] Sort the results by created_at descending.

[Assistant] SELECT brand, price, created_at FROM e-commerce.inventory ORDER BY created_at DESC;

[User] Group inventory by expires_at and show the count of video_url.

[Assistant] SELECT expires_at, COUNT(video_url) AS count_video_url FROM e-commerce.inventory GROUP BY expires_at;


[User] Get all order_items.

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

[User] Sort the results by categories descending.

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

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

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


[User] Retrieve all order_items.

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

[User] Show me order_items with message_id LIKE 'A%'.

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

[User] Calculate count of updated_at for each message_id in order_items.

[Assistant] SELECT message_id, COUNT(updated_at) AS count_updated_at FROM e-commerce.order_items GROUP BY message_id;


[User] Retrieve media_url, user_id, title for every order_item.

[Assistant] SELECT media_url, user_id, title FROM e-commerce.order_items;

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

[Assistant] SELECT media_url, user_id, title FROM e-commerce.order_items ORDER BY created_at ASC;

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

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


[User] Get brand, item_id, created_at from all inventory.

[Assistant] SELECT brand, item_id, created_at FROM e-commerce.inventory;

[User] Show me inventory with video_url LIKE 'A%'.

[Assistant] SELECT brand, item_id, created_at FROM e-commerce.inventory WHERE video_url LIKE 'A%';

[User] Show me the count of inventory grouped by expires_at.

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


[User] List all inventory.

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

[User] Show the results sorted by category ascending.

[Assistant] SELECT * FROM e-commerce.inventory ORDER BY category ASC;

[User] Count the number of inventory in each brand category.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE travel.purchases (
  id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  cancelled_at timestamp without time zone,
  card_type char,
  product_id text,
  approval_status character varying(256) NOT NULL,
  total smallint,
  user_id varchar NOT NULL -- identifier for user,
  payment_method varchar NOT NULL,
  facilitie_id text NOT NULL -- reference to facilities.address_id,
  FOREIGN KEY (facilitie_id) REFERENCES facilities(address_id)
)

CREATE TABLE travel.facilities (
  address_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  description character varying(64),
  accessibility character varying(128),
  zip_code character varying(64) NOT NULL,
  type character varying(256),
  postal_code character varying(64) NOT NULL,
  member_id text NOT NULL -- reference to members.id,
  FOREIGN KEY (member_id) REFERENCES members(id)
)

CREATE TABLE travel.members (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  joined_at date,
  last_name varchar NOT NULL,
  first_name character varying(64),
  full_name character varying(128),
  state text,
  is_active boolean NOT NULL -- indicates if active is true,
  display_name char
)

[User] Show me all facilities.

[Assistant] SELECT * FROM travel.facilities;

[User] List description, accessibility, display_name, updated_at for each facilitie along with their member information.

[Assistant] SELECT *, members.display_name, members.updated_at FROM travel.facilities JOIN travel.members ON facilities.member_id = members.id;

[User] Sort the results by postal_code descending.

[Assistant] SELECT *, members.display_name, members.updated_at FROM travel.facilities JOIN travel.members ON facilities.member_id = members.id ORDER BY postal_code DESC;


[User] Display all facilities.

[Assistant] SELECT * FROM travel.facilities;

[User] Get zip_code, updated_at, display_name, state by joining facilities with members.

[Assistant] SELECT *, members.display_name, members.state FROM travel.facilities JOIN travel.members ON facilities.member_id = members.id;

[User] How many facilities are there per member_id?

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


[User] Display all purchases.

[Assistant] SELECT * FROM travel.purchases;

[User] Retrieve user_id, payment_method, type, member_id showing the relationship between purchases and facilities.

[Assistant] SELECT *, facilities.type, facilities.member_id FROM travel.purchases JOIN travel.facilities ON purchases.facilitie_id = facilities.address_id;

[User] Calculate average of id for each card_type in purchases.

[Assistant] SELECT card_type, AVERAGE(id) AS average_id FROM travel.purchases GROUP BY card_type;


[User] List user_id, approval_status, id from purchases.

[Assistant] SELECT user_id, approval_status, id FROM travel.purchases;

[User] Retrieve purchases where payment_method LIKE 'A%'.

[Assistant] SELECT user_id, approval_status, id FROM travel.purchases WHERE payment_method LIKE 'A%';

[User] Show only 25 records.

[Assistant] SELECT user_id, approval_status, id FROM travel.purchases WHERE payment_method LIKE 'A%' LIMIT 25;


[User] List all purchases.

[Assistant] SELECT * FROM travel.purchases;

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

[Assistant] SELECT * FROM travel.purchases ORDER BY id ASC;

[User] Only show the top 5 results.

[Assistant] SELECT * FROM travel.purchases ORDER BY id ASC LIMIT 5;