[User] Retrieve profile_picture_url, state, avatar for every user.

[Assistant] SELECT profile_picture_url, state, avatar FROM tradingplatform.users;

[User] Find users where order_id LIKE 'A%'.

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

[User] Sort the results by last_active ascending.

[Assistant] SELECT profile_picture_url, state, avatar FROM tradingplatform.users WHERE order_id LIKE 'A%' ORDER BY last_active ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.orders (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  traded_at timestamp,
  seller_id varchar -- identifier for seller,
  total numeric(38,14) NOT NULL,
  account_id character varying(64) NOT NULL
)

CREATE TABLE tradingplatform.users (
  person_id text PRIMARY KEY -- unique identifier,
  last_active timestamp,
  created_at timestamp without time zone,
  avatar character varying(64),
  state character varying(256),
  profile_picture_url varchar,
  order_id text -- reference to orders.invoice_id,
  FOREIGN KEY (order_id) REFERENCES orders(invoice_id)
)

CREATE TABLE tradingplatform.logs (
  store_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  created_at date,
  latitude char NOT NULL,
  location_lat character varying(256),
  street varchar,
  order_id text NOT NULL -- reference to orders.invoice_id,
  FOREIGN KEY (order_id) REFERENCES orders(invoice_id)
)

[User] Retrieve store_id, latitude, location_lat for every log.

[Assistant] SELECT store_id, latitude, location_lat FROM tradingplatform.logs;

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

[Assistant] SELECT store_id, latitude, location_lat FROM tradingplatform.logs ORDER BY order_id ASC;

[User] Order the output by location_lat ascending.

[Assistant] SELECT store_id, latitude, location_lat FROM tradingplatform.logs ORDER BY location_lat ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.grades (
  message_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  published_at timestamp,
  user_id character varying(256) NOT NULL,
  media_url character varying(64) NOT NULL,
  views character varying(256),
  description character varying(256)
)

CREATE TABLE education.assignments (
  venue_id character varying(64) NOT NULL -- unique identifier,
  last_inspected timestamp without time zone,
  state character varying(128),
  street char,
  timezone character varying(64) NOT NULL,
  address_line1 text,
  location_lat varchar,
  grade_id text NOT NULL -- reference to grades.message_id,
  FOREIGN KEY (grade_id) REFERENCES grades(message_id)
)

CREATE TABLE education.students (
  user_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  membership_level varchar NOT NULL,
  status char,
  birth_date date,
  address character varying(256) NOT NULL,
  grade_id text NOT NULL -- reference to grades.message_id,
  FOREIGN KEY (grade_id) REFERENCES grades(message_id)
)

[User] Get birth_date, address, status from all students.

[Assistant] SELECT birth_date, address, status FROM education.students;

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

[Assistant] SELECT birth_date, address, status FROM education.students WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Tally up students by grade_id.

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


[User] List grade_id, timezone, street from assignments.

[Assistant] SELECT grade_id, timezone, street FROM education.assignments;

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

[Assistant] SELECT grade_id, timezone, street FROM education.assignments WHERE last_inspected BETWEEN '2023-01-01' AND '2023-03-31';

[User] Show me the count of assignments grouped by last_inspected.

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


[User] List grade_id, address, status from students.

[Assistant] SELECT grade_id, address, status FROM education.students;

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

[Assistant] SELECT grade_id, address, status FROM education.students WHERE updated_at > '2023-01-01';

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

[Assistant] SELECT grade_id, address, status FROM education.students WHERE updated_at > '2023-01-01' ORDER BY status ASC;


[User] Retrieve updated_at, address, grade_id for every student.

[Assistant] SELECT updated_at, address, grade_id FROM education.students;

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

[Assistant] SELECT updated_at, address, grade_id FROM education.students WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Show the results sorted by updated_at ascending.

[Assistant] SELECT updated_at, address, grade_id FROM education.students WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY updated_at ASC;


[User] List all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Show the results sorted by timezone descending.

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

[User] Only show the top 20 results.

[Assistant] SELECT * FROM education.assignments ORDER BY timezone DESC LIMIT 20;


[User] Show me membership_level, address, updated_at for all students.

[Assistant] SELECT membership_level, address, updated_at FROM education.students;

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

[Assistant] SELECT membership_level, address, updated_at FROM education.students WHERE membership_level LIKE 'A%';

[User] Show me count of grade_id grouped by address for students.

[Assistant] SELECT address, COUNT(grade_id) AS count_grade_id FROM education.students GROUP BY address;


[User] Show me last_inspected, timezone, street for all assignments.

[Assistant] SELECT last_inspected, timezone, street FROM education.assignments;

[User] Show me assignments with location_lat LIKE 'A%'.

[Assistant] SELECT last_inspected, timezone, street FROM education.assignments WHERE location_lat LIKE 'A%';

[User] Can you order these by street ascending?

[Assistant] SELECT last_inspected, timezone, street FROM education.assignments WHERE location_lat LIKE 'A%' ORDER BY street ASC;


[User] Retrieve address, birth_date, membership_level for every student.

[Assistant] SELECT address, birth_date, membership_level FROM education.students;

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

[Assistant] SELECT address, birth_date, membership_level FROM education.students WHERE birth_date <= CURRENT_DATE - INTERVAL '6 months';

[User] Get the distribution of students across different user_id values.

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


[User] List all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] What grade_id, last_inspected, created_at, media_url do we have for assignments and their associated grades?

[Assistant] SELECT *, grades.created_at, grades.media_url FROM education.assignments JOIN education.grades ON assignments.grade_id = grades.message_id;

[User] Sort the results by street descending.

[Assistant] SELECT *, grades.created_at, grades.media_url FROM education.assignments JOIN education.grades ON assignments.grade_id = grades.message_id ORDER BY street DESC;


[User] Get all students.

[Assistant] SELECT * FROM education.students;

[User] List updated_at, address, media_url, views for each student along with their grade information.

[Assistant] SELECT *, grades.media_url, grades.views FROM education.students JOIN education.grades ON students.grade_id = grades.message_id;

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE music.articles (
  id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  updated_at timestamp,
  attachment_url varchar,
  parent_id character varying(128) NOT NULL,
  tags char,
  content character varying(64),
  subject char
)

CREATE TABLE music.transactions (
  order_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  completed_at timestamp,
  buyer_id character varying(64) NOT NULL,
  payment_method char NOT NULL,
  subtotal smallint,
  product_id character varying(64) NOT NULL,
  user_id character varying(128),
  amount numeric,
  article_id text NOT NULL -- reference to articles.id,
  FOREIGN KEY (article_id) REFERENCES articles(id)
)

[User] What are the payment_method, subtotal, product_id of each transaction?

[Assistant] SELECT payment_method, subtotal, product_id FROM music.transactions;

[User] Get all transactions between January and March.

[Assistant] SELECT payment_method, subtotal, product_id FROM music.transactions WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Group transactions by completed_at and show the sum of order_id.

[Assistant] SELECT completed_at, SUM(order_id) AS sum_order_id FROM music.transactions GROUP BY completed_at;


[User] Get payment_method, subtotal, user_id from all transactions.

[Assistant] SELECT payment_method, subtotal, user_id FROM music.transactions;

[User] Show the results sorted by completed_at ascending.

[Assistant] SELECT payment_method, subtotal, user_id FROM music.transactions ORDER BY completed_at ASC;

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

[Assistant] SELECT payment_method, subtotal, user_id FROM music.transactions ORDER BY amount DESC;


[User] Get all transactions.

[Assistant] SELECT * FROM music.transactions;

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

[Assistant] SELECT * FROM music.transactions WHERE user_id LIKE 'A%';

[User] Return just 5 rows.

[Assistant] SELECT * FROM music.transactions WHERE user_id LIKE 'A%' LIMIT 5;


[User] Get amount, article_id, product_id from all transactions.

[Assistant] SELECT amount, article_id, product_id FROM music.transactions;

[User] Get all transactions from 2023.

[Assistant] SELECT amount, article_id, product_id FROM music.transactions WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Return just 10 rows.

[Assistant] SELECT amount, article_id, product_id FROM music.transactions WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 10;


[User] List user_id, product_id, buyer_id from transactions.

[Assistant] SELECT user_id, product_id, buyer_id FROM music.transactions;

[User] Order the output by subtotal ascending.

[Assistant] SELECT user_id, product_id, buyer_id FROM music.transactions ORDER BY subtotal ASC;

[User] Show the results sorted by product_id descending.

[Assistant] SELECT user_id, product_id, buyer_id FROM music.transactions ORDER BY product_id DESC;


[User] List order_id, user_id, payment_method from transactions.

[Assistant] SELECT order_id, user_id, payment_method FROM music.transactions;

[User] What buyer_id, subtotal, attachment_url, subject do we have for transactions and their associated articles?

[Assistant] SELECT order_id, user_id, payment_method, articles.attachment_url, articles.subject FROM music.transactions JOIN music.articles ON transactions.article_id = articles.id;

[User] Order the output by user_id ascending.

[Assistant] SELECT order_id, user_id, payment_method, articles.attachment_url, articles.subject FROM music.transactions JOIN music.articles ON transactions.article_id = articles.id ORDER BY user_id ASC;


[User] List all transactions.

[Assistant] SELECT * FROM music.transactions;

[User] Order the output by article_id descending.

[Assistant] SELECT * FROM music.transactions ORDER BY article_id DESC;

[User] Limit the results to 100 rows.

[Assistant] SELECT * FROM music.transactions ORDER BY article_id DESC LIMIT 100;


[User] What are the amount, completed_at, payment_method of each transaction?

[Assistant] SELECT amount, completed_at, payment_method FROM music.transactions;

[User] Get transactions that match amount > 12.

[Assistant] SELECT amount, completed_at, payment_method FROM music.transactions WHERE amount > 12;

[User] How many transactions are there per payment_method?

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


[User] Get order_id, subtotal, payment_method from all transactions.

[Assistant] SELECT order_id, subtotal, payment_method FROM music.transactions;

[User] List article_id, amount, attachment_url, content for each transaction along with their article information.

[Assistant] SELECT order_id, subtotal, payment_method, articles.attachment_url, articles.content FROM music.transactions JOIN music.articles ON transactions.article_id = articles.id;

[User] Group transactions by buyer_id and show the max of product_id.

[Assistant] SELECT buyer_id, MAX(product_id) AS max_product_id FROM music.transactions GROUP BY buyer_id;


[User] Display all transactions.

[Assistant] SELECT * FROM music.transactions;

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

[Assistant] SELECT * FROM music.transactions ORDER BY completed_at DESC;

[User] Group transactions by product_id and show the sum of updated_at.

[Assistant] SELECT product_id, SUM(updated_at) AS sum_updated_at FROM music.transactions GROUP BY product_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.followers (
  barcode text PRIMARY KEY -- unique identifier,
  expires_at date,
  created_at timestamp without time zone,
  available character varying(64),
  popularity_score character varying(64) NOT NULL,
  rating text,
  currency character varying(256),
  group_id text NOT NULL -- reference to groups.post_id,
  FOREIGN KEY (group_id) REFERENCES groups(post_id)
)

CREATE TABLE socialmedia.events (
  post_id character varying(64) NOT NULL -- unique identifier,
  published_at date,
  author_id character varying(128) -- identifier for author,
  body character varying(256),
  parent_id character varying(128) -- identifier for parent,
  follower_id text -- reference to followers.barcode,
  FOREIGN KEY (follower_id) REFERENCES followers(barcode)
)

CREATE TABLE socialmedia.groups (
  post_id text PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  thumbnail character varying(64),
  shares char,
  content character varying(128),
  attachment_url character varying(128) NOT NULL
)

[User] Show me author_id, parent_id, published_at for all events.

[Assistant] SELECT author_id, parent_id, published_at FROM socialmedia.events;

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

[Assistant] SELECT author_id, parent_id, published_at FROM socialmedia.events ORDER BY parent_id DESC;

[User] Group events by follower_id and show the min of follower_id.

[Assistant] SELECT follower_id, MIN(follower_id) AS min_follower_id FROM socialmedia.events GROUP BY follower_id;


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Retrieve followers where rating LIKE 'A%'.

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

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

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


[User] Get expires_at, available, created_at from all followers.

[Assistant] SELECT expires_at, available, created_at FROM socialmedia.followers;

[User] Sort the results by created_at ascending.

[Assistant] SELECT expires_at, available, created_at FROM socialmedia.followers ORDER BY created_at ASC;

[User] Show me the count of followers grouped by group_id.

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


[User] Retrieve expires_at, currency, rating for every follower.

[Assistant] SELECT expires_at, currency, rating FROM socialmedia.followers;

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

[Assistant] SELECT expires_at, currency, rating FROM socialmedia.followers ORDER BY created_at DESC;

[User] What is the min group_id for each currency in followers?

[Assistant] SELECT currency, MIN(group_id) AS min_group_id FROM socialmedia.followers GROUP BY currency;


[User] Retrieve all events.

[Assistant] SELECT * FROM socialmedia.events;

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

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

[User] How many events are there per author_id?

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


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show me available, rating, thumbnail, content from followers and their related groups.

[Assistant] SELECT *, groups.thumbnail, groups.content FROM socialmedia.followers JOIN socialmedia.groups ON followers.group_id = groups.post_id;

[User] Get count of expires_at by available from followers.

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


[User] Retrieve currency, expires_at, available for every follower.

[Assistant] SELECT currency, expires_at, available FROM socialmedia.followers;

[User] Show the results sorted by popularity_score ascending.

[Assistant] SELECT currency, expires_at, available FROM socialmedia.followers ORDER BY popularity_score ASC;

[User] Tally up followers by currency.

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


[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

[User] Show me the count of followers grouped by rating.

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


[User] List body, published_at, parent_id from events.

[Assistant] SELECT body, published_at, parent_id FROM socialmedia.events;

[User] What follower_id, body, rating, popularity_score do we have for events and their associated followers?

[Assistant] SELECT body, published_at, parent_id, followers.rating, followers.popularity_score FROM socialmedia.events JOIN socialmedia.followers ON events.follower_id = followers.barcode;

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

[Assistant] SELECT body, published_at, parent_id, followers.rating, followers.popularity_score FROM socialmedia.events JOIN socialmedia.followers ON events.follower_id = followers.barcode ORDER BY follower_id ASC;


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Sort the results by expires_at ascending.

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

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

[Assistant] SELECT popularity_score, MIN(popularity_score) AS min_popularity_score FROM socialmedia.followers GROUP BY popularity_score;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.wallets (
  account_id varchar PRIMARY KEY -- unique identifier,
  due_date timestamp,
  updated_at timestamp,
  approval_status text NOT NULL,
  credit character varying(128) NOT NULL,
  verification_status character varying(64) NOT NULL,
  reconciliation_status text,
  asset_id integer NOT NULL -- reference to assets.sku,
  FOREIGN KEY (asset_id) REFERENCES assets(sku)
)

CREATE TABLE tradingplatform.assets (
  sku integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  published_at timestamp without time zone,
  thumbnail_url character varying(64),
  title char,
  featured_rank character varying(64) NOT NULL,
  price bigint NOT NULL,
  views varchar,
  wallet_id text NOT NULL -- reference to wallets.account_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(account_id)
)

CREATE TABLE tradingplatform.notifications (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  completed_at timestamp,
  payment_status character varying(256),
  subtotal numeric(38,14) NOT NULL,
  approval_status character varying(64),
  currency text,
  asset_id integer NOT NULL -- reference to assets.sku,
  FOREIGN KEY (asset_id) REFERENCES assets(sku)
)

[User] List all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Order the output by wallet_id descending.

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

[User] Limit the results to 5 rows.

[Assistant] SELECT * FROM tradingplatform.assets ORDER BY wallet_id DESC LIMIT 5;


[User] Retrieve all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Retrieve thumbnail_url, wallet_id, reconciliation_status, approval_status showing the relationship between assets and wallets.

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

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

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


[User] Retrieve all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] List approval_status, currency, thumbnail_url, price for each notification along with their asset information.

[Assistant] SELECT *, assets.thumbnail_url, assets.price FROM tradingplatform.notifications JOIN tradingplatform.assets ON notifications.asset_id = assets.sku;

[User] Tally up notifications by subtotal.

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


[User] Get all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Order the output by credit ascending.

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

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

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


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] List notifications with dates from 2023.

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

[User] Calculate count of payment_status for each approval_status in notifications.

[Assistant] SELECT approval_status, COUNT(payment_status) AS count_payment_status FROM tradingplatform.notifications GROUP BY approval_status;


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Order the output by subtotal descending.

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

[User] Show the results sorted by completed_at ascending.

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


[User] Retrieve all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Show me verification_status, asset_id, created_at, published_at from wallets and their related assets.

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

[User] Show the results sorted by reconciliation_status descending.

[Assistant] SELECT *, assets.created_at, assets.published_at FROM tradingplatform.wallets JOIN tradingplatform.assets ON wallets.asset_id = assets.sku ORDER BY reconciliation_status DESC;


[User] Show me payment_status, subtotal, asset_id for all notifications.

[Assistant] SELECT payment_status, subtotal, asset_id FROM tradingplatform.notifications;

[User] Show the results sorted by completed_at descending.

[Assistant] SELECT payment_status, subtotal, asset_id FROM tradingplatform.notifications ORDER BY completed_at DESC;

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

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


[User] List all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Get credit, updated_at, thumbnail_url, featured_rank by joining wallets with assets.

[Assistant] SELECT *, assets.thumbnail_url, assets.featured_rank FROM tradingplatform.wallets JOIN tradingplatform.assets ON wallets.asset_id = assets.sku;

[User] What is the average reconciliation_status for each due_date in wallets?

[Assistant] SELECT due_date, AVERAGE(reconciliation_status) AS average_reconciliation_status FROM tradingplatform.wallets GROUP BY due_date;


[User] Get created_at, published_at, featured_rank from all assets.

[Assistant] SELECT created_at, published_at, featured_rank FROM tradingplatform.assets;

[User] Get all assets from 2023.

[Assistant] SELECT created_at, published_at, featured_rank FROM tradingplatform.assets WHERE published_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Show the results sorted by title descending.

[Assistant] SELECT created_at, published_at, featured_rank FROM tradingplatform.assets WHERE published_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY title DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.assets (
  barcode text PRIMARY KEY -- unique identifier,
  published_at date,
  views text,
  description char,
  title character varying(64),
  quantity character varying(256),
  log_id integer NOT NULL -- reference to logs.id,
  notification_id text -- reference to notifications.sku,
  FOREIGN KEY (log_id) REFERENCES logs(id),
  FOREIGN KEY (notification_id) REFERENCES notifications(sku)
)

CREATE TABLE tradingplatform.users (
  employee_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  joined_at timestamp,
  email character varying(256),
  last_name text,
  status character varying(64),
  bio character varying(128) NOT NULL,
  is_verified bit,
  state varchar,
  log_id integer NOT NULL -- reference to logs.id,
  FOREIGN KEY (log_id) REFERENCES logs(id)
)

CREATE TABLE tradingplatform.logs (
  id integer PRIMARY KEY -- unique identifier,
  last_active timestamp,
  profile_picture_url character varying(256) NOT NULL,
  display_name char NOT NULL,
  is_verified boolean -- indicates if verified is true,
  age character varying(256)
)

CREATE TABLE tradingplatform.notifications (
  sku text PRIMARY KEY -- unique identifier,
  expires_at timestamp without time zone,
  backorder varchar NOT NULL,
  video_url character varying(256) -- identifier for video_url,
  popularity_score text,
  asset_id text -- reference to assets.barcode,
  FOREIGN KEY (asset_id) REFERENCES assets(barcode)
)

[User] Display all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

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

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

[User] Limit the results to 5 rows.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE expires_at > '2023-12-01' LIMIT 5;


[User] Retrieve all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Find assets where log_id > 82.

[Assistant] SELECT * FROM tradingplatform.assets WHERE log_id > 82;

[User] Tally up assets by quantity.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.enrollments (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  title character varying(256) NOT NULL,
  cost smallint,
  video_url varchar NOT NULL,
  reserved character varying(64) NOT NULL,
  discount smallint,
  brand text
)

CREATE TABLE education.assignments (
  payment_id character varying(64) NOT NULL -- unique identifier,
  traded_at timestamp without time zone,
  completed_at timestamp,
  amount bigint,
  payment_method char,
  seller_id character varying(128) -- identifier for seller,
  approval_status char,
  department_id text -- reference to departments.user_id,
  student_id integer NOT NULL -- reference to students.id,
  FOREIGN KEY (department_id) REFERENCES departments(user_id),
  FOREIGN KEY (student_id) REFERENCES students(id)
)

CREATE TABLE education.departments (
  user_id text PRIMARY KEY -- unique identifier,
  last_active timestamp,
  created_at timestamp without time zone,
  email character varying(64),
  token character varying(256),
  website char,
  nationality character varying(64) NOT NULL,
  age text NOT NULL
)

CREATE TABLE education.students (
  id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  website varchar,
  salt character varying(128)
)

[User] Get all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] List assignments that have payment_method LIKE 'A%'.

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

[User] How many assignments are there per department_id?

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


[User] What are the approval_status, completed_at, payment_method of each assignment?

[Assistant] SELECT approval_status, completed_at, payment_method FROM education.assignments;

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

[Assistant] SELECT approval_status, completed_at, payment_method FROM education.assignments WHERE completed_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Count the number of assignments in each seller_id category.

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


[User] What are the amount, payment_id, department_id of each assignment?

[Assistant] SELECT amount, payment_id, department_id FROM education.assignments;

[User] Sort the results by student_id descending.

[Assistant] SELECT amount, payment_id, department_id FROM education.assignments ORDER BY student_id DESC;

[User] Restrict the output to 5 items.

[Assistant] SELECT amount, payment_id, department_id FROM education.assignments ORDER BY student_id DESC LIMIT 5;


[User] Retrieve all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Order the output by seller_id descending.

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

[User] Show only 10 records.

[Assistant] SELECT * FROM education.assignments ORDER BY seller_id DESC LIMIT 10;


[User] Show me all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Get assignments that match completed_at > '2023-01-01'.

[Assistant] SELECT * FROM education.assignments WHERE completed_at > '2023-01-01';

[User] Only show the top 15 results.

[Assistant] SELECT * FROM education.assignments WHERE completed_at > '2023-01-01' LIMIT 15;


[User] List all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Show the results sorted by amount ascending.

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

[User] Get the distribution of assignments across different student_id values.

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


[User] What are the traded_at, completed_at, seller_id of each assignment?

[Assistant] SELECT traded_at, completed_at, seller_id FROM education.assignments;

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

[Assistant] SELECT traded_at, completed_at, seller_id FROM education.assignments WHERE completed_at > '2023-12-01';

[User] Get average of payment_method by payment_method from assignments.

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


[User] Get all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Show me assignments with amount > 13.

[Assistant] SELECT * FROM education.assignments WHERE amount > 13;

[User] Show me the count of assignments grouped by traded_at.

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


[User] Get all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Retrieve student_id, traded_at, token, email showing the relationship between assignments and departments.

[Assistant] SELECT *, departments.token, departments.email FROM education.assignments JOIN education.departments ON assignments.department_id = departments.user_id;

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

[Assistant] SELECT *, departments.token, departments.email FROM education.assignments JOIN education.departments ON assignments.department_id = departments.user_id ORDER BY student_id DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.events (
  address_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  accessibility varchar NOT NULL,
  timezone character varying(64) NOT NULL,
  type char,
  address_line1 varchar,
  name character varying(128)
)

CREATE TABLE socialmedia.users (
  user_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  updated_at date,
  password_hash character varying(128),
  website character varying(128),
  zip_code char NOT NULL,
  email character varying(128) NOT NULL,
  avatar text,
  status text,
  event_id text -- reference to events.address_id,
  FOREIGN KEY (event_id) REFERENCES events(address_id)
)

CREATE TABLE socialmedia.likes (
  customer_id character varying(64) NOT NULL -- unique identifier,
  last_active date,
  updated_at timestamp without time zone,
  nationality text,
  status character varying(256),
  membership_level character varying(128),
  address character varying(64) NOT NULL,
  website varchar,
  zip_code varchar NOT NULL,
  event_id text NOT NULL -- reference to events.address_id,
  FOREIGN KEY (event_id) REFERENCES events(address_id)
)

[User] Get all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Order the output by event_id ascending.

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

[User] Only show the top 100 results.

[Assistant] SELECT * FROM socialmedia.likes ORDER BY event_id ASC LIMIT 100;


[User] Retrieve zip_code, address, membership_level for every like.

[Assistant] SELECT zip_code, address, membership_level FROM socialmedia.likes;

[User] Find likes where website LIKE 'A%'.

[Assistant] SELECT zip_code, address, membership_level FROM socialmedia.likes WHERE website LIKE 'A%';

[User] Count the number of likes in each website category.

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


[User] Retrieve last_active, status, zip_code for every like.

[Assistant] SELECT last_active, status, zip_code FROM socialmedia.likes;

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

[Assistant] SELECT last_active, status, zip_code FROM socialmedia.likes WHERE zip_code LIKE 'A%';

[User] Group likes by last_active and show the sum of updated_at.

[Assistant] SELECT last_active, SUM(updated_at) AS sum_updated_at FROM socialmedia.likes GROUP BY last_active;


[User] Retrieve all users.

[Assistant] SELECT * FROM socialmedia.users;

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

[Assistant] SELECT * FROM socialmedia.users WHERE zip_code LIKE 'A%';

[User] How many users are there per created_at?

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


[User] Display all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Get email, event_id, accessibility, type by joining users with events.

[Assistant] SELECT *, events.accessibility, events.type FROM socialmedia.users JOIN socialmedia.events ON users.event_id = events.address_id;

[User] Calculate count of email for each zip_code in users.

[Assistant] SELECT zip_code, COUNT(email) AS count_email FROM socialmedia.users GROUP BY zip_code;


[User] Retrieve password_hash, zip_code, status for every user.

[Assistant] SELECT password_hash, zip_code, status FROM socialmedia.users;

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

[Assistant] SELECT password_hash, zip_code, status FROM socialmedia.users WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Group users by avatar and show the average of zip_code.

[Assistant] SELECT avatar, AVERAGE(zip_code) AS average_zip_code FROM socialmedia.users GROUP BY avatar;


[User] What are the created_at, updated_at, event_id of each user?

[Assistant] SELECT created_at, updated_at, event_id FROM socialmedia.users;

[User] Show me updated_at, status, name, created_at from users and their related events.

[Assistant] SELECT created_at, updated_at, event_id, events.name, events.created_at FROM socialmedia.users JOIN socialmedia.events ON users.event_id = events.address_id;

[User] Can you order these by website ascending?

[Assistant] SELECT created_at, updated_at, event_id, events.name, events.created_at FROM socialmedia.users JOIN socialmedia.events ON users.event_id = events.address_id ORDER BY website ASC;


[User] Retrieve all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Can you order these by event_id descending?

[Assistant] SELECT * FROM socialmedia.likes ORDER BY event_id DESC;

[User] Count the number of likes in each event_id category.

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


[User] List last_active, zip_code, address from likes.

[Assistant] SELECT last_active, zip_code, address FROM socialmedia.likes;

[User] Show the results sorted by membership_level descending.

[Assistant] SELECT last_active, zip_code, address FROM socialmedia.likes ORDER BY membership_level DESC;

[User] Restrict the output to 50 items.

[Assistant] SELECT last_active, zip_code, address FROM socialmedia.likes ORDER BY membership_level DESC LIMIT 50;


[User] Retrieve all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Get all likes created yesterday.

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

[User] Get average of address by membership_level from likes.

[Assistant] SELECT membership_level, AVERAGE(address) AS average_address FROM socialmedia.likes GROUP BY membership_level;


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 retail.members (
  user_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at date,
  username character varying(128),
  birth_date date,
  address character varying(128),
  booking_id integer -- reference to bookings.id,
  FOREIGN KEY (booking_id) REFERENCES bookings(id)
)

CREATE TABLE retail.bookings (
  id integer PRIMARY KEY -- unique identifier,
  traded_at date,
  cancelled_at date,
  payment_status character varying(128),
  card_type char,
  amount numeric,
  delivery_status char,
  currency character varying(128),
  total numeric NOT NULL,
  member_id integer -- reference to members.user_id,
  FOREIGN KEY (member_id) REFERENCES members(user_id)
)

[User] Retrieve all bookings.

[Assistant] SELECT * FROM retail.bookings;

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

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

[User] Get the distribution of bookings across different cancelled_at values.

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


[User] Get all members.

[Assistant] SELECT * FROM retail.members;

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

[Assistant] SELECT * FROM retail.members ORDER BY address DESC;

[User] Tally up members by updated_at.

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


[User] List created_at, booking_id, updated_at from members.

[Assistant] SELECT created_at, booking_id, updated_at FROM retail.members;

[User] List members that have created_at > '2023-01-01'.

[Assistant] SELECT created_at, booking_id, updated_at FROM retail.members WHERE created_at > '2023-01-01';

[User] Can you order these by booking_id ascending?

[Assistant] SELECT created_at, booking_id, updated_at FROM retail.members WHERE created_at > '2023-01-01' ORDER BY booking_id ASC;


[User] Show me updated_at, created_at, username for all members.

[Assistant] SELECT updated_at, created_at, username FROM retail.members;

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

[Assistant] SELECT updated_at, created_at, username FROM retail.members WHERE created_at > '2023-01-01';

[User] Count the number of members in each address category.

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


[User] Retrieve birth_date, booking_id, address for every member.

[Assistant] SELECT birth_date, booking_id, address FROM retail.members;

[User] List members that have created_at > '2023-01-01'.

[Assistant] SELECT birth_date, booking_id, address FROM retail.members WHERE created_at > '2023-01-01';

[User] Show the results sorted by username descending.

[Assistant] SELECT birth_date, booking_id, address FROM retail.members WHERE created_at > '2023-01-01' ORDER BY username DESC;


[User] What are the traded_at, amount, card_type of each booking?

[Assistant] SELECT traded_at, amount, card_type FROM retail.bookings;

[User] List card_type, payment_status, address, updated_at for each booking along with their member information.

[Assistant] SELECT traded_at, amount, card_type, members.address, members.updated_at FROM retail.bookings JOIN retail.members ON bookings.member_id = members.user_id;

[User] Show me the count of bookings grouped by total.

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


[User] List all bookings.

[Assistant] SELECT * FROM retail.bookings;

[User] Get bookings that match amount > 47.

[Assistant] SELECT * FROM retail.bookings WHERE amount > 47;

[User] Get the distribution of bookings across different delivery_status values.

[Assistant] SELECT delivery_status, COUNT(*) AS count FROM retail.bookings GROUP BY delivery_status ORDER BY count DESC;


[User] Show me all members.

[Assistant] SELECT * FROM retail.members;

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

[Assistant] SELECT * FROM retail.members WHERE created_at > '2023-01-01';

[User] Show only 25 records.

[Assistant] SELECT * FROM retail.members WHERE created_at > '2023-01-01' LIMIT 25;


[User] Display all members.

[Assistant] SELECT * FROM retail.members;

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

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

[User] Tally up members by updated_at.

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


[User] Get all bookings.

[Assistant] SELECT * FROM retail.bookings;

[User] What delivery_status, card_type, username, address do we have for bookings and their associated members?

[Assistant] SELECT *, members.username, members.address FROM retail.bookings JOIN retail.members ON bookings.member_id = members.user_id;

[User] Count the number of bookings in each cancelled_at category.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE realestate.facilities (
  store_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  updated_at date,
  latitude text,
  capacity character varying(128),
  address_line1 char,
  category text,
  description character varying(64),
  user_id text -- reference to users.user_id,
  FOREIGN KEY (user_id) REFERENCES users(user_id)
)

CREATE TABLE realestate.users (
  user_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  state character varying(64),
  token character varying(64)
)

[User] List all facilities.

[Assistant] SELECT * FROM realestate.facilities;

[User] Get facilities that match address_line1 LIKE 'A%'.

[Assistant] SELECT * FROM realestate.facilities WHERE address_line1 LIKE 'A%';

[User] Tally up facilities by user_id.

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


[User] Retrieve all facilities.

[Assistant] SELECT * FROM realestate.facilities;

[User] Sort the results by updated_at descending.

[Assistant] SELECT * FROM realestate.facilities ORDER BY updated_at DESC;

[User] Can you order these by capacity descending?

[Assistant] SELECT * FROM realestate.facilities ORDER BY capacity DESC;


[User] Retrieve capacity, updated_at, address_line1 for every facilitie.

[Assistant] SELECT capacity, updated_at, address_line1 FROM realestate.facilities;

[User] List facilities that have description LIKE 'A%'.

[Assistant] SELECT capacity, updated_at, address_line1 FROM realestate.facilities WHERE description LIKE 'A%';

[User] Calculate sum of category for each capacity in facilities.

[Assistant] SELECT capacity, SUM(category) AS sum_category FROM realestate.facilities GROUP BY capacity;


[User] Get capacity, latitude, created_at from all facilities.

[Assistant] SELECT capacity, latitude, created_at FROM realestate.facilities;

[User] Show me category, address_line1, state, last_active from facilities and their related users.

[Assistant] SELECT capacity, latitude, created_at, users.state, users.last_active FROM realestate.facilities JOIN realestate.users ON facilities.user_id = users.user_id;

[User] Show only 10 records.

[Assistant] SELECT capacity, latitude, created_at, users.state, users.last_active FROM realestate.facilities JOIN realestate.users ON facilities.user_id = users.user_id LIMIT 10;


[User] Get all facilities.

[Assistant] SELECT * FROM realestate.facilities;

[User] Retrieve updated_at, address_line1, last_active, token showing the relationship between facilities and users.

[Assistant] SELECT *, users.last_active, users.token FROM realestate.facilities JOIN realestate.users ON facilities.user_id = users.user_id;

[User] Sort the results by latitude ascending.

[Assistant] SELECT *, users.last_active, users.token FROM realestate.facilities JOIN realestate.users ON facilities.user_id = users.user_id ORDER BY latitude ASC;


[User] Show me store_id, address_line1, description for all facilities.

[Assistant] SELECT store_id, address_line1, description FROM realestate.facilities;

[User] Retrieve description, address_line1, state, token showing the relationship between facilities and users.

[Assistant] SELECT store_id, address_line1, description, users.state, users.token FROM realestate.facilities JOIN realestate.users ON facilities.user_id = users.user_id;

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

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


[User] Retrieve all facilities.

[Assistant] SELECT * FROM realestate.facilities;

[User] What category, created_at, last_active, state do we have for facilities and their associated users?

[Assistant] SELECT *, users.last_active, users.state FROM realestate.facilities JOIN realestate.users ON facilities.user_id = users.user_id;

[User] Only show the top 25 results.

[Assistant] SELECT *, users.last_active, users.state FROM realestate.facilities JOIN realestate.users ON facilities.user_id = users.user_id LIMIT 25;


[User] Retrieve user_id, address_line1, category for every facilitie.

[Assistant] SELECT user_id, address_line1, category FROM realestate.facilities;

[User] Can you order these by category ascending?

[Assistant] SELECT user_id, address_line1, category FROM realestate.facilities ORDER BY category ASC;

[User] Show only 10 records.

[Assistant] SELECT user_id, address_line1, category FROM realestate.facilities ORDER BY category ASC LIMIT 10;


[User] Retrieve store_id, capacity, user_id for every facilitie.

[Assistant] SELECT store_id, capacity, user_id FROM realestate.facilities;

[User] What created_at, address_line1, state, token do we have for facilities and their associated users?

[Assistant] SELECT store_id, capacity, user_id, users.state, users.token FROM realestate.facilities JOIN realestate.users ON facilities.user_id = users.user_id;

[User] How many facilities are there per created_at?

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


[User] Show me capacity, latitude, description for all facilities.

[Assistant] SELECT capacity, latitude, description FROM realestate.facilities;

[User] Find facilities created yesterday.

[Assistant] SELECT capacity, latitude, description FROM realestate.facilities WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Return just 100 rows.

[Assistant] SELECT capacity, latitude, description FROM realestate.facilities WHERE updated_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 100;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE banking.billing (
  id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  status varchar,
  amount decimal,
  description text,
  payee_id character varying(64) NOT NULL -- identifier for payee,
  reservation_id integer NOT NULL -- reference to reservations.id,
  FOREIGN KEY (reservation_id) REFERENCES reservations(id)
)

CREATE TABLE banking.reservations (
  id integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  payment_method text NOT NULL,
  buyer_id varchar -- identifier for buyer,
  payment_status varchar NOT NULL,
  amount decimal,
  currency varchar,
  billin_id text NOT NULL -- reference to billing.id,
  FOREIGN KEY (billin_id) REFERENCES billing(id)
)

CREATE TABLE banking.patients (
  user_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  salt char,
  country character varying(64),
  first_name text NOT NULL,
  token text,
  profile_picture_url varchar,
  billin_id text NOT NULL -- reference to billing.id,
  FOREIGN KEY (billin_id) REFERENCES billing(id)
)

[User] Show me created_at, currency, payment_status for all reservations.

[Assistant] SELECT created_at, currency, payment_status FROM banking.reservations;

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

[Assistant] SELECT created_at, currency, payment_status FROM banking.reservations WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Calculate average of currency for each payment_method in reservations.

[Assistant] SELECT payment_method, AVERAGE(currency) AS average_currency FROM banking.reservations GROUP BY payment_method;


[User] List all patients.

[Assistant] SELECT * FROM banking.patients;

[User] Show me patients with billin_id LIKE 'A%'.

[Assistant] SELECT * FROM banking.patients WHERE billin_id LIKE 'A%';

[User] Sort the results by token ascending.

[Assistant] SELECT * FROM banking.patients WHERE billin_id LIKE 'A%' ORDER BY token ASC;


[User] List all patients.

[Assistant] SELECT * FROM banking.patients;

[User] List token, country, amount, payee_id for each patient along with their billing information.

[Assistant] SELECT *, billing.amount, billing.payee_id FROM banking.patients JOIN banking.billing ON patients.billin_id = billing.id;

[User] Limit the results to 25 rows.

[Assistant] SELECT *, billing.amount, billing.payee_id FROM banking.patients JOIN banking.billing ON patients.billin_id = billing.id LIMIT 25;


[User] Get billin_id, created_at, payment_method from all reservations.

[Assistant] SELECT billin_id, created_at, payment_method FROM banking.reservations;

[User] List reservations that have payment_status LIKE 'A%'.

[Assistant] SELECT billin_id, created_at, payment_method FROM banking.reservations WHERE payment_status LIKE 'A%';

[User] Only show the top 5 results.

[Assistant] SELECT billin_id, created_at, payment_method FROM banking.reservations WHERE payment_status LIKE 'A%' LIMIT 5;


[User] Display all billing.

[Assistant] SELECT * FROM banking.billing;

[User] Show me description, payee_id, currency, amount from billing and their related reservations.

[Assistant] SELECT *, reservations.currency, reservations.amount FROM banking.billing JOIN banking.reservations ON billing.reservation_id = reservations.id;

[User] Can you order these by amount descending?

[Assistant] SELECT *, reservations.currency, reservations.amount FROM banking.billing JOIN banking.reservations ON billing.reservation_id = reservations.id ORDER BY amount DESC;


[User] Show me all patients.

[Assistant] SELECT * FROM banking.patients;

[User] Show me patients with salt LIKE 'A%'.

[Assistant] SELECT * FROM banking.patients WHERE salt LIKE 'A%';

[User] How many patients are there per first_name?

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


[User] Get all billing.

[Assistant] SELECT * FROM banking.billing;

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

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

[User] Group billing by updated_at and show the max of reservation_id.

[Assistant] SELECT updated_at, MAX(reservation_id) AS max_reservation_id FROM banking.billing GROUP BY updated_at;


[User] Display all reservations.

[Assistant] SELECT * FROM banking.reservations;

[User] Retrieve reservations where payment_status LIKE 'A%'.

[Assistant] SELECT * FROM banking.reservations WHERE payment_status LIKE 'A%';

[User] Return just 5 rows.

[Assistant] SELECT * FROM banking.reservations WHERE payment_status LIKE 'A%' LIMIT 5;


[User] List all reservations.

[Assistant] SELECT * FROM banking.reservations;

[User] Can you order these by currency ascending?

[Assistant] SELECT * FROM banking.reservations ORDER BY currency ASC;

[User] Get sum of buyer_id by created_at from reservations.

[Assistant] SELECT created_at, SUM(buyer_id) AS sum_buyer_id FROM banking.reservations GROUP BY created_at;


[User] Get billin_id, created_at, first_name from all patients.

[Assistant] SELECT billin_id, created_at, first_name FROM banking.patients;

[User] What token, salt, status, updated_at do we have for patients and their associated billing?

[Assistant] SELECT billin_id, created_at, first_name, billing.status, billing.updated_at FROM banking.patients JOIN banking.billing ON patients.billin_id = billing.id;

[User] What is the sum profile_picture_url for each billin_id in patients?

[Assistant] SELECT billin_id, SUM(profile_picture_url) AS sum_profile_picture_url FROM banking.patients GROUP BY billin_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.accounts (
  payment_id integer PRIMARY KEY -- unique identifier,
  due_date timestamp without time zone,
  payment_date timestamp,
  approval_status character varying(256) NOT NULL,
  invoice_number character varying(256),
  vendor_id varchar -- identifier for vendor,
  credit character varying(64),
  amount numeric
)

CREATE TABLE finance.transactions (
  payment_id character varying(64) NOT NULL -- unique identifier,
  traded_at date,
  status character varying(128),
  currency char,
  fee character varying(64),
  subtotal numeric,
  customer_id text NOT NULL -- reference to customers.user_id,
  FOREIGN KEY (customer_id) REFERENCES customers(user_id)
)

CREATE TABLE finance.customers (
  user_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at timestamp without time zone,
  display_name character varying(256),
  bio character varying(64) NOT NULL,
  password_hash character varying(64),
  full_name varchar,
  website character varying(256),
  account_status character varying(128)
)

CREATE TABLE finance.audits (
  id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  gender varchar,
  username character varying(64) NOT NULL,
  city varchar NOT NULL,
  is_verified boolean,
  language char,
  customer_id text NOT NULL -- reference to customers.user_id,
  FOREIGN KEY (customer_id) REFERENCES customers(user_id)
)

[User] Show me id, is_verified, city for all audits.

[Assistant] SELECT id, is_verified, city FROM finance.audits;

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

[Assistant] SELECT id, is_verified, city FROM finance.audits WHERE created_at > '2023-12-01';

[User] Restrict the output to 15 items.

[Assistant] SELECT id, is_verified, city FROM finance.audits WHERE created_at > '2023-12-01' LIMIT 15;


[User] Get city, is_verified, customer_id from all audits.

[Assistant] SELECT city, is_verified, customer_id FROM finance.audits;

[User] Order the output by language descending.

[Assistant] SELECT city, is_verified, customer_id FROM finance.audits ORDER BY language DESC;

[User] Show only 5 records.

[Assistant] SELECT city, is_verified, customer_id FROM finance.audits ORDER BY language DESC LIMIT 5;


[User] List all audits.

[Assistant] SELECT * FROM finance.audits;

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

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

[User] Sort the results by language ascending.

[Assistant] SELECT * FROM finance.audits WHERE id LIKE 'A%' ORDER BY language ASC;


[User] Display all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Find audits where gender LIKE 'A%'.

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

[User] Count the number of audits in each gender category.

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


[User] Retrieve all transactions.

[Assistant] SELECT * FROM finance.transactions;

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

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

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

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


[User] Retrieve all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Can you order these by gender ascending?

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

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

[Assistant] SELECT * FROM finance.audits ORDER BY city 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 finance.loans (
  payment_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  created_at date,
  payee_id char NOT NULL -- identifier for payee,
  invoice_number char,
  exchange_rate char,
  vendor_id character varying(128) NOT NULL,
  investment_id text -- reference to investments.invoice_id,
  FOREIGN KEY (investment_id) REFERENCES investments(invoice_id)
)

CREATE TABLE finance.investments (
  invoice_id text PRIMARY KEY -- unique identifier,
  completed_at timestamp without time zone,
  payment_status text NOT NULL,
  delivery_status character varying(256),
  seller_id text -- identifier for seller,
  user_id text
)

CREATE TABLE finance.customers (
  person_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  address varchar,
  zip_code character varying(128),
  website character varying(64) NOT NULL,
  country varchar,
  username character varying(128)
)

CREATE TABLE finance.accounts (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  balance numeric(38,14),
  reference_number character varying(64) NOT NULL,
  approval_status char,
  customer_id character varying(256)
)

CREATE TABLE finance.transactions (
  id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  processed_at timestamp,
  status text,
  discount decimal NOT NULL,
  currency char,
  loan_id text -- reference to loans.payment_id,
  FOREIGN KEY (loan_id) REFERENCES loans(payment_id)
)

[User] Retrieve all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Can you order these by created_at descending?

[Assistant] SELECT * FROM finance.loans ORDER BY created_at DESC;

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

[Assistant] SELECT * FROM finance.loans ORDER BY investment_id ASC;


[User] List all transactions.

[Assistant] SELECT * FROM finance.transactions;

[User] List transactions that have discount > 64.

[Assistant] SELECT * FROM finance.transactions WHERE discount > 64;

[User] Show only 100 records.

[Assistant] SELECT * FROM finance.transactions WHERE discount > 64 LIMIT 100;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.prescriptions (
  id text PRIMARY KEY -- unique identifier,
  due_date timestamp without time zone,
  payer_id character varying(128),
  customer_id character varying(64) -- identifier for customer,
  currency character varying(64) NOT NULL,
  patient_id text NOT NULL -- reference to patients.employee_id,
  FOREIGN KEY (patient_id) REFERENCES patients(employee_id)
)

CREATE TABLE healthcare.patients (
  employee_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  status character varying(64) NOT NULL,
  username character varying(128) NOT NULL,
  phone char,
  full_name char NOT NULL,
  billin_id text -- reference to billing.content_id,
  FOREIGN KEY (billin_id) REFERENCES billing(content_id)
)

CREATE TABLE healthcare.billing (
  content_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  published_at timestamp without time zone,
  body character varying(128) NOT NULL,
  image_url character varying(64),
  parent_id character varying(128) -- identifier for parent,
  thumbnail text NOT NULL,
  shares char NOT NULL,
  prescription_id text -- reference to prescriptions.id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(id)
)

[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

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

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


[User] Retrieve all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] List image_url, prescription_id, customer_id, payer_id for each billing along with their prescription information.

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

[User] Limit the results to 5 rows.

[Assistant] SELECT *, prescriptions.customer_id, prescriptions.payer_id FROM healthcare.billing JOIN healthcare.prescriptions ON billing.prescription_id = prescriptions.id LIMIT 5;


[User] List patient_id, currency, due_date from prescriptions.

[Assistant] SELECT patient_id, currency, due_date FROM healthcare.prescriptions;

[User] Get customer_id, payer_id, full_name, phone by joining prescriptions with patients.

[Assistant] SELECT patient_id, currency, due_date, patients.full_name, patients.phone FROM healthcare.prescriptions JOIN healthcare.patients ON prescriptions.patient_id = patients.employee_id;

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

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


[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Find billing where body LIKE 'A%'.

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

[User] Return just 50 rows.

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


[User] List due_date, patient_id, currency from prescriptions.

[Assistant] SELECT due_date, patient_id, currency FROM healthcare.prescriptions;

[User] List currency, payer_id, billin_id, phone for each prescription along with their patient information.

[Assistant] SELECT due_date, patient_id, currency, patients.billin_id, patients.phone FROM healthcare.prescriptions JOIN healthcare.patients ON prescriptions.patient_id = patients.employee_id;

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

[Assistant] SELECT payer_id, SUM(customer_id) AS sum_customer_id FROM healthcare.prescriptions GROUP BY payer_id;


[User] Display all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Retrieve due_date, patient_id, username, status showing the relationship between prescriptions and patients.

[Assistant] SELECT *, patients.username, patients.status FROM healthcare.prescriptions JOIN healthcare.patients ON prescriptions.patient_id = patients.employee_id;

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

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


[User] List due_date, payer_id, patient_id from prescriptions.

[Assistant] SELECT due_date, payer_id, patient_id FROM healthcare.prescriptions;

[User] Sort the results by currency ascending.

[Assistant] SELECT due_date, payer_id, patient_id FROM healthcare.prescriptions ORDER BY currency ASC;

[User] How many prescriptions are there per currency?

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


[User] Retrieve all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Retrieve patients where phone LIKE 'A%'.

[Assistant] SELECT * FROM healthcare.patients WHERE phone LIKE 'A%';

[User] Show the results sorted by username ascending.

[Assistant] SELECT * FROM healthcare.patients WHERE phone LIKE 'A%' ORDER BY username ASC;


[User] Display all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Show me prescriptions that were from 2023.

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

[User] Can you order these by currency descending?

[Assistant] SELECT * FROM healthcare.prescriptions WHERE due_date BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY currency DESC;


[User] Get created_at, billin_id, username from all patients.

[Assistant] SELECT created_at, billin_id, username FROM healthcare.patients;

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

[Assistant] SELECT created_at, billin_id, username FROM healthcare.patients WHERE username LIKE 'A%';

[User] Show me the count of patients grouped by full_name.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.departments (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  created_at timestamp without time zone,
  parent_id character varying(64),
  media_url character varying(64),
  subject character varying(64) NOT NULL,
  score character varying(128),
  assignment_id text -- reference to assignments.id,
  FOREIGN KEY (assignment_id) REFERENCES assignments(id)
)

CREATE TABLE education.assignments (
  id text PRIMARY KEY -- unique identifier,
  created_at date,
  expires_at timestamp,
  discount smallint NOT NULL,
  price numeric(38,14),
  reserved varchar NOT NULL,
  available text,
  featured_rank character varying(256) NOT NULL,
  thumbnail_url character varying(256),
  department_id text -- reference to departments.id,
  FOREIGN KEY (department_id) REFERENCES departments(id)
)

[User] Display all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Show the results sorted by price descending.

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

[User] Get sum of price by available from assignments.

[Assistant] SELECT available, SUM(price) AS sum_price FROM education.assignments GROUP BY available;


[User] Retrieve all departments.

[Assistant] SELECT * FROM education.departments;

[User] Can you order these by parent_id descending?

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

[User] Group departments by created_at and show the sum of subject.

[Assistant] SELECT created_at, SUM(subject) AS sum_subject FROM education.departments GROUP BY created_at;


[User] List media_url, score, parent_id from departments.

[Assistant] SELECT media_url, score, parent_id FROM education.departments;

[User] List created_at, parent_id, discount, created_at for each department along with their assignment information.

[Assistant] SELECT media_url, score, parent_id, assignments.discount, assignments.created_at FROM education.departments JOIN education.assignments ON departments.assignment_id = assignments.id;

[User] Show only 10 records.

[Assistant] SELECT media_url, score, parent_id, assignments.discount, assignments.created_at FROM education.departments JOIN education.assignments ON departments.assignment_id = assignments.id LIMIT 10;


[User] Display all departments.

[Assistant] SELECT * FROM education.departments;

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

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

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

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


[User] Show me created_at, updated_at, subject for all departments.

[Assistant] SELECT created_at, updated_at, subject FROM education.departments;

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

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

[User] Calculate max of parent_id for each score in departments.

[Assistant] SELECT score, MAX(parent_id) AS max_parent_id FROM education.departments GROUP BY score;


[User] List reserved, department_id, expires_at from assignments.

[Assistant] SELECT reserved, department_id, expires_at FROM education.assignments;

[User] Get all assignments from last week.

[Assistant] SELECT reserved, department_id, expires_at FROM education.assignments WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Show only 25 records.

[Assistant] SELECT reserved, department_id, expires_at FROM education.assignments WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 25;


[User] Retrieve all assignments.

[Assistant] SELECT * FROM education.assignments;

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

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

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

[Assistant] SELECT * FROM education.assignments WHERE created_at > '2023-01-01' ORDER BY discount ASC;


[User] Show me all departments.

[Assistant] SELECT * FROM education.departments;

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

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

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

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


[User] Retrieve featured_rank, available, department_id for every assignment.

[Assistant] SELECT featured_rank, available, department_id FROM education.assignments;

[User] Show me created_at, reserved, parent_id, created_at from assignments and their related departments.

[Assistant] SELECT featured_rank, available, department_id, departments.parent_id, departments.created_at FROM education.assignments JOIN education.departments ON assignments.department_id = departments.id;

[User] How many assignments are there per available?

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


[User] Get all departments.

[Assistant] SELECT * FROM education.departments;

[User] Retrieve score, assignment_id, discount, thumbnail_url showing the relationship between departments and assignments.

[Assistant] SELECT *, assignments.discount, assignments.thumbnail_url FROM education.departments JOIN education.assignments ON departments.assignment_id = assignments.id;

[User] Show the results sorted by score descending.

[Assistant] SELECT *, assignments.discount, assignments.thumbnail_url FROM education.departments JOIN education.assignments ON departments.assignment_id = assignments.id ORDER BY score 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.users (
  user_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at timestamp without time zone,
  state char NOT NULL,
  api_key char NOT NULL,
  language character varying(128) NOT NULL,
  phone character varying(128),
  profile_picture_url varchar,
  asset_id integer -- reference to assets.product_id,
  FOREIGN KEY (asset_id) REFERENCES assets(product_id)
)

CREATE TABLE tradingplatform.assets (
  product_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  price bigint,
  reserved character varying(256),
  image_url varchar,
  rating char NOT NULL,
  title text,
  order_id text -- reference to orders.transaction_id,
  FOREIGN KEY (order_id) REFERENCES orders(transaction_id)
)

CREATE TABLE tradingplatform.orders (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  cancelled_at date,
  traded_at timestamp,
  discount bigint NOT NULL,
  customer_id varchar -- identifier for customer,
  account_id character varying(128) NOT NULL -- identifier for account,
  approval_status character varying(64),
  payment_method character varying(64)
)

[User] Get all users.

[Assistant] SELECT * FROM tradingplatform.users;

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

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

[User] How many users are there per profile_picture_url?

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


[User] Retrieve updated_at, created_at, language for every user.

[Assistant] SELECT updated_at, created_at, language FROM tradingplatform.users;

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

[Assistant] SELECT updated_at, created_at, language FROM tradingplatform.users WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] What is the max state for each asset_id in users?

[Assistant] SELECT asset_id, MAX(state) AS max_state FROM tradingplatform.users GROUP BY asset_id;


[User] Get order_id, title, updated_at from all assets.

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

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

[Assistant] SELECT order_id, title, updated_at FROM tradingplatform.assets WHERE updated_at > '2023-01-01';

[User] Group assets by image_url and show the average of title.

[Assistant] SELECT image_url, AVERAGE(title) AS average_title FROM tradingplatform.assets GROUP BY image_url;


[User] Retrieve order_id, reserved, image_url for every asset.

[Assistant] SELECT order_id, reserved, image_url FROM tradingplatform.assets;

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

[Assistant] SELECT order_id, reserved, image_url FROM tradingplatform.assets WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Count the number of assets in each reserved category.

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


[User] Show me title, order_id, image_url for all assets.

[Assistant] SELECT title, order_id, image_url FROM tradingplatform.assets;

[User] Order the output by title ascending.

[Assistant] SELECT title, order_id, image_url FROM tradingplatform.assets ORDER BY title ASC;

[User] Count the number of assets in each rating category.

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


[User] List all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] Can you order these by asset_id descending?

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

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

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


[User] Get all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

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

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

[User] Show only 20 records.

[Assistant] SELECT * FROM tradingplatform.assets WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 20;


[User] Get all users.

[Assistant] SELECT * FROM tradingplatform.users;

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

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

[User] Return just 25 rows.

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


[User] Get state, asset_id, profile_picture_url from all users.

[Assistant] SELECT state, asset_id, profile_picture_url FROM tradingplatform.users;

[User] Show the results sorted by profile_picture_url ascending.

[Assistant] SELECT state, asset_id, profile_picture_url FROM tradingplatform.users ORDER BY profile_picture_url ASC;

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

[Assistant] SELECT state, asset_id, profile_picture_url FROM tradingplatform.users ORDER BY phone ASC;


[User] Show me all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

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

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

[User] Sort the results by order_id descending.

[Assistant] SELECT * FROM tradingplatform.assets WHERE updated_at > '2023-12-01' ORDER BY order_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.inventory (
  item_id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp,
  subcategory char,
  media_url varchar,
  thumbnail_url text NOT NULL,
  tax_rate character varying(128),
  order_item_id integer -- reference to order_items.item_id,
  FOREIGN KEY (order_item_id) REFERENCES order_items(item_id)
)

CREATE TABLE e-commerce.order_items (
  item_id integer PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  created_at date,
  featured_rank text NOT NULL,
  views character varying(64),
  thumbnail_url character varying(64),
  inventor_id text -- reference to inventory.item_id,
  FOREIGN KEY (inventor_id) REFERENCES inventory(item_id)
)

[User] Retrieve subcategory, media_url, order_item_id for every inventory.

[Assistant] SELECT subcategory, media_url, order_item_id FROM e-commerce.inventory;

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

[Assistant] SELECT subcategory, media_url, order_item_id FROM e-commerce.inventory WHERE tax_rate LIKE 'A%';

[User] Show me average of order_item_id grouped by published_at for inventory.

[Assistant] SELECT published_at, AVERAGE(order_item_id) AS average_order_item_id FROM e-commerce.inventory GROUP BY published_at;


[User] List media_url, published_at, tax_rate from inventory.

[Assistant] SELECT media_url, published_at, tax_rate FROM e-commerce.inventory;

[User] Get inventory that match thumbnail_url LIKE 'A%'.

[Assistant] SELECT media_url, published_at, tax_rate FROM e-commerce.inventory WHERE thumbnail_url LIKE 'A%';

[User] Can you order these by order_item_id ascending?

[Assistant] SELECT media_url, published_at, tax_rate FROM e-commerce.inventory WHERE thumbnail_url LIKE 'A%' ORDER BY order_item_id ASC;


[User] List views, inventor_id, featured_rank from order_items.

[Assistant] SELECT views, inventor_id, featured_rank FROM e-commerce.order_items;

[User] Sort the results by created_at ascending.

[Assistant] SELECT views, inventor_id, featured_rank FROM e-commerce.order_items ORDER BY created_at ASC;

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

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


[User] List all inventory.

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

[User] Show me published_at, subcategory, views, created_at from inventory and their related order_items.

[Assistant] SELECT *, order_items.views, order_items.created_at FROM e-commerce.inventory JOIN e-commerce.order_items ON inventory.order_item_id = order_items.item_id;

[User] How many inventory are there per tax_rate?

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


[User] Retrieve all order_items.

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

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

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

[User] Can you order these by views ascending?

[Assistant] SELECT * FROM e-commerce.order_items WHERE thumbnail_url LIKE 'A%' ORDER BY views ASC;


[User] Display all inventory.

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

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

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

[User] Calculate max of tax_rate for each published_at in inventory.

[Assistant] SELECT published_at, MAX(tax_rate) AS max_tax_rate FROM e-commerce.inventory GROUP BY published_at;


[User] What are the views, created_at, published_at of each order_item?

[Assistant] SELECT views, created_at, published_at FROM e-commerce.order_items;

[User] List order_items that have views LIKE 'A%'.

[Assistant] SELECT views, created_at, published_at FROM e-commerce.order_items WHERE views LIKE 'A%';

[User] What is the sum inventor_id for each published_at in order_items?

[Assistant] SELECT published_at, SUM(inventor_id) AS sum_inventor_id FROM e-commerce.order_items GROUP BY published_at;


[User] Show me all inventory.

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

[User] List inventory with dates created yesterday.

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

[User] Can you order these by thumbnail_url ascending?

[Assistant] SELECT * FROM e-commerce.inventory WHERE published_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY thumbnail_url ASC;


[User] Retrieve all inventory.

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

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

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

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

[Assistant] SELECT * FROM e-commerce.inventory ORDER BY thumbnail_url DESC;


[User] Get all order_items.

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

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

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

[User] Tally up order_items by thumbnail_url.

[Assistant] SELECT thumbnail_url, COUNT(*) AS count FROM e-commerce.order_items GROUP BY thumbnail_url 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 sports.purchases (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  processed_at date,
  updated_at date,
  subtotal numeric(38,14),
  approval_status character varying(256) NOT NULL,
  payment_method character varying(256) NOT NULL,
  client_id integer NOT NULL -- reference to clients.customer_id,
  FOREIGN KEY (client_id) REFERENCES clients(customer_id)
)

CREATE TABLE sports.clients (
  customer_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  birth_date date,
  nationality text,
  website character varying(128),
  token character varying(256) NOT NULL,
  is_active boolean NOT NULL
)

[User] Display all purchases.

[Assistant] SELECT * FROM sports.purchases;

[User] Find purchases between January and March.

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

[User] Sort the results by processed_at descending.

[Assistant] SELECT * FROM sports.purchases WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY processed_at DESC;


[User] What are the updated_at, payment_method, client_id of each purchase?

[Assistant] SELECT updated_at, payment_method, client_id FROM sports.purchases;

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

[Assistant] SELECT updated_at, payment_method, client_id FROM sports.purchases ORDER BY approval_status ASC;

[User] Tally up purchases by approval_status.

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


[User] Display all purchases.

[Assistant] SELECT * FROM sports.purchases;

[User] Retrieve payment_method, client_id, birth_date, token showing the relationship between purchases and clients.

[Assistant] SELECT *, clients.birth_date, clients.token FROM sports.purchases JOIN sports.clients ON purchases.client_id = clients.customer_id;

[User] Calculate count of processed_at for each updated_at in purchases.

[Assistant] SELECT updated_at, COUNT(processed_at) AS count_processed_at FROM sports.purchases GROUP BY updated_at;


[User] Retrieve processed_at, client_id, approval_status for every purchase.

[Assistant] SELECT processed_at, client_id, approval_status FROM sports.purchases;

[User] List payment_method, approval_status, nationality, updated_at for each purchase along with their client information.

[Assistant] SELECT processed_at, client_id, approval_status, clients.nationality, clients.updated_at FROM sports.purchases JOIN sports.clients ON purchases.client_id = clients.customer_id;

[User] Calculate average of transaction_id for each payment_method in purchases.

[Assistant] SELECT payment_method, AVERAGE(transaction_id) AS average_transaction_id FROM sports.purchases GROUP BY payment_method;


[User] List all purchases.

[Assistant] SELECT * FROM sports.purchases;

[User] Get all purchases between January and March.

[Assistant] SELECT * FROM sports.purchases WHERE processed_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Restrict the output to 100 items.

[Assistant] SELECT * FROM sports.purchases WHERE processed_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 100;


[User] Show me all purchases.

[Assistant] SELECT * FROM sports.purchases;

[User] Order the output by subtotal ascending.

[Assistant] SELECT * FROM sports.purchases ORDER BY subtotal ASC;

[User] Show only 10 records.

[Assistant] SELECT * FROM sports.purchases ORDER BY subtotal ASC LIMIT 10;


[User] List transaction_id, processed_at, client_id from purchases.

[Assistant] SELECT transaction_id, processed_at, client_id FROM sports.purchases;

[User] Retrieve subtotal, approval_status, website, birth_date showing the relationship between purchases and clients.

[Assistant] SELECT transaction_id, processed_at, client_id, clients.website, clients.birth_date FROM sports.purchases JOIN sports.clients ON purchases.client_id = clients.customer_id;

[User] Show only 50 records.

[Assistant] SELECT transaction_id, processed_at, client_id, clients.website, clients.birth_date FROM sports.purchases JOIN sports.clients ON purchases.client_id = clients.customer_id LIMIT 50;


[User] Show me processed_at, payment_method, updated_at for all purchases.

[Assistant] SELECT processed_at, payment_method, updated_at FROM sports.purchases;

[User] List processed_at, subtotal, is_active, nationality for each purchase along with their client information.

[Assistant] SELECT processed_at, payment_method, updated_at, clients.is_active, clients.nationality FROM sports.purchases JOIN sports.clients ON purchases.client_id = clients.customer_id;

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

[Assistant] SELECT processed_at, payment_method, updated_at, clients.is_active, clients.nationality FROM sports.purchases JOIN sports.clients ON purchases.client_id = clients.customer_id ORDER BY transaction_id DESC;


[User] Retrieve approval_status, updated_at, client_id for every purchase.

[Assistant] SELECT approval_status, updated_at, client_id FROM sports.purchases;

[User] Show me subtotal, processed_at, updated_at, nationality from purchases and their related clients.

[Assistant] SELECT approval_status, updated_at, client_id, clients.updated_at, clients.nationality FROM sports.purchases JOIN sports.clients ON purchases.client_id = clients.customer_id;

[User] Limit the results to 5 rows.

[Assistant] SELECT approval_status, updated_at, client_id, clients.updated_at, clients.nationality FROM sports.purchases JOIN sports.clients ON purchases.client_id = clients.customer_id LIMIT 5;


[User] List processed_at, subtotal, approval_status from purchases.

[Assistant] SELECT processed_at, subtotal, approval_status FROM sports.purchases;

[User] Show me subtotal, updated_at, nationality, birth_date from purchases and their related clients.

[Assistant] SELECT processed_at, subtotal, approval_status, clients.nationality, clients.birth_date FROM sports.purchases JOIN sports.clients ON purchases.client_id = clients.customer_id;

[User] What is the average subtotal for each payment_method in purchases?

[Assistant] SELECT payment_method, AVERAGE(subtotal) AS average_subtotal FROM sports.purchases GROUP BY payment_method;


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.investments (
  post_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp without time zone,
  content character varying(128) NOT NULL,
  text character varying(256),
  keywords varchar
)

CREATE TABLE finance.accounts (
  payment_id character varying(64) NOT NULL -- unique identifier,
  processed_at timestamp without time zone,
  reconciliation_status char,
  payer_id char NOT NULL -- identifier for payer,
  exchange_rate varchar NOT NULL,
  transaction_id text NOT NULL -- reference to transactions.order_id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(order_id)
)

CREATE TABLE finance.transactions (
  order_id text PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  traded_at date,
  discount integer,
  delivery_status text,
  buyer_id varchar NOT NULL -- identifier for buyer
)

[User] List all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Sort the results by exchange_rate descending.

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

[User] Show only 15 records.

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


[User] Retrieve all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Retrieve payer_id, exchange_rate, cancelled_at, delivery_status showing the relationship between accounts and transactions.

[Assistant] SELECT *, transactions.cancelled_at, transactions.delivery_status FROM finance.accounts JOIN finance.transactions ON accounts.transaction_id = transactions.order_id;

[User] What is the min payment_id for each processed_at in accounts?

[Assistant] SELECT processed_at, MIN(payment_id) AS min_payment_id FROM finance.accounts GROUP BY processed_at;


[User] Get reconciliation_status, transaction_id, exchange_rate from all accounts.

[Assistant] SELECT reconciliation_status, transaction_id, exchange_rate FROM finance.accounts;

[User] Can you order these by processed_at descending?

[Assistant] SELECT reconciliation_status, transaction_id, exchange_rate FROM finance.accounts ORDER BY processed_at DESC;

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

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


[User] Retrieve all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

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

[User] Restrict the output to 20 items.

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


[User] Get payment_id, payer_id, processed_at from all accounts.

[Assistant] SELECT payment_id, payer_id, processed_at FROM finance.accounts;

[User] Can you order these by payment_id ascending?

[Assistant] SELECT payment_id, payer_id, processed_at FROM finance.accounts ORDER BY payment_id ASC;

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

[Assistant] SELECT payment_id, payer_id, processed_at FROM finance.accounts ORDER BY payer_id ASC;


[User] List all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Retrieve transaction_id, payment_id, discount, delivery_status showing the relationship between accounts and transactions.

[Assistant] SELECT *, transactions.discount, transactions.delivery_status FROM finance.accounts JOIN finance.transactions ON accounts.transaction_id = transactions.order_id;

[User] Only show the top 15 results.

[Assistant] SELECT *, transactions.discount, transactions.delivery_status FROM finance.accounts JOIN finance.transactions ON accounts.transaction_id = transactions.order_id LIMIT 15;


[User] Display all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Retrieve exchange_rate, payer_id, cancelled_at, buyer_id showing the relationship between accounts and transactions.

[Assistant] SELECT *, transactions.cancelled_at, transactions.buyer_id FROM finance.accounts JOIN finance.transactions ON accounts.transaction_id = transactions.order_id;

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

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


[User] List exchange_rate, reconciliation_status, transaction_id from accounts.

[Assistant] SELECT exchange_rate, reconciliation_status, transaction_id FROM finance.accounts;

[User] Show me processed_at, transaction_id, discount, buyer_id from accounts and their related transactions.

[Assistant] SELECT exchange_rate, reconciliation_status, transaction_id, transactions.discount, transactions.buyer_id FROM finance.accounts JOIN finance.transactions ON accounts.transaction_id = transactions.order_id;

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

[Assistant] SELECT exchange_rate, reconciliation_status, transaction_id, transactions.discount, transactions.buyer_id FROM finance.accounts JOIN finance.transactions ON accounts.transaction_id = transactions.order_id ORDER BY reconciliation_status DESC;


[User] Get all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Show me payment_id, reconciliation_status, cancelled_at, traded_at from accounts and their related transactions.

[Assistant] SELECT *, transactions.cancelled_at, transactions.traded_at FROM finance.accounts JOIN finance.transactions ON accounts.transaction_id = transactions.order_id;

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

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