[User] Display all products.

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

[User] Order the output by expires_at descending.

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

[User] Show only 25 records.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.products (
  sku integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  expires_at timestamp,
  views text NOT NULL,
  manufacturer character varying(64),
  name character varying(256),
  discount numeric,
  backorder text NOT NULL,
  cost bigint,
  shippin_id text -- reference to shipping.id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(id)
)

CREATE TABLE e-commerce.shipping (
  id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  last_active date,
  age text,
  country character varying(64),
  birth_date timestamp without time zone,
  nationality character varying(64)
)

[User] Show me all products.

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

[User] Retrieve products where name LIKE 'A%'.

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

[User] How many products are there per discount?

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


[User] Get all products.

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

[User] Sort the results by discount ascending.

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

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

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


[User] Get discount, backorder, cost from all products.

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

[User] What views, discount, age, nationality do we have for products and their associated shipping?

[Assistant] SELECT discount, backorder, cost, shipping.age, shipping.nationality FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.id;

[User] Can you order these by expires_at ascending?

[Assistant] SELECT discount, backorder, cost, shipping.age, shipping.nationality FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.id ORDER BY expires_at ASC;


[User] Get manufacturer, expires_at, discount from all products.

[Assistant] SELECT manufacturer, expires_at, discount FROM e-commerce.products;

[User] What created_at, backorder, age, nationality do we have for products and their associated shipping?

[Assistant] SELECT manufacturer, expires_at, discount, shipping.age, shipping.nationality FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.id;

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

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


[User] Retrieve all products.

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

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

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

[User] Show me the count of products grouped by backorder.

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


[User] Get all products.

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

[User] Retrieve name, created_at, country, age showing the relationship between products and shipping.

[Assistant] SELECT *, shipping.country, shipping.age FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.id;

[User] Only show the top 10 results.

[Assistant] SELECT *, shipping.country, shipping.age FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.id LIMIT 10;


[User] Get shippin_id, backorder, views from all products.

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

[User] Can you order these by cost descending?

[Assistant] SELECT shippin_id, backorder, views FROM e-commerce.products ORDER BY cost DESC;

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

[Assistant] SELECT created_at, COUNT(*) AS count FROM e-commerce.products GROUP BY created_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 tradingplatform.logs (
  person_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  last_active timestamp without time zone,
  email text,
  token char,
  website character varying(64),
  is_verified boolean,
  is_active boolean NOT NULL -- indicates if active is true,
  address character varying(128),
  trade_id text NOT NULL -- reference to trades.payment_id,
  FOREIGN KEY (trade_id) REFERENCES trades(payment_id)
)

CREATE TABLE tradingplatform.trades (
  payment_id text PRIMARY KEY -- unique identifier,
  completed_at timestamp,
  card_type character varying(256),
  user_id character varying(256) -- identifier for user,
  approval_status character varying(128),
  customer_id text -- identifier for customer,
  seller_id character varying(64),
  discount smallint
)

CREATE TABLE tradingplatform.metadata (
  location_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  address_line2 varchar,
  location_lat character varying(256),
  state text,
  parking_available char NOT NULL
)

[User] Display all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Show me website, trade_id, seller_id, completed_at from logs and their related trades.

[Assistant] SELECT *, trades.seller_id, trades.completed_at FROM tradingplatform.logs JOIN tradingplatform.trades ON logs.trade_id = trades.payment_id;

[User] Get the distribution of logs across different address values.

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


[User] Show me all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] What is_active, trade_id, user_id, discount do we have for logs and their associated trades?

[Assistant] SELECT *, trades.user_id, trades.discount FROM tradingplatform.logs JOIN tradingplatform.trades ON logs.trade_id = trades.payment_id;

[User] Limit the results to 25 rows.

[Assistant] SELECT *, trades.user_id, trades.discount FROM tradingplatform.logs JOIN tradingplatform.trades ON logs.trade_id = trades.payment_id LIMIT 25;


[User] List all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Show me logs with last_active > '2023-01-01'.

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

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

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


[User] What are the is_active, is_verified, email of each log?

[Assistant] SELECT is_active, is_verified, email FROM tradingplatform.logs;

[User] Show the results sorted by is_active ascending.

[Assistant] SELECT is_active, is_verified, email FROM tradingplatform.logs ORDER BY is_active ASC;

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

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


[User] Show me website, token, is_active for all logs.

[Assistant] SELECT website, token, is_active FROM tradingplatform.logs;

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

[Assistant] SELECT website, token, is_active FROM tradingplatform.logs ORDER BY updated_at ASC;

[User] Group logs by is_active and show the min of token.

[Assistant] SELECT is_active, MIN(token) AS min_token FROM tradingplatform.logs GROUP BY is_active;


[User] Get is_active, is_verified, website from all logs.

[Assistant] SELECT is_active, is_verified, website FROM tradingplatform.logs;

[User] Can you order these by trade_id descending?

[Assistant] SELECT is_active, is_verified, website FROM tradingplatform.logs ORDER BY trade_id DESC;

[User] What is the count token for each token in logs?

[Assistant] SELECT token, COUNT(token) AS count_token FROM tradingplatform.logs GROUP BY token;


[User] List all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

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

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

[User] How many logs are there per token?

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


[User] List all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Find logs between January and March.

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

[User] Tally up logs by token.

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


[User] What are the token, is_verified, last_active of each log?

[Assistant] SELECT token, is_verified, last_active FROM tradingplatform.logs;

[User] Retrieve token, updated_at, customer_id, seller_id showing the relationship between logs and trades.

[Assistant] SELECT token, is_verified, last_active, trades.customer_id, trades.seller_id FROM tradingplatform.logs JOIN tradingplatform.trades ON logs.trade_id = trades.payment_id;

[User] Get max of email by token from logs.

[Assistant] SELECT token, MAX(email) AS max_email FROM tradingplatform.logs GROUP BY token;


[User] List is_active, updated_at, email from logs.

[Assistant] SELECT is_active, updated_at, email FROM tradingplatform.logs;

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

[Assistant] SELECT is_active, updated_at, email FROM tradingplatform.logs WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Show only 100 records.

[Assistant] SELECT is_active, updated_at, email FROM tradingplatform.logs WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' 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.billing (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  updated_at timestamp without time zone,
  email char,
  api_key character varying(64),
  gender text,
  display_name character varying(256),
  salt char,
  first_name character varying(64),
  medical_record_id text -- reference to medical_records.comment_id,
  FOREIGN KEY (medical_record_id) REFERENCES medical_records(comment_id)
)

CREATE TABLE healthcare.medical_records (
  comment_id varchar PRIMARY KEY -- unique identifier,
  edited_at date,
  subject text,
  user_id character varying(128),
  image_url character varying(64),
  body text,
  attachment_url text
)

CREATE TABLE healthcare.departments (
  customer_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  updated_at date,
  api_key char,
  address char,
  status text,
  username char,
  city character varying(128),
  membership_level character varying(128),
  medical_record_id text -- reference to medical_records.comment_id,
  FOREIGN KEY (medical_record_id) REFERENCES medical_records(comment_id)
)

CREATE TABLE healthcare.appointments (
  address_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  longitude varchar NOT NULL,
  capacity character varying(128) NOT NULL,
  address_line1 character varying(128),
  billin_id text NOT NULL -- reference to billing.id,
  FOREIGN KEY (billin_id) REFERENCES billing(id)
)

[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] How many billing are there per gender?

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


[User] Display all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] Only show the top 100 results.

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


[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

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

[Assistant] SELECT * FROM healthcare.appointments ORDER BY longitude ASC;

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

[Assistant] SELECT * FROM healthcare.appointments ORDER BY updated_at ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE insurance.reservations (
  order_id varchar PRIMARY KEY -- unique identifier,
  processed_at date,
  traded_at date,
  payment_method character varying(256),
  status varchar,
  user_id text NOT NULL,
  payment_status character varying(128)
)

CREATE TABLE insurance.items (
  product_id character varying(64) NOT NULL -- unique identifier,
  expires_at date,
  views char,
  backorder char,
  manufacturer character varying(64),
  title varchar NOT NULL
)

CREATE TABLE insurance.posts (
  comment_id character varying(64) NOT NULL -- unique identifier,
  edited_at timestamp without time zone,
  categories character varying(64),
  user_id character varying(128) -- identifier for user,
  rating character varying(256) NOT NULL,
  message character varying(64)
)

[User] Retrieve views, expires_at, backorder for every item.

[Assistant] SELECT views, expires_at, backorder FROM insurance.items;

[User] Show me items that were from 2023.

[Assistant] SELECT views, expires_at, backorder FROM insurance.items WHERE expires_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Get the distribution of items across different backorder values.

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


[User] Retrieve all reservations.

[Assistant] SELECT * FROM insurance.reservations;

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

[Assistant] SELECT * FROM insurance.reservations WHERE traded_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Get min of payment_status by processed_at from reservations.

[Assistant] SELECT processed_at, MIN(payment_status) AS min_payment_status FROM insurance.reservations GROUP BY processed_at;


[User] Retrieve all items.

[Assistant] SELECT * FROM insurance.items;

[User] Get all items created yesterday.

[Assistant] SELECT * FROM insurance.items WHERE expires_at = CURRENT_DATE - INTERVAL '1 day';

[User] Tally up items by title.

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


[User] Show me edited_at, user_id, comment_id for all posts.

[Assistant] SELECT edited_at, user_id, comment_id FROM insurance.posts;

[User] List posts with dates from last week.

[Assistant] SELECT edited_at, user_id, comment_id FROM insurance.posts WHERE edited_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Show only 10 records.

[Assistant] SELECT edited_at, user_id, comment_id FROM insurance.posts WHERE edited_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 10;


[User] List backorder, views, product_id from items.

[Assistant] SELECT backorder, views, product_id FROM insurance.items;

[User] Show the results sorted by title ascending.

[Assistant] SELECT backorder, views, product_id FROM insurance.items ORDER BY title ASC;

[User] Get the distribution of items across different views values.

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


[User] Show me all reservations.

[Assistant] SELECT * FROM insurance.reservations;

[User] Show the results sorted by payment_method ascending.

[Assistant] SELECT * FROM insurance.reservations ORDER BY payment_method ASC;

[User] Show the results sorted by processed_at descending.

[Assistant] SELECT * FROM insurance.reservations ORDER BY processed_at DESC;


[User] List title, expires_at, backorder from items.

[Assistant] SELECT title, expires_at, backorder FROM insurance.items;

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

[Assistant] SELECT title, expires_at, backorder FROM insurance.items ORDER BY manufacturer DESC;

[User] Count the number of items in each title category.

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


[User] Get rating, user_id, message from all posts.

[Assistant] SELECT rating, user_id, message FROM insurance.posts;

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

[Assistant] SELECT rating, user_id, message FROM insurance.posts WHERE edited_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Show the results sorted by edited_at ascending.

[Assistant] SELECT rating, user_id, message FROM insurance.posts WHERE edited_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY edited_at ASC;


[User] Display all reservations.

[Assistant] SELECT * FROM insurance.reservations;

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

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

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

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


[User] Retrieve all items.

[Assistant] SELECT * FROM insurance.items;

[User] Find items older than 6 months.

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

[User] Limit the results to 5 rows.

[Assistant] SELECT * FROM insurance.items WHERE expires_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 5;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.shipping (
  transaction_id text PRIMARY KEY -- unique identifier,
  created_at date,
  cancelled_at date,
  seller_id text,
  account_id char,
  amount smallint NOT NULL,
  delivery_status character varying(64),
  card_type character varying(256) NOT NULL
)

CREATE TABLE e-commerce.inventory (
  id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp,
  thumbnail_url char,
  price integer,
  cost numeric NOT NULL,
  quantity text,
  shippin_id text -- reference to shipping.transaction_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(transaction_id)
)

[User] Get cost, id, thumbnail_url from all inventory.

[Assistant] SELECT cost, id, thumbnail_url FROM e-commerce.inventory;

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

[Assistant] SELECT cost, id, thumbnail_url FROM e-commerce.inventory WHERE published_at > '2023-01-01';

[User] Get the distribution of inventory across different quantity values.

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


[User] Display all inventory.

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

[User] Get inventory that match price > 95.

[Assistant] SELECT * FROM e-commerce.inventory WHERE price > 95;

[User] Show the results sorted by quantity ascending.

[Assistant] SELECT * FROM e-commerce.inventory WHERE price > 95 ORDER BY quantity ASC;


[User] List all inventory.

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

[User] Show me inventory with price > 20.

[Assistant] SELECT * FROM e-commerce.inventory WHERE price > 20;

[User] Can you order these by published_at descending?

[Assistant] SELECT * FROM e-commerce.inventory WHERE price > 20 ORDER BY published_at DESC;


[User] List price, published_at, cost from inventory.

[Assistant] SELECT price, published_at, cost FROM e-commerce.inventory;

[User] Can you order these by published_at ascending?

[Assistant] SELECT price, published_at, cost FROM e-commerce.inventory ORDER BY published_at ASC;

[User] Show the results sorted by cost descending.

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


[User] Show me all inventory.

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

[User] Find inventory modified within the last hour.

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

[User] Return just 100 rows.

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


[User] List price, id, thumbnail_url from inventory.

[Assistant] SELECT price, id, thumbnail_url FROM e-commerce.inventory;

[User] Can you order these by cost descending?

[Assistant] SELECT price, id, thumbnail_url FROM e-commerce.inventory ORDER BY cost DESC;

[User] Order the output by shippin_id descending.

[Assistant] SELECT price, id, thumbnail_url FROM e-commerce.inventory ORDER BY shippin_id DESC;


[User] List all inventory.

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

[User] List inventory that have quantity LIKE 'A%'.

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

[User] Group inventory by cost and show the count of shippin_id.

[Assistant] SELECT cost, COUNT(shippin_id) AS count_shippin_id FROM e-commerce.inventory GROUP BY cost;


[User] Retrieve cost, id, thumbnail_url for every inventory.

[Assistant] SELECT cost, id, thumbnail_url FROM e-commerce.inventory;

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

[Assistant] SELECT cost, id, thumbnail_url FROM e-commerce.inventory ORDER BY cost ASC;

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

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


[User] Retrieve all inventory.

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

[User] Find inventory where thumbnail_url LIKE 'A%'.

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

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

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


[User] List price, id, thumbnail_url from inventory.

[Assistant] SELECT price, id, thumbnail_url FROM e-commerce.inventory;

[User] What thumbnail_url, price, delivery_status, created_at do we have for inventory and their associated shipping?

[Assistant] SELECT price, id, thumbnail_url, shipping.delivery_status, shipping.created_at FROM e-commerce.inventory JOIN e-commerce.shipping ON inventory.shippin_id = shipping.transaction_id;

[User] Group inventory by shippin_id and show the min of cost.

[Assistant] SELECT shippin_id, MIN(cost) AS min_cost FROM e-commerce.inventory GROUP BY shippin_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 education.enrollments (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  last_inspected timestamp without time zone,
  name varchar NOT NULL,
  city character varying(128),
  state character varying(256) NOT NULL,
  description character varying(128) NOT NULL,
  country varchar NOT NULL,
  accessibility varchar,
  type character varying(128),
  student_id text NOT NULL -- reference to students.customer_id,
  FOREIGN KEY (student_id) REFERENCES students(customer_id)
)

CREATE TABLE education.courses (
  content_id character varying(64) NOT NULL -- unique identifier,
  published_at date,
  subject char,
  user_id character varying(64) -- identifier for user,
  body character varying(256),
  attachment_url character varying(128) NOT NULL,
  message character varying(128) NOT NULL,
  student_id text NOT NULL -- reference to students.customer_id,
  enrollment_id text NOT NULL -- reference to enrollments.id,
  FOREIGN KEY (student_id) REFERENCES students(customer_id),
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(id)
)

CREATE TABLE education.students (
  customer_id varchar PRIMARY KEY -- unique identifier,
  last_active timestamp,
  display_name character varying(256),
  last_name character varying(128),
  password_hash character varying(128) NOT NULL,
  enrollment_id text -- reference to enrollments.id,
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(id)
)

[User] Retrieve all students.

[Assistant] SELECT * FROM education.students;

[User] Find students where enrollment_id LIKE 'A%'.

[Assistant] SELECT * FROM education.students WHERE enrollment_id LIKE 'A%';

[User] Tally up students by display_name.

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


[User] Show me all students.

[Assistant] SELECT * FROM education.students;

[User] Order the output by last_name descending.

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

[User] Calculate min of last_active for each display_name in students.

[Assistant] SELECT display_name, MIN(last_active) AS min_last_active FROM education.students GROUP BY display_name;


[User] Display all courses.

[Assistant] SELECT * FROM education.courses;

[User] Can you order these by user_id descending?

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

[User] Only show the top 10 results.

[Assistant] SELECT * FROM education.courses ORDER BY user_id DESC LIMIT 10;


[User] Retrieve all students.

[Assistant] SELECT * FROM education.students;

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

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

[User] How many students are there per display_name?

[Assistant] SELECT display_name, COUNT(*) AS count FROM education.students GROUP BY display_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 socialmedia.groups (
  id varchar PRIMARY KEY -- unique identifier,
  last_inspected date,
  capacity character varying(128),
  country char,
  location_lat text NOT NULL,
  like_id text -- reference to likes.product_id,
  FOREIGN KEY (like_id) REFERENCES likes(product_id)
)

CREATE TABLE socialmedia.users (
  id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  age varchar,
  status character varying(256),
  language text,
  nationality text NOT NULL
)

CREATE TABLE socialmedia.events (
  payment_id integer PRIMARY KEY -- unique identifier,
  cancelled_at timestamp without time zone,
  created_at date,
  subtotal decimal,
  buyer_id character varying(128),
  seller_id character varying(128) NOT NULL,
  discount decimal,
  delivery_status character varying(256),
  group_id text NOT NULL -- reference to groups.id,
  FOREIGN KEY (group_id) REFERENCES groups(id)
)

CREATE TABLE socialmedia.likes (
  product_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  category character varying(256) NOT NULL,
  brand character varying(256) NOT NULL,
  cost numeric(38,14)
)

[User] List cancelled_at, seller_id, created_at from events.

[Assistant] SELECT cancelled_at, seller_id, created_at FROM socialmedia.events;

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

[Assistant] SELECT cancelled_at, seller_id, created_at FROM socialmedia.events WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Tally up events by group_id.

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


[User] What are the like_id, country, last_inspected of each group?

[Assistant] SELECT like_id, country, last_inspected FROM socialmedia.groups;

[User] Can you order these by country ascending?

[Assistant] SELECT like_id, country, last_inspected FROM socialmedia.groups ORDER BY country ASC;

[User] Return just 15 rows.

[Assistant] SELECT like_id, country, last_inspected FROM socialmedia.groups ORDER BY country ASC LIMIT 15;


[User] Display all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Show me country, last_inspected, created_at, cost from groups and their related likes.

[Assistant] SELECT *, likes.created_at, likes.cost FROM socialmedia.groups JOIN socialmedia.likes ON groups.like_id = likes.product_id;

[User] Can you order these by country ascending?

[Assistant] SELECT *, likes.created_at, likes.cost FROM socialmedia.groups JOIN socialmedia.likes ON groups.like_id = likes.product_id ORDER BY country ASC;


[User] Retrieve all events.

[Assistant] SELECT * FROM socialmedia.events;

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

[Assistant] SELECT * FROM socialmedia.events WHERE delivery_status LIKE 'A%';

[User] Only show the top 5 results.

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


[User] What are the last_inspected, country, location_lat of each group?

[Assistant] SELECT last_inspected, country, location_lat FROM socialmedia.groups;

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

[Assistant] SELECT last_inspected, country, location_lat FROM socialmedia.groups ORDER BY location_lat ASC;

[User] Sort the results by like_id descending.

[Assistant] SELECT last_inspected, country, location_lat FROM socialmedia.groups ORDER BY like_id DESC;


[User] Show me all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Show the results sorted by buyer_id ascending.

[Assistant] SELECT * FROM socialmedia.events ORDER BY buyer_id ASC;

[User] Restrict the output to 25 items.

[Assistant] SELECT * FROM socialmedia.events ORDER BY buyer_id ASC LIMIT 25;


[User] List all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] List country, location_lat, cost, category for each group along with their like information.

[Assistant] SELECT *, likes.cost, likes.category FROM socialmedia.groups JOIN socialmedia.likes ON groups.like_id = likes.product_id;

[User] Show only 25 records.

[Assistant] SELECT *, likes.cost, likes.category FROM socialmedia.groups JOIN socialmedia.likes ON groups.like_id = likes.product_id LIMIT 25;


[User] List discount, group_id, created_at from events.

[Assistant] SELECT discount, group_id, created_at FROM socialmedia.events;

[User] What subtotal, delivery_status, capacity, last_inspected do we have for events and their associated groups?

[Assistant] SELECT discount, group_id, created_at, groups.capacity, groups.last_inspected FROM socialmedia.events JOIN socialmedia.groups ON events.group_id = groups.id;

[User] Show the results sorted by discount descending.

[Assistant] SELECT discount, group_id, created_at, groups.capacity, groups.last_inspected FROM socialmedia.events JOIN socialmedia.groups ON events.group_id = groups.id ORDER BY discount DESC;


[User] Show me all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Show me capacity, like_id, category, created_at from groups and their related likes.

[Assistant] SELECT *, likes.category, likes.created_at FROM socialmedia.groups JOIN socialmedia.likes ON groups.like_id = likes.product_id;

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

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


[User] Get all events.

[Assistant] SELECT * FROM socialmedia.events;

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

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

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

[Assistant] SELECT * FROM socialmedia.events WHERE cancelled_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY group_id ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.doctors (
  venue_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  parking_available character varying(128) NOT NULL,
  capacity character varying(128),
  operating_hours character varying(256),
  billin_id text NOT NULL -- reference to billing.venue_id,
  FOREIGN KEY (billin_id) REFERENCES billing(venue_id)
)

CREATE TABLE healthcare.billing (
  venue_id varchar PRIMARY KEY -- unique identifier,
  last_inspected timestamp without time zone,
  operating_hours character varying(64),
  location_lat character varying(256),
  location_lon char,
  zip_code text,
  longitude character varying(256),
  doctor_id text NOT NULL -- reference to doctors.venue_id,
  appointment_id text -- reference to appointments.address_id,
  FOREIGN KEY (doctor_id) REFERENCES doctors(venue_id),
  FOREIGN KEY (appointment_id) REFERENCES appointments(address_id)
)

CREATE TABLE healthcare.appointments (
  address_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  last_inspected timestamp without time zone,
  accessibility character varying(128),
  parking_available char,
  city character varying(128),
  type character varying(256) NOT NULL,
  timezone varchar
)

[User] Show me capacity, operating_hours, parking_available for all doctors.

[Assistant] SELECT capacity, operating_hours, parking_available FROM healthcare.doctors;

[User] Get all doctors from 2023.

[Assistant] SELECT capacity, operating_hours, parking_available FROM healthcare.doctors WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31';

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

[Assistant] SELECT capacity, operating_hours, parking_available FROM healthcare.doctors WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY operating_hours ASC;


[User] Retrieve parking_available, updated_at, capacity for every doctor.

[Assistant] SELECT parking_available, updated_at, capacity FROM healthcare.doctors;

[User] Show the results sorted by capacity descending.

[Assistant] SELECT parking_available, updated_at, capacity FROM healthcare.doctors ORDER BY capacity DESC;

[User] Show the results sorted by parking_available descending.

[Assistant] SELECT parking_available, updated_at, capacity FROM healthcare.doctors ORDER BY parking_available DESC;


[User] Retrieve capacity, parking_available, operating_hours for every doctor.

[Assistant] SELECT capacity, parking_available, operating_hours FROM healthcare.doctors;

[User] Show me doctors with parking_available LIKE 'A%'.

[Assistant] SELECT capacity, parking_available, operating_hours FROM healthcare.doctors WHERE parking_available LIKE 'A%';

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

[Assistant] SELECT capacity, parking_available, operating_hours FROM healthcare.doctors WHERE parking_available LIKE 'A%' ORDER BY capacity ASC;


[User] Retrieve appointment_id, location_lat, operating_hours for every billing.

[Assistant] SELECT appointment_id, location_lat, operating_hours FROM healthcare.billing;

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

[Assistant] SELECT appointment_id, location_lat, operating_hours FROM healthcare.billing WHERE last_inspected > '2023-12-01';

[User] Show the results sorted by last_inspected descending.

[Assistant] SELECT appointment_id, location_lat, operating_hours FROM healthcare.billing WHERE last_inspected > '2023-12-01' ORDER BY last_inspected DESC;


[User] Retrieve all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] Group billing by last_inspected and show the min of zip_code.

[Assistant] SELECT last_inspected, MIN(zip_code) AS min_zip_code FROM healthcare.billing GROUP BY last_inspected;


[User] Retrieve all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

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

[User] Sort the results by parking_available ascending.

[Assistant] SELECT * FROM healthcare.doctors WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY parking_available ASC;


[User] List all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

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

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


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] List updated_at, parking_available, last_inspected, location_lon for each doctor along with their billing information.

[Assistant] SELECT *, billing.last_inspected, billing.location_lon FROM healthcare.doctors JOIN healthcare.billing ON doctors.billin_id = billing.venue_id;

[User] Only show the top 25 results.

[Assistant] SELECT *, billing.last_inspected, billing.location_lon FROM healthcare.doctors JOIN healthcare.billing ON doctors.billin_id = billing.venue_id LIMIT 25;


[User] List zip_code, doctor_id, last_inspected from billing.

[Assistant] SELECT zip_code, doctor_id, last_inspected FROM healthcare.billing;

[User] Get appointment_id, operating_hours, capacity, operating_hours by joining billing with doctors.

[Assistant] SELECT zip_code, doctor_id, last_inspected, doctors.capacity, doctors.operating_hours FROM healthcare.billing JOIN healthcare.doctors ON billing.doctor_id = doctors.venue_id;

[User] What is the sum doctor_id for each location_lon in billing?

[Assistant] SELECT location_lon, SUM(doctor_id) AS sum_doctor_id FROM healthcare.billing GROUP BY location_lon;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE media.purchases (
  order_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  amount numeric,
  exchange_rate character varying(128),
  total integer NOT NULL,
  card_type char NOT NULL,
  price bigint,
  store_id text -- reference to stores.id,
  account_id text NOT NULL -- reference to accounts.account_id,
  FOREIGN KEY (store_id) REFERENCES stores(id),
  FOREIGN KEY (account_id) REFERENCES accounts(account_id)
)

CREATE TABLE media.accounts (
  account_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  verification_status char,
  amount numeric NOT NULL,
  payee_id varchar NOT NULL -- identifier for payee,
  vendor_id text -- identifier for vendor,
  balance numeric,
  purchase_id text NOT NULL -- reference to purchases.order_id,
  FOREIGN KEY (purchase_id) REFERENCES purchases(order_id)
)

CREATE TABLE media.stores (
  id text PRIMARY KEY -- unique identifier,
  last_inspected timestamp without time zone,
  updated_at timestamp,
  zip_code varchar NOT NULL,
  parking_available text,
  location_lat char,
  geo_point char,
  country text NOT NULL,
  name char,
  description character varying(256) NOT NULL,
  account_id text NOT NULL -- reference to accounts.account_id,
  FOREIGN KEY (account_id) REFERENCES accounts(account_id)
)

[User] List all stores.

[Assistant] SELECT * FROM media.stores;

[User] Find stores between January and March.

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

[User] Only show the top 10 results.

[Assistant] SELECT * FROM media.stores WHERE last_inspected BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 10;


[User] Display all accounts.

[Assistant] SELECT * FROM media.accounts;

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

[Assistant] SELECT * FROM media.accounts ORDER BY verification_status ASC;

[User] Can you order these by updated_at descending?

[Assistant] SELECT * FROM media.accounts ORDER BY updated_at DESC;


[User] What are the balance, vendor_id, purchase_id of each account?

[Assistant] SELECT balance, vendor_id, purchase_id FROM media.accounts;

[User] Sort the results by payee_id descending.

[Assistant] SELECT balance, vendor_id, purchase_id FROM media.accounts ORDER BY payee_id DESC;

[User] Show only 5 records.

[Assistant] SELECT balance, vendor_id, purchase_id FROM media.accounts ORDER BY payee_id DESC LIMIT 5;


[User] Get account_id, country, updated_at from all stores.

[Assistant] SELECT account_id, country, updated_at FROM media.stores;

[User] Show the results sorted by description ascending.

[Assistant] SELECT account_id, country, updated_at FROM media.stores ORDER BY description ASC;

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

[Assistant] SELECT account_id, country, updated_at FROM media.stores ORDER BY geo_point DESC;


[User] Show me description, geo_point, country for all stores.

[Assistant] SELECT description, geo_point, country FROM media.stores;

[User] Get stores that match account_id LIKE 'A%'.

[Assistant] SELECT description, geo_point, country FROM media.stores WHERE account_id LIKE 'A%';

[User] Return just 20 rows.

[Assistant] SELECT description, geo_point, country FROM media.stores WHERE account_id LIKE 'A%' LIMIT 20;


[User] Show me account_id, card_type, exchange_rate for all purchases.

[Assistant] SELECT account_id, card_type, exchange_rate FROM media.purchases;

[User] Can you order these by price descending?

[Assistant] SELECT account_id, card_type, exchange_rate FROM media.purchases ORDER BY price DESC;

[User] Can you order these by card_type ascending?

[Assistant] SELECT account_id, card_type, exchange_rate FROM media.purchases ORDER BY card_type ASC;


[User] Retrieve all stores.

[Assistant] SELECT * FROM media.stores;

[User] Get stores that match parking_available LIKE 'A%'.

[Assistant] SELECT * FROM media.stores WHERE parking_available LIKE 'A%';

[User] Show only 5 records.

[Assistant] SELECT * FROM media.stores WHERE parking_available LIKE 'A%' LIMIT 5;


[User] Retrieve all purchases.

[Assistant] SELECT * FROM media.purchases;

[User] Show me exchange_rate, account_id, description, zip_code from purchases and their related stores.

[Assistant] SELECT *, stores.description, stores.zip_code FROM media.purchases JOIN media.stores ON purchases.store_id = stores.id;

[User] Tally up purchases by store_id.

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


[User] What are the balance, purchase_id, updated_at of each account?

[Assistant] SELECT balance, purchase_id, updated_at FROM media.accounts;

[User] Can you order these by verification_status descending?

[Assistant] SELECT balance, purchase_id, updated_at FROM media.accounts ORDER BY verification_status DESC;

[User] Show the results sorted by amount ascending.

[Assistant] SELECT balance, purchase_id, updated_at FROM media.accounts ORDER BY amount 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.accounts (
  transaction_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  notes character varying(256) NOT NULL,
  credit char,
  reference_number varchar,
  approval_status text,
  reconciliation_status character varying(256) NOT NULL,
  customer_id text -- reference to customers.customer_id,
  FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
)

CREATE TABLE finance.payments (
  order_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  cancelled_at timestamp without time zone,
  delivery_status varchar,
  product_id character varying(256),
  amount bigint,
  seller_id character varying(128) -- identifier for seller,
  payment_status char NOT NULL,
  customer_id text NOT NULL -- reference to customers.customer_id,
  FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
)

CREATE TABLE finance.customers (
  customer_id varchar PRIMARY KEY -- unique identifier,
  joined_at date,
  updated_at timestamp without time zone,
  account_status character varying(256),
  gender character varying(256),
  phone varchar,
  email character varying(256),
  payment_id text NOT NULL -- reference to payments.order_id,
  FOREIGN KEY (payment_id) REFERENCES payments(order_id)
)

[User] Retrieve all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Retrieve customer_id, cancelled_at, joined_at, gender showing the relationship between payments and customers.

[Assistant] SELECT *, customers.joined_at, customers.gender FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.customer_id;

[User] Show the results sorted by seller_id ascending.

[Assistant] SELECT *, customers.joined_at, customers.gender FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.customer_id ORDER BY seller_id ASC;


[User] Show me reference_number, reconciliation_status, credit for all accounts.

[Assistant] SELECT reference_number, reconciliation_status, credit FROM finance.accounts;

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

[Assistant] SELECT reference_number, reconciliation_status, credit FROM finance.accounts WHERE notes LIKE 'A%';

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

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


[User] List all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] Get reference_number, customer_id, phone, account_status by joining accounts with customers.

[Assistant] SELECT *, customers.phone, customers.account_status FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.customer_id;

[User] Show the results sorted by credit descending.

[Assistant] SELECT *, customers.phone, customers.account_status FROM finance.accounts JOIN finance.customers ON accounts.customer_id = customers.customer_id ORDER BY credit DESC;


[User] Retrieve all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Can you order these by updated_at ascending?

[Assistant] SELECT * FROM finance.customers WHERE joined_at > '2023-12-01' ORDER BY updated_at ASC;


[User] List account_status, joined_at, updated_at from customers.

[Assistant] SELECT account_status, joined_at, updated_at FROM finance.customers;

[User] Find customers where phone LIKE 'A%'.

[Assistant] SELECT account_status, joined_at, updated_at FROM finance.customers WHERE phone LIKE 'A%';

[User] Show only 25 records.

[Assistant] SELECT account_status, joined_at, updated_at FROM finance.customers WHERE phone LIKE 'A%' LIMIT 25;


[User] Show me payment_status, cancelled_at, processed_at for all payments.

[Assistant] SELECT payment_status, cancelled_at, processed_at FROM finance.payments;

[User] Order the output by customer_id ascending.

[Assistant] SELECT payment_status, cancelled_at, processed_at FROM finance.payments ORDER BY customer_id ASC;

[User] Show me sum of processed_at grouped by delivery_status for payments.

[Assistant] SELECT delivery_status, SUM(processed_at) AS sum_processed_at FROM finance.payments GROUP BY delivery_status;


[User] Retrieve delivery_status, customer_id, processed_at for every payment.

[Assistant] SELECT delivery_status, customer_id, processed_at FROM finance.payments;

[User] Show me payments with processed_at > '2023-01-01'.

[Assistant] SELECT delivery_status, customer_id, processed_at FROM finance.payments WHERE processed_at > '2023-01-01';

[User] Get average of customer_id by cancelled_at from payments.

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


[User] List processed_at, delivery_status, customer_id from payments.

[Assistant] SELECT processed_at, delivery_status, customer_id FROM finance.payments;

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

[Assistant] SELECT processed_at, delivery_status, customer_id FROM finance.payments WHERE cancelled_at > '2023-12-01';

[User] Show me the count of payments grouped by processed_at.

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


[User] Show me all payments.

[Assistant] SELECT * FROM finance.payments;

[User] What cancelled_at, processed_at, email, joined_at do we have for payments and their associated customers?

[Assistant] SELECT *, customers.email, customers.joined_at FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.customer_id;

[User] Order the output by amount descending.

[Assistant] SELECT *, customers.email, customers.joined_at FROM finance.payments JOIN finance.customers ON payments.customer_id = customers.customer_id ORDER BY amount DESC;


[User] Show me all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

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

[User] Show the results sorted by reference_number ascending.

[Assistant] SELECT * FROM finance.accounts WHERE updated_at > '2023-01-01' ORDER BY reference_number 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.departments (
  payment_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  product_id text -- identifier for product,
  subtotal smallint,
  discount numeric,
  card_type text NOT NULL,
  fee character varying(128)
)

CREATE TABLE education.grades (
  barcode character varying(64) NOT NULL -- unique identifier,
  expires_at timestamp,
  thumbnail_url char,
  image_url character varying(64) NOT NULL,
  price integer NOT NULL,
  department_id text -- reference to departments.payment_id,
  FOREIGN KEY (department_id) REFERENCES departments(payment_id)
)

[User] What are the image_url, price, expires_at of each grade?

[Assistant] SELECT image_url, price, expires_at FROM education.grades;

[User] Get price, thumbnail_url, card_type, subtotal by joining grades with departments.

[Assistant] SELECT image_url, price, expires_at, departments.card_type, departments.subtotal FROM education.grades JOIN education.departments ON grades.department_id = departments.payment_id;

[User] Get min of barcode by price from grades.

[Assistant] SELECT price, MIN(barcode) AS min_barcode FROM education.grades GROUP BY price;


[User] Retrieve all grades.

[Assistant] SELECT * FROM education.grades;

[User] Show the results sorted by expires_at descending.

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

[User] Order the output by barcode ascending.

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


[User] Show me all grades.

[Assistant] SELECT * FROM education.grades;

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

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

[User] Tally up grades by image_url.

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


[User] Get all grades.

[Assistant] SELECT * FROM education.grades;

[User] Show me expires_at, thumbnail_url, processed_at, card_type from grades and their related departments.

[Assistant] SELECT *, departments.processed_at, departments.card_type FROM education.grades JOIN education.departments ON grades.department_id = departments.payment_id;

[User] Show me the count of grades grouped by thumbnail_url.

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


[User] Retrieve all grades.

[Assistant] SELECT * FROM education.grades;

[User] Show me grades that were older than 6 months.

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

[User] What is the max image_url for each department_id in grades?

[Assistant] SELECT department_id, MAX(image_url) AS max_image_url FROM education.grades GROUP BY department_id;


[User] List all grades.

[Assistant] SELECT * FROM education.grades;

[User] Find grades older than 6 months.

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

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

[Assistant] SELECT * FROM education.grades WHERE expires_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY department_id ASC;


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

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

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

[Assistant] SELECT barcode, price, department_id FROM education.grades WHERE expires_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Get average of thumbnail_url by thumbnail_url from grades.

[Assistant] SELECT thumbnail_url, AVERAGE(thumbnail_url) AS average_thumbnail_url FROM education.grades GROUP BY thumbnail_url;


[User] List thumbnail_url, image_url, price from grades.

[Assistant] SELECT thumbnail_url, image_url, price FROM education.grades;

[User] List barcode, image_url, fee, card_type for each grade along with their department information.

[Assistant] SELECT thumbnail_url, image_url, price, departments.fee, departments.card_type FROM education.grades JOIN education.departments ON grades.department_id = departments.payment_id;

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

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


[User] Retrieve barcode, image_url, department_id for every grade.

[Assistant] SELECT barcode, image_url, department_id FROM education.grades;

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

[Assistant] SELECT barcode, image_url, department_id FROM education.grades WHERE expires_at > '2023-12-01';

[User] What is the average price for each barcode in grades?

[Assistant] SELECT barcode, AVERAGE(price) AS average_price FROM education.grades GROUP BY barcode;


[User] Show me all grades.

[Assistant] SELECT * FROM education.grades;

[User] Show me price, expires_at, card_type, product_id from grades and their related departments.

[Assistant] SELECT *, departments.card_type, departments.product_id FROM education.grades JOIN education.departments ON grades.department_id = departments.payment_id;

[User] Tally up grades by expires_at.

[Assistant] SELECT expires_at, COUNT(*) AS count FROM education.grades GROUP BY expires_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 e-commerce.products (
  sku character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  published_at date,
  stock_level character varying(64),
  reserved varchar,
  rating text,
  popularity_score character varying(64),
  title character varying(128),
  user_id integer NOT NULL -- reference to users.user_id,
  FOREIGN KEY (user_id) REFERENCES users(user_id)
)

CREATE TABLE e-commerce.users (
  user_id integer PRIMARY KEY -- unique identifier,
  joined_at date,
  updated_at timestamp without time zone,
  account_status varchar NOT NULL,
  website character varying(64),
  last_login timestamp without time zone,
  api_key char,
  order_item_id text NOT NULL -- reference to order_items.transaction_id,
  FOREIGN KEY (order_item_id) REFERENCES order_items(transaction_id)
)

CREATE TABLE e-commerce.orders (
  id integer PRIMARY KEY -- unique identifier,
  created_at date,
  price numeric(38,14),
  discount decimal NOT NULL,
  payment_status text
)

CREATE TABLE e-commerce.inventory (
  id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp,
  thumbnail_url text,
  media_url character varying(64),
  title char NOT NULL
)

CREATE TABLE e-commerce.order_items (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  processed_at timestamp,
  amount smallint,
  description character varying(64),
  approval_status varchar
)

[User] Show me all products.

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

[User] Order the output by title descending.

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

[User] Show me the count of products grouped by stock_level.

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


[User] List all users.

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

[User] Can you order these by updated_at ascending?

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

[User] Show only 25 records.

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


[User] List all users.

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

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

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

[User] Show me count of api_key grouped by last_login for users.

[Assistant] SELECT last_login, COUNT(api_key) AS count_api_key FROM e-commerce.users GROUP BY last_login;


[User] Retrieve all users.

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

[User] Retrieve users where order_item_id LIKE 'A%'.

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

[User] Sort the results by last_login ascending.

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


[User] List all products.

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

[User] Find products where rating LIKE 'A%'.

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

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

[Assistant] SELECT stock_level, MIN(user_id) AS min_user_id FROM e-commerce.products GROUP BY stock_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 healthcare.medical_records (
  product_id text PRIMARY KEY -- unique identifier,
  expires_at timestamp,
  created_at timestamp without time zone,
  discount numeric,
  brand character varying(256) NOT NULL,
  available text NOT NULL
)

CREATE TABLE healthcare.doctors (
  employee_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at date,
  username char,
  bio character varying(64),
  address text,
  phone character varying(64),
  last_name varchar
)

CREATE TABLE healthcare.departments (
  sku character varying(64) NOT NULL -- unique identifier,
  expires_at date,
  manufacturer char,
  subcategory char,
  category character varying(256) NOT NULL,
  rating text,
  popularity_score varchar,
  brand character varying(128) NOT NULL
)

CREATE TABLE healthcare.appointments (
  customer_id character varying(64) NOT NULL -- unique identifier,
  last_active date,
  avatar character varying(256),
  city char NOT NULL,
  state character varying(64),
  status character varying(64),
  timezone character varying(128)
)

CREATE TABLE healthcare.patients (
  employee_id character varying(64) NOT NULL -- unique identifier,
  joined_at date,
  username varchar NOT NULL,
  profile_picture_url character varying(64) NOT NULL,
  full_name text,
  medical_record_id text -- reference to medical_records.product_id,
  FOREIGN KEY (medical_record_id) REFERENCES medical_records(product_id)
)

[User] List all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Can you order these by full_name descending?

[Assistant] SELECT * FROM healthcare.patients ORDER BY full_name DESC;

[User] Limit the results to 20 rows.

[Assistant] SELECT * FROM healthcare.patients ORDER BY full_name DESC LIMIT 20;


[User] Show me username, joined_at, employee_id for all patients.

[Assistant] SELECT username, joined_at, employee_id FROM healthcare.patients;

[User] Can you order these by username descending?

[Assistant] SELECT username, joined_at, employee_id FROM healthcare.patients ORDER BY username DESC;

[User] Restrict the output to 5 items.

[Assistant] SELECT username, joined_at, employee_id FROM healthcare.patients ORDER BY username DESC LIMIT 5;


[User] Retrieve all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Show me patients with joined_at > '2023-01-01'.

[Assistant] SELECT * FROM healthcare.patients WHERE joined_at > '2023-01-01';

[User] Tally up patients by medical_record_id.

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


[User] Retrieve all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Order the output by profile_picture_url ascending.

[Assistant] SELECT * FROM healthcare.patients ORDER BY profile_picture_url ASC;

[User] Can you order these by medical_record_id descending?

[Assistant] SELECT * FROM healthcare.patients ORDER BY medical_record_id DESC;


[User] Get all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Find patients from 2023.

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

[User] Show only 50 records.

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


[User] Show me all patients.

[Assistant] SELECT * FROM healthcare.patients;

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

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

[User] Order the output by employee_id ascending.

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


[User] Display all patients.

[Assistant] SELECT * FROM healthcare.patients;

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

[Assistant] SELECT * FROM healthcare.patients ORDER BY joined_at ASC;

[User] What is the min medical_record_id for each employee_id in patients?

[Assistant] SELECT employee_id, MIN(medical_record_id) AS min_medical_record_id FROM healthcare.patients GROUP BY employee_id;


[User] List all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Retrieve patients where joined_at > '2023-01-01'.

[Assistant] SELECT * FROM healthcare.patients WHERE joined_at > '2023-01-01';

[User] Show only 25 records.

[Assistant] SELECT * FROM healthcare.patients WHERE joined_at > '2023-01-01' LIMIT 25;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.appointments (
  invoice_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  updated_at timestamp without time zone,
  balance numeric,
  notes text,
  vendor_id character varying(64),
  exchange_rate char,
  credit character varying(256) NOT NULL,
  patient_id integer -- reference to patients.person_id,
  FOREIGN KEY (patient_id) REFERENCES patients(person_id)
)

CREATE TABLE healthcare.patients (
  person_id integer PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  updated_at timestamp without time zone,
  last_name character varying(64) NOT NULL,
  state text,
  display_name character varying(64),
  appointment_id text -- reference to appointments.invoice_id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(invoice_id)
)

[User] List balance, patient_id, updated_at from appointments.

[Assistant] SELECT balance, patient_id, updated_at FROM healthcare.appointments;

[User] Retrieve appointments where vendor_id LIKE 'A%'.

[Assistant] SELECT balance, patient_id, updated_at FROM healthcare.appointments WHERE vendor_id LIKE 'A%';

[User] Show only 25 records.

[Assistant] SELECT balance, patient_id, updated_at FROM healthcare.appointments WHERE vendor_id LIKE 'A%' LIMIT 25;


[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Show the results sorted by patient_id ascending.

[Assistant] SELECT * FROM healthcare.appointments ORDER BY patient_id ASC;

[User] Restrict the output to 50 items.

[Assistant] SELECT * FROM healthcare.appointments ORDER BY patient_id ASC LIMIT 50;


[User] Display all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] What appointment_id, state, patient_id, credit do we have for patients and their associated appointments?

[Assistant] SELECT *, appointments.patient_id, appointments.credit FROM healthcare.patients JOIN healthcare.appointments ON patients.appointment_id = appointments.invoice_id;

[User] Show the results sorted by state descending.

[Assistant] SELECT *, appointments.patient_id, appointments.credit FROM healthcare.patients JOIN healthcare.appointments ON patients.appointment_id = appointments.invoice_id ORDER BY state DESC;


[User] Retrieve all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] List balance, patient_id, display_name, last_active for each appointment along with their patient information.

[Assistant] SELECT *, patients.display_name, patients.last_active FROM healthcare.appointments JOIN healthcare.patients ON appointments.patient_id = patients.person_id;

[User] Tally up appointments by balance.

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


[User] Get updated_at, created_at, vendor_id from all appointments.

[Assistant] SELECT updated_at, created_at, vendor_id FROM healthcare.appointments;

[User] Get all appointments from 2023.

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

[User] Return just 100 rows.

[Assistant] SELECT updated_at, created_at, vendor_id FROM healthcare.appointments WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 100;


[User] Retrieve display_name, appointment_id, last_active for every patient.

[Assistant] SELECT display_name, appointment_id, last_active FROM healthcare.patients;

[User] Show the results sorted by state descending.

[Assistant] SELECT display_name, appointment_id, last_active FROM healthcare.patients ORDER BY state DESC;

[User] Order the output by display_name descending.

[Assistant] SELECT display_name, appointment_id, last_active FROM healthcare.patients ORDER BY display_name DESC;


[User] Retrieve all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Retrieve appointments where balance > 5.

[Assistant] SELECT * FROM healthcare.appointments WHERE balance > 5;

[User] Calculate sum of notes for each exchange_rate in appointments.

[Assistant] SELECT exchange_rate, SUM(notes) AS sum_notes FROM healthcare.appointments GROUP BY exchange_rate;


[User] What are the updated_at, state, last_name of each patient?

[Assistant] SELECT updated_at, state, last_name FROM healthcare.patients;

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

[Assistant] SELECT updated_at, state, last_name FROM healthcare.patients WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] What is the average state for each updated_at in patients?

[Assistant] SELECT updated_at, AVERAGE(state) AS average_state FROM healthcare.patients GROUP BY updated_at;


[User] Show me all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

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

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

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

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


[User] Display all patients.

[Assistant] SELECT * FROM healthcare.patients;

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

[Assistant] SELECT * FROM healthcare.patients ORDER BY last_active DESC;

[User] Show the results sorted by appointment_id descending.

[Assistant] SELECT * FROM healthcare.patients ORDER BY appointment_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.shipping (
  payment_id integer PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  invoice_number character varying(256) NOT NULL,
  payer_id character varying(128),
  user_id character varying(64) -- identifier for user,
  balance integer,
  verification_status char
)

CREATE TABLE e-commerce.products (
  id character varying(64) NOT NULL -- unique identifier,
  expires_at timestamp without time zone,
  available character varying(256),
  quantity char,
  media_url char,
  name text NOT NULL,
  shippin_id integer -- reference to shipping.payment_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(payment_id)
)

CREATE TABLE e-commerce.categories (
  id varchar PRIMARY KEY -- unique identifier,
  joined_at date,
  created_at timestamp,
  last_login timestamp NOT NULL,
  birth_date date NOT NULL,
  timezone varchar,
  password_hash character varying(64) NOT NULL,
  is_verified bit
)

CREATE TABLE e-commerce.users (
  customer_id text PRIMARY KEY -- unique identifier,
  joined_at date,
  created_at timestamp,
  address character varying(64) NOT NULL,
  membership_level character varying(256),
  last_name text NOT NULL
)

[User] Get id, available, name from all products.

[Assistant] SELECT id, available, name FROM e-commerce.products;

[User] Retrieve quantity, name, payer_id, balance showing the relationship between products and shipping.

[Assistant] SELECT id, available, name, shipping.payer_id, shipping.balance FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.payment_id;

[User] Return just 15 rows.

[Assistant] SELECT id, available, name, shipping.payer_id, shipping.balance FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.payment_id LIMIT 15;


[User] Display all products.

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

[User] Show me quantity, name, payment_date, invoice_number from products and their related shipping.

[Assistant] SELECT *, shipping.payment_date, shipping.invoice_number FROM e-commerce.products JOIN e-commerce.shipping ON products.shippin_id = shipping.payment_id;

[User] Group products by name and show the min of quantity.

[Assistant] SELECT name, MIN(quantity) AS min_quantity FROM e-commerce.products GROUP BY name;


[User] Show me all products.

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

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

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

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

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


[User] Show me expires_at, quantity, name for all products.

[Assistant] SELECT expires_at, quantity, name FROM e-commerce.products;

[User] Find products where shippin_id > 80.

[Assistant] SELECT expires_at, quantity, name FROM e-commerce.products WHERE shippin_id > 80;

[User] Return just 5 rows.

[Assistant] SELECT expires_at, quantity, name FROM e-commerce.products WHERE shippin_id > 80 LIMIT 5;


[User] Display all products.

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

[User] Get all products from 2023.

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

[User] Order the output by available descending.

[Assistant] SELECT * FROM e-commerce.products WHERE expires_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY available DESC;


[User] Retrieve quantity, available, media_url for every product.

[Assistant] SELECT quantity, available, media_url FROM e-commerce.products;

[User] Get all products created yesterday.

[Assistant] SELECT quantity, available, media_url FROM e-commerce.products WHERE expires_at = CURRENT_DATE - INTERVAL '1 day';

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

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


[User] List name, id, shippin_id from products.

[Assistant] SELECT name, id, shippin_id FROM e-commerce.products;

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

[Assistant] SELECT name, id, shippin_id FROM e-commerce.products WHERE expires_at > '2023-01-01';

[User] Show only 15 records.

[Assistant] SELECT name, id, shippin_id FROM e-commerce.products WHERE expires_at > '2023-01-01' LIMIT 15;


[User] Display all products.

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

[User] Show me products with shippin_id > 20.

[Assistant] SELECT * FROM e-commerce.products WHERE shippin_id > 20;

[User] Sort the results by id ascending.

[Assistant] SELECT * FROM e-commerce.products WHERE shippin_id > 20 ORDER BY id ASC;


[User] Get all products.

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

[User] Order the output by quantity ascending.

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

[User] Show me the count of products grouped by media_url.

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


[User] What are the available, id, expires_at of each product?

[Assistant] SELECT available, id, expires_at FROM e-commerce.products;

[User] Show the results sorted by name ascending.

[Assistant] SELECT available, id, expires_at FROM e-commerce.products ORDER BY name ASC;

[User] Calculate sum of name for each shippin_id in products.

[Assistant] SELECT shippin_id, SUM(name) AS sum_name FROM e-commerce.products GROUP BY shippin_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.transactions (
  invoice_id integer PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  created_at timestamp without time zone,
  card_type character varying(256) NOT NULL,
  customer_id varchar -- identifier for customer,
  exchange_rate character varying(256) NOT NULL,
  payment_status character varying(256) NOT NULL,
  loan_id text -- reference to loans.location_id,
  FOREIGN KEY (loan_id) REFERENCES loans(location_id)
)

CREATE TABLE finance.payments (
  payment_id integer PRIMARY KEY -- unique identifier,
  traded_at date,
  created_at date,
  user_id character varying(128) NOT NULL -- identifier for user,
  card_type character varying(128),
  exchange_rate character varying(256),
  buyer_id text -- identifier for buyer,
  tax numeric NOT NULL,
  customer_id text -- reference to customers.person_id,
  FOREIGN KEY (customer_id) REFERENCES customers(person_id)
)

CREATE TABLE finance.customers (
  person_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  last_active timestamp,
  is_verified bit,
  api_key varchar NOT NULL,
  nationality text NOT NULL,
  last_login timestamp,
  transaction_id integer NOT NULL -- reference to transactions.invoice_id,
  loan_id text NOT NULL -- reference to loans.location_id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(invoice_id),
  FOREIGN KEY (loan_id) REFERENCES loans(location_id)
)

CREATE TABLE finance.loans (
  location_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  parking_available text,
  type character varying(256)
)

[User] Retrieve all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Order the output by traded_at ascending.

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

[User] Sort the results by exchange_rate ascending.

[Assistant] SELECT * FROM finance.payments ORDER BY exchange_rate 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 government.reviews (
  message_id text PRIMARY KEY -- unique identifier,
  created_at date,
  title character varying(256),
  body varchar NOT NULL,
  author_id text,
  content char,
  media_url char NOT NULL,
  reply_to_id char -- identifier for reply_to,
  likes character varying(256) NOT NULL,
  patient_id integer NOT NULL -- reference to patients.person_id,
  FOREIGN KEY (patient_id) REFERENCES patients(person_id)
)

CREATE TABLE government.patients (
  person_id integer PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  first_name character varying(256) NOT NULL,
  birth_date timestamp without time zone NOT NULL,
  profile_picture_url character varying(64),
  account_id integer NOT NULL -- reference to accounts.transaction_id,
  review_id text NOT NULL -- reference to reviews.message_id,
  FOREIGN KEY (account_id) REFERENCES accounts(transaction_id),
  FOREIGN KEY (review_id) REFERENCES reviews(message_id)
)

CREATE TABLE government.accounts (
  transaction_id integer PRIMARY KEY -- unique identifier,
  due_date date,
  category text,
  credit text,
  approval_status varchar NOT NULL,
  customer_id text,
  debit character varying(128),
  reconciliation_status char NOT NULL,
  notes text,
  review_id text -- reference to reviews.message_id,
  FOREIGN KEY (review_id) REFERENCES reviews(message_id)
)

[User] Get reply_to_id, created_at, body from all reviews.

[Assistant] SELECT reply_to_id, created_at, body FROM government.reviews;

[User] Get reviews that match title LIKE 'A%'.

[Assistant] SELECT reply_to_id, created_at, body FROM government.reviews WHERE title LIKE 'A%';

[User] Restrict the output to 10 items.

[Assistant] SELECT reply_to_id, created_at, body FROM government.reviews WHERE title LIKE 'A%' LIMIT 10;


[User] What are the debit, customer_id, due_date of each account?

[Assistant] SELECT debit, customer_id, due_date FROM government.accounts;

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

[Assistant] SELECT debit, customer_id, due_date FROM government.accounts WHERE due_date > '2023-12-01';

[User] Show only 100 records.

[Assistant] SELECT debit, customer_id, due_date FROM government.accounts WHERE due_date > '2023-12-01' LIMIT 100;


[User] List title, patient_id, likes from reviews.

[Assistant] SELECT title, patient_id, likes FROM government.reviews;

[User] List reviews with dates created yesterday.

[Assistant] SELECT title, patient_id, likes FROM government.reviews WHERE created_at = CURRENT_DATE - INTERVAL '1 day';

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

[Assistant] SELECT title, patient_id, likes FROM government.reviews WHERE created_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY title DESC;


[User] Get patient_id, likes, title from all reviews.

[Assistant] SELECT patient_id, likes, title FROM government.reviews;

[User] Order the output by title ascending.

[Assistant] SELECT patient_id, likes, title FROM government.reviews ORDER BY title ASC;

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

[Assistant] SELECT patient_id, likes, title FROM government.reviews ORDER BY patient_id ASC;


[User] Display all reviews.

[Assistant] SELECT * FROM government.reviews;

[User] Order the output by content descending.

[Assistant] SELECT * FROM government.reviews ORDER BY content DESC;

[User] Only show the top 25 results.

[Assistant] SELECT * FROM government.reviews ORDER BY content DESC LIMIT 25;


[User] List all reviews.

[Assistant] SELECT * FROM government.reviews;

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

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

[User] Return just 5 rows.

[Assistant] SELECT * FROM government.reviews WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 5;


[User] Get joined_at, review_id, first_name from all patients.

[Assistant] SELECT joined_at, review_id, first_name FROM government.patients;

[User] Show the results sorted by first_name ascending.

[Assistant] SELECT joined_at, review_id, first_name FROM government.patients ORDER BY first_name ASC;

[User] Show me average of birth_date grouped by review_id for patients.

[Assistant] SELECT review_id, AVERAGE(birth_date) AS average_birth_date FROM government.patients GROUP BY review_id;


[User] Display all patients.

[Assistant] SELECT * FROM government.patients;

[User] Find patients where first_name LIKE 'A%'.

[Assistant] SELECT * FROM government.patients WHERE first_name LIKE 'A%';

[User] Restrict the output to 50 items.

[Assistant] SELECT * FROM government.patients WHERE first_name LIKE 'A%' LIMIT 50;


[User] Show me all accounts.

[Assistant] SELECT * FROM government.accounts;

[User] Find accounts modified within the last hour.

[Assistant] SELECT * FROM government.accounts WHERE due_date >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Return just 20 rows.

[Assistant] SELECT * FROM government.accounts WHERE due_date >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 20;


[User] List all reviews.

[Assistant] SELECT * FROM government.reviews;

[User] Show me reviews with author_id LIKE 'A%'.

[Assistant] SELECT * FROM government.reviews WHERE author_id LIKE 'A%';

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE travel.orders (
  order_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at timestamp,
  status character varying(64),
  card_type character varying(64),
  payment_status character varying(64),
  currency varchar,
  account_id char -- identifier for account,
  delivery_status character varying(256),
  user_id varchar NOT NULL -- identifier for user,
  student_id text NOT NULL -- reference to students.user_id,
  FOREIGN KEY (student_id) REFERENCES students(user_id)
)

CREATE TABLE travel.addresses (
  id text PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at date,
  coordinates character varying(256),
  operating_hours text NOT NULL,
  state character varying(64) NOT NULL,
  latitude character varying(64) NOT NULL
)

CREATE TABLE travel.students (
  user_id text PRIMARY KEY -- unique identifier,
  created_at date,
  status varchar,
  salt character varying(64) NOT NULL,
  age character varying(128) NOT NULL
)

[User] Show me updated_at, card_type, payment_status for all orders.

[Assistant] SELECT updated_at, card_type, payment_status FROM travel.orders;

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

[Assistant] SELECT updated_at, card_type, payment_status FROM travel.orders WHERE currency LIKE 'A%';

[User] Get average of status by status from orders.

[Assistant] SELECT status, AVERAGE(status) AS average_status FROM travel.orders GROUP BY status;


[User] List all orders.

[Assistant] SELECT * FROM travel.orders;

[User] Get orders that match payment_status LIKE 'A%'.

[Assistant] SELECT * FROM travel.orders WHERE payment_status LIKE 'A%';

[User] Show me average of student_id grouped by card_type for orders.

[Assistant] SELECT card_type, AVERAGE(student_id) AS average_student_id FROM travel.orders GROUP BY card_type;


[User] Retrieve all orders.

[Assistant] SELECT * FROM travel.orders;

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

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

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

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


[User] Show me all orders.

[Assistant] SELECT * FROM travel.orders;

[User] Retrieve orders where currency LIKE 'A%'.

[Assistant] SELECT * FROM travel.orders WHERE currency LIKE 'A%';

[User] Sort the results by created_at ascending.

[Assistant] SELECT * FROM travel.orders WHERE currency LIKE 'A%' ORDER BY created_at ASC;


[User] Display all orders.

[Assistant] SELECT * FROM travel.orders;

[User] Get orders that match status LIKE 'A%'.

[Assistant] SELECT * FROM travel.orders WHERE status LIKE 'A%';

[User] Show me average of delivery_status grouped by updated_at for orders.

[Assistant] SELECT updated_at, AVERAGE(delivery_status) AS average_delivery_status FROM travel.orders GROUP BY updated_at;


[User] What are the currency, updated_at, delivery_status of each order?

[Assistant] SELECT currency, updated_at, delivery_status FROM travel.orders;

[User] Show me updated_at, currency, created_at, age from orders and their related students.

[Assistant] SELECT currency, updated_at, delivery_status, students.created_at, students.age FROM travel.orders JOIN travel.students ON orders.student_id = students.user_id;

[User] Order the output by status descending.

[Assistant] SELECT currency, updated_at, delivery_status, students.created_at, students.age FROM travel.orders JOIN travel.students ON orders.student_id = students.user_id ORDER BY status DESC;


[User] Display all orders.

[Assistant] SELECT * FROM travel.orders;

[User] Order the output by account_id descending.

[Assistant] SELECT * FROM travel.orders ORDER BY account_id DESC;

[User] Group orders by card_type and show the count of status.

[Assistant] SELECT card_type, COUNT(status) AS count_status FROM travel.orders GROUP BY card_type;


[User] What are the card_type, created_at, status of each order?

[Assistant] SELECT card_type, created_at, status FROM travel.orders;

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

[Assistant] SELECT card_type, created_at, status FROM travel.orders WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Show only 100 records.

[Assistant] SELECT card_type, created_at, status FROM travel.orders WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 100;


[User] Retrieve all orders.

[Assistant] SELECT * FROM travel.orders;

[User] Get orders that match status LIKE 'A%'.

[Assistant] SELECT * FROM travel.orders WHERE status LIKE 'A%';

[User] What is the sum delivery_status for each currency in orders?

[Assistant] SELECT currency, SUM(delivery_status) AS sum_delivery_status FROM travel.orders GROUP BY currency;


[User] Retrieve all orders.

[Assistant] SELECT * FROM travel.orders;

[User] What created_at, payment_status, created_at, age do we have for orders and their associated students?

[Assistant] SELECT *, students.created_at, students.age FROM travel.orders JOIN travel.students ON orders.student_id = students.user_id;

[User] Show the results sorted by payment_status ascending.

[Assistant] SELECT *, students.created_at, students.age FROM travel.orders JOIN travel.students ON orders.student_id = students.user_id ORDER BY payment_status 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 humanresources.members (
  employee_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  username text NOT NULL,
  zip_code character varying(128),
  birth_date date,
  email char NOT NULL,
  first_name character varying(64),
  message_id text NOT NULL -- reference to messages.post_id,
  FOREIGN KEY (message_id) REFERENCES messages(post_id)
)

CREATE TABLE humanresources.messages (
  post_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at date,
  score character varying(128),
  attachment_url varchar,
  thumbnail text NOT NULL,
  member_id integer NOT NULL -- reference to members.employee_id,
  FOREIGN KEY (member_id) REFERENCES members(employee_id)
)

[User] Retrieve email, zip_code, first_name for every member.

[Assistant] SELECT email, zip_code, first_name FROM humanresources.members;

[User] Get members that match birth_date > '2023-01-01'.

[Assistant] SELECT email, zip_code, first_name FROM humanresources.members WHERE birth_date > '2023-01-01';

[User] Can you order these by message_id ascending?

[Assistant] SELECT email, zip_code, first_name FROM humanresources.members WHERE birth_date > '2023-01-01' ORDER BY message_id ASC;


[User] Retrieve all members.

[Assistant] SELECT * FROM humanresources.members;

[User] Show me email, username, thumbnail, member_id from members and their related messages.

[Assistant] SELECT *, messages.thumbnail, messages.member_id FROM humanresources.members JOIN humanresources.messages ON members.message_id = messages.post_id;

[User] Show the results sorted by email descending.

[Assistant] SELECT *, messages.thumbnail, messages.member_id FROM humanresources.members JOIN humanresources.messages ON members.message_id = messages.post_id ORDER BY email DESC;


[User] List all messages.

[Assistant] SELECT * FROM humanresources.messages;

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

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

[User] Order the output by member_id ascending.

[Assistant] SELECT * FROM humanresources.messages WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY member_id ASC;


[User] Retrieve all messages.

[Assistant] SELECT * FROM humanresources.messages;

[User] List thumbnail, updated_at, updated_at, email for each message along with their member information.

[Assistant] SELECT *, members.updated_at, members.email FROM humanresources.messages JOIN humanresources.members ON messages.member_id = members.employee_id;

[User] Get average of member_id by created_at from messages.

[Assistant] SELECT created_at, AVERAGE(member_id) AS average_member_id FROM humanresources.messages GROUP BY created_at;


[User] Show me thumbnail, attachment_url, score for all messages.

[Assistant] SELECT thumbnail, attachment_url, score FROM humanresources.messages;

[User] Can you order these by member_id ascending?

[Assistant] SELECT thumbnail, attachment_url, score FROM humanresources.messages ORDER BY member_id ASC;

[User] Show the results sorted by member_id ascending.

[Assistant] SELECT thumbnail, attachment_url, score FROM humanresources.messages ORDER BY member_id ASC;


[User] List score, attachment_url, thumbnail from messages.

[Assistant] SELECT score, attachment_url, thumbnail FROM humanresources.messages;

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

[Assistant] SELECT score, attachment_url, thumbnail FROM humanresources.messages WHERE updated_at > '2023-01-01';

[User] Return just 25 rows.

[Assistant] SELECT score, attachment_url, thumbnail FROM humanresources.messages WHERE updated_at > '2023-01-01' LIMIT 25;


[User] Retrieve all members.

[Assistant] SELECT * FROM humanresources.members;

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

[Assistant] SELECT * FROM humanresources.members WHERE email LIKE 'A%';

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

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


[User] Retrieve all messages.

[Assistant] SELECT * FROM humanresources.messages;

[User] Sort the results by updated_at ascending.

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

[User] Group messages by attachment_url and show the max of score.

[Assistant] SELECT attachment_url, MAX(score) AS max_score FROM humanresources.messages GROUP BY attachment_url;


[User] Show me all messages.

[Assistant] SELECT * FROM humanresources.messages;

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

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

[User] Order the output by created_at ascending.

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


[User] List all members.

[Assistant] SELECT * FROM humanresources.members;

[User] What email, updated_at, attachment_url, member_id do we have for members and their associated messages?

[Assistant] SELECT *, messages.attachment_url, messages.member_id FROM humanresources.members JOIN humanresources.messages ON members.message_id = messages.post_id;

[User] Show only 100 records.

[Assistant] SELECT *, messages.attachment_url, messages.member_id FROM humanresources.members JOIN humanresources.messages ON members.message_id = messages.post_id LIMIT 100;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.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] List created_at, street, order_id from logs.

[Assistant] SELECT created_at, street, order_id FROM tradingplatform.logs;

[User] List street, store_id, traded_at, seller_id for each log along with their order information.

[Assistant] SELECT created_at, street, order_id, orders.traded_at, orders.seller_id FROM tradingplatform.logs JOIN tradingplatform.orders ON logs.order_id = orders.invoice_id;

[User] Tally up logs by street.

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


[User] Show me all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Find logs created yesterday.

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

[User] Show only 10 records.

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


[User] Retrieve all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Find logs between January and March.

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

[User] Calculate count of created_at for each updated_at in logs.

[Assistant] SELECT updated_at, COUNT(created_at) AS count_created_at FROM tradingplatform.logs GROUP BY updated_at;


[User] Display all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] List users with dates from last week.

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

[User] Show only 5 records.

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


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

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

[User] Order the output by last_active ascending.

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

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

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


[User] Retrieve location_lat, street, created_at for every log.

[Assistant] SELECT location_lat, street, created_at FROM tradingplatform.logs;

[User] Order the output by created_at descending.

[Assistant] SELECT location_lat, street, created_at FROM tradingplatform.logs ORDER BY created_at DESC;

[User] Limit the results to 50 rows.

[Assistant] SELECT location_lat, street, created_at FROM tradingplatform.logs ORDER BY created_at DESC LIMIT 50;


[User] Retrieve street, latitude, order_id for every log.

[Assistant] SELECT street, latitude, order_id FROM tradingplatform.logs;

[User] Retrieve street, store_id, seller_id, account_id showing the relationship between logs and orders.

[Assistant] SELECT street, latitude, order_id, orders.seller_id, orders.account_id FROM tradingplatform.logs JOIN tradingplatform.orders ON logs.order_id = orders.invoice_id;

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

[Assistant] SELECT street, latitude, order_id, orders.seller_id, orders.account_id FROM tradingplatform.logs JOIN tradingplatform.orders ON logs.order_id = orders.invoice_id ORDER BY created_at ASC;


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

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

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

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

[User] Return just 20 rows.

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