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 (
  comment_id text PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  reply_to_id varchar NOT NULL,
  description character varying(128) NOT NULL,
  author_id character varying(256),
  attachment_url character varying(64),
  grade_id text -- reference to grades.account_id,
  FOREIGN KEY (grade_id) REFERENCES grades(account_id)
)

CREATE TABLE education.grades (
  account_id text PRIMARY KEY -- unique identifier,
  payment_date date,
  created_at timestamp without time zone,
  reconciliation_status character varying(128),
  category character varying(256),
  reference_number varchar,
  department_id text -- reference to departments.comment_id,
  FOREIGN KEY (department_id) REFERENCES departments(comment_id)
)

[User] List reconciliation_status, category, created_at from grades.

[Assistant] SELECT reconciliation_status, category, created_at FROM education.grades;

[User] Show me reconciliation_status, payment_date, attachment_url, published_at from grades and their related departments.

[Assistant] SELECT reconciliation_status, category, created_at, departments.attachment_url, departments.published_at FROM education.grades JOIN education.departments ON grades.department_id = departments.comment_id;

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

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


[User] Retrieve department_id, created_at, payment_date for every grade.

[Assistant] SELECT department_id, created_at, payment_date FROM education.grades;

[User] Retrieve created_at, payment_date, grade_id, attachment_url showing the relationship between grades and departments.

[Assistant] SELECT department_id, created_at, payment_date, departments.grade_id, departments.attachment_url FROM education.grades JOIN education.departments ON grades.department_id = departments.comment_id;

[User] Get min of department_id by department_id from grades.

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


[User] Show me all grades.

[Assistant] SELECT * FROM education.grades;

[User] List grades with dates created yesterday.

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

[User] Restrict the output to 50 items.

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


[User] Display all departments.

[Assistant] SELECT * FROM education.departments;

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

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

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

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


[User] What are the grade_id, published_at, attachment_url of each department?

[Assistant] SELECT grade_id, published_at, attachment_url FROM education.departments;

[User] Retrieve published_at, grade_id, reference_number, category showing the relationship between departments and grades.

[Assistant] SELECT grade_id, published_at, attachment_url, grades.reference_number, grades.category FROM education.departments JOIN education.grades ON departments.grade_id = grades.account_id;

[User] Get the distribution of departments across different grade_id values.

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


[User] Get category, payment_date, department_id from all grades.

[Assistant] SELECT category, payment_date, department_id FROM education.grades;

[User] Retrieve department_id, payment_date, description, author_id showing the relationship between grades and departments.

[Assistant] SELECT category, payment_date, department_id, departments.description, departments.author_id FROM education.grades JOIN education.departments ON grades.department_id = departments.comment_id;

[User] Tally up grades by category.

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


[User] What are the reconciliation_status, payment_date, created_at of each grade?

[Assistant] SELECT reconciliation_status, payment_date, created_at FROM education.grades;

[User] Get all grades older than 6 months.

[Assistant] SELECT reconciliation_status, payment_date, created_at FROM education.grades WHERE payment_date <= CURRENT_DATE - INTERVAL '6 months';

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

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


[User] Retrieve all grades.

[Assistant] SELECT * FROM education.grades;

[User] List grades that have reconciliation_status LIKE 'A%'.

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

[User] Limit the results to 50 rows.

[Assistant] SELECT * FROM education.grades WHERE reconciliation_status LIKE 'A%' LIMIT 50;


[User] List reply_to_id, author_id, published_at from departments.

[Assistant] SELECT reply_to_id, author_id, published_at FROM education.departments;

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

[Assistant] SELECT reply_to_id, author_id, published_at FROM education.departments WHERE attachment_url LIKE 'A%';

[User] Return just 25 rows.

[Assistant] SELECT reply_to_id, author_id, published_at FROM education.departments WHERE attachment_url LIKE 'A%' LIMIT 25;


[User] Show me description, attachment_url, grade_id for all departments.

[Assistant] SELECT description, attachment_url, grade_id FROM education.departments;

[User] Show me description, reply_to_id, reconciliation_status, category from departments and their related grades.

[Assistant] SELECT description, attachment_url, grade_id, grades.reconciliation_status, grades.category FROM education.departments JOIN education.grades ON departments.grade_id = grades.account_id;

[User] Sort the results by description ascending.

[Assistant] SELECT description, attachment_url, grade_id, grades.reconciliation_status, grades.category FROM education.departments JOIN education.grades ON departments.grade_id = grades.account_id ORDER BY description 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 e-commerce.inventory (
  product_id text PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  image_url char,
  available varchar NOT NULL,
  rating character varying(256),
  msrp char,
  subcategory character varying(64),
  order_id integer NOT NULL -- reference to orders.payment_id,
  FOREIGN KEY (order_id) REFERENCES orders(payment_id)
)

CREATE TABLE e-commerce.orders (
  payment_id integer PRIMARY KEY -- unique identifier,
  completed_at timestamp,
  exchange_rate char NOT NULL,
  price bigint NOT NULL,
  user_id character varying(64),
  status character varying(256) NOT NULL,
  inventor_id text -- reference to inventory.product_id,
  FOREIGN KEY (inventor_id) REFERENCES inventory(product_id)
)

[User] List all inventory.

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

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

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

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

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


[User] Retrieve subcategory, rating, available for every inventory.

[Assistant] SELECT subcategory, rating, available FROM e-commerce.inventory;

[User] Show the results sorted by msrp descending.

[Assistant] SELECT subcategory, rating, available FROM e-commerce.inventory ORDER BY msrp DESC;

[User] Show me min of subcategory grouped by image_url for inventory.

[Assistant] SELECT image_url, MIN(subcategory) AS min_subcategory FROM e-commerce.inventory GROUP BY image_url;


[User] Get all orders.

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

[User] List orders that have price > 18.

[Assistant] SELECT * FROM e-commerce.orders WHERE price > 18;

[User] Calculate average of completed_at for each completed_at in orders.

[Assistant] SELECT completed_at, AVERAGE(completed_at) AS average_completed_at FROM e-commerce.orders GROUP BY completed_at;


[User] Get all inventory.

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

[User] List order_id, published_at, price, exchange_rate for each inventory along with their order information.

[Assistant] SELECT *, orders.price, orders.exchange_rate FROM e-commerce.inventory JOIN e-commerce.orders ON inventory.order_id = orders.payment_id;

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

[Assistant] SELECT *, orders.price, orders.exchange_rate FROM e-commerce.inventory JOIN e-commerce.orders ON inventory.order_id = orders.payment_id ORDER BY available ASC;


[User] List all inventory.

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

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

[Assistant] SELECT * FROM e-commerce.inventory WHERE published_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Get sum of msrp by available from inventory.

[Assistant] SELECT available, SUM(msrp) AS sum_msrp FROM e-commerce.inventory GROUP BY available;


[User] Get subcategory, available, published_at from all inventory.

[Assistant] SELECT subcategory, available, published_at FROM e-commerce.inventory;

[User] Retrieve image_url, available, price, status showing the relationship between inventory and orders.

[Assistant] SELECT subcategory, available, published_at, orders.price, orders.status FROM e-commerce.inventory JOIN e-commerce.orders ON inventory.order_id = orders.payment_id;

[User] Can you order these by order_id descending?

[Assistant] SELECT subcategory, available, published_at, orders.price, orders.status FROM e-commerce.inventory JOIN e-commerce.orders ON inventory.order_id = orders.payment_id ORDER BY order_id DESC;


[User] Get all orders.

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

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

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

[User] Limit the results to 25 rows.

[Assistant] SELECT * FROM e-commerce.orders WHERE status LIKE 'A%' LIMIT 25;


[User] List user_id, completed_at, price from orders.

[Assistant] SELECT user_id, completed_at, price FROM e-commerce.orders;

[User] Show me user_id, status, rating, published_at from orders and their related inventory.

[Assistant] SELECT user_id, completed_at, price, inventory.rating, inventory.published_at FROM e-commerce.orders JOIN e-commerce.inventory ON orders.inventor_id = inventory.product_id;

[User] Count the number of orders in each completed_at category.

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


[User] Show me available, image_url, msrp for all inventory.

[Assistant] SELECT available, image_url, msrp FROM e-commerce.inventory;

[User] Retrieve order_id, published_at, completed_at, price showing the relationship between inventory and orders.

[Assistant] SELECT available, image_url, msrp, orders.completed_at, orders.price FROM e-commerce.inventory JOIN e-commerce.orders ON inventory.order_id = orders.payment_id;

[User] Group inventory by order_id and show the count of subcategory.

[Assistant] SELECT order_id, COUNT(subcategory) AS count_subcategory FROM e-commerce.inventory GROUP BY order_id;


[User] Show me all orders.

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

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

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

[User] Only show the top 100 results.

[Assistant] SELECT * FROM e-commerce.orders WHERE user_id LIKE 'A%' 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.doctors (
  employee_id character varying(64) NOT NULL -- unique identifier,
  joined_at date,
  last_active date,
  full_name char,
  password_hash character varying(128) NOT NULL,
  city character varying(256),
  status char,
  gender text,
  department_id text NOT NULL -- reference to departments.message_id,
  FOREIGN KEY (department_id) REFERENCES departments(message_id)
)

CREATE TABLE healthcare.medical_records (
  id integer PRIMARY KEY -- unique identifier,
  published_at date,
  expires_at timestamp,
  views char,
  discount bigint,
  image_url varchar NOT NULL,
  brand char
)

CREATE TABLE healthcare.departments (
  message_id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  user_id char NOT NULL,
  format character varying(64) NOT NULL
)

[User] Show me all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] List status, gender, user_id, format for each doctor along with their department information.

[Assistant] SELECT *, departments.user_id, departments.format FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.message_id;

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

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


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

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

[User] Can you order these by gender descending?

[Assistant] SELECT * FROM healthcare.doctors WHERE gender LIKE 'A%' ORDER BY gender DESC;


[User] List all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

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

[User] Show me the count of doctors grouped by joined_at.

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


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Show me joined_at, full_name, format, published_at from doctors and their related departments.

[Assistant] SELECT *, departments.format, departments.published_at FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.message_id;

[User] Get the distribution of doctors across different password_hash values.

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


[User] What are the password_hash, gender, full_name of each doctor?

[Assistant] SELECT password_hash, gender, full_name FROM healthcare.doctors;

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

[Assistant] SELECT password_hash, gender, full_name FROM healthcare.doctors WHERE joined_at >= CURRENT_DATE - INTERVAL '7 days';

[User] What is the average gender for each password_hash in doctors?

[Assistant] SELECT password_hash, AVERAGE(gender) AS average_gender FROM healthcare.doctors GROUP BY password_hash;


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Find doctors where joined_at > '2023-01-01'.

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

[User] What is the max city for each department_id in doctors?

[Assistant] SELECT department_id, MAX(city) AS max_city FROM healthcare.doctors GROUP BY department_id;


[User] Retrieve joined_at, last_active, city for every doctor.

[Assistant] SELECT joined_at, last_active, city FROM healthcare.doctors;

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

[Assistant] SELECT joined_at, last_active, city FROM healthcare.doctors WHERE last_active >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Return just 50 rows.

[Assistant] SELECT joined_at, last_active, city FROM healthcare.doctors WHERE last_active >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 50;


[User] Get all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] What password_hash, employee_id, published_at, format do we have for doctors and their associated departments?

[Assistant] SELECT *, departments.published_at, departments.format FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.message_id;

[User] Only show the top 25 results.

[Assistant] SELECT *, departments.published_at, departments.format FROM healthcare.doctors JOIN healthcare.departments ON doctors.department_id = departments.message_id LIMIT 25;


[User] List all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

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

[User] Tally up doctors by full_name.

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


[User] Retrieve all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Order the output by employee_id ascending.

[Assistant] SELECT * FROM healthcare.doctors ORDER BY employee_id ASC;

[User] Show only 5 records.

[Assistant] SELECT * FROM healthcare.doctors ORDER BY employee_id ASC LIMIT 5;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.posts (
  content_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  published_at timestamp,
  tags text,
  visibility char,
  views character varying(64),
  shares char,
  follower_id text -- reference to followers.user_id,
  FOREIGN KEY (follower_id) REFERENCES followers(user_id)
)

CREATE TABLE socialmedia.followers (
  user_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  birth_date timestamp NOT NULL,
  last_login timestamp NOT NULL,
  status text NOT NULL,
  first_name character varying(128),
  nationality character varying(128),
  is_active boolean -- indicates if active is true
)

CREATE TABLE socialmedia.events (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  completed_at date,
  traded_at date,
  seller_id character varying(64),
  subtotal integer NOT NULL,
  discount decimal NOT NULL,
  payment_method character varying(64),
  post_id integer -- reference to posts.content_id,
  FOREIGN KEY (post_id) REFERENCES posts(content_id)
)

[User] Show me tags, published_at, follower_id for all posts.

[Assistant] SELECT tags, published_at, follower_id FROM socialmedia.posts;

[User] Sort the results by shares ascending.

[Assistant] SELECT tags, published_at, follower_id FROM socialmedia.posts ORDER BY shares ASC;

[User] Group posts by published_at and show the count of tags.

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


[User] Retrieve follower_id, views, tags for every post.

[Assistant] SELECT follower_id, views, tags FROM socialmedia.posts;

[User] Get posts that match tags LIKE 'A%'.

[Assistant] SELECT follower_id, views, tags FROM socialmedia.posts WHERE tags LIKE 'A%';

[User] Show the results sorted by published_at descending.

[Assistant] SELECT follower_id, views, tags FROM socialmedia.posts WHERE tags LIKE 'A%' ORDER BY published_at DESC;


[User] Display all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] Retrieve published_at, views, last_login, is_active showing the relationship between posts and followers.

[Assistant] SELECT *, followers.last_login, followers.is_active FROM socialmedia.posts JOIN socialmedia.followers ON posts.follower_id = followers.user_id;

[User] How many posts are there per updated_at?

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


[User] List post_id, seller_id, discount from events.

[Assistant] SELECT post_id, seller_id, discount FROM socialmedia.events;

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

[Assistant] SELECT post_id, seller_id, discount FROM socialmedia.events WHERE traded_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Tally up events by payment_method.

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


[User] Display all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] Sort the results by follower_id descending.

[Assistant] SELECT * FROM socialmedia.posts ORDER BY follower_id DESC;

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

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


[User] Retrieve discount, seller_id, invoice_id for every event.

[Assistant] SELECT discount, seller_id, invoice_id FROM socialmedia.events;

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

[Assistant] SELECT discount, seller_id, invoice_id FROM socialmedia.events WHERE completed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Order the output by subtotal descending.

[Assistant] SELECT discount, seller_id, invoice_id FROM socialmedia.events WHERE completed_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY subtotal DESC;


[User] Get all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] List events with dates from 2023.

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

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

[Assistant] SELECT discount, MIN(completed_at) AS min_completed_at FROM socialmedia.events GROUP BY discount;


[User] Display all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] List posts with dates from 2023.

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

[User] Get the distribution of posts across different tags values.

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


[User] Retrieve invoice_id, payment_method, traded_at for every event.

[Assistant] SELECT invoice_id, payment_method, traded_at FROM socialmedia.events;

[User] Order the output by post_id ascending.

[Assistant] SELECT invoice_id, payment_method, traded_at FROM socialmedia.events ORDER BY post_id ASC;

[User] Get min of seller_id by post_id from events.

[Assistant] SELECT post_id, MIN(seller_id) AS min_seller_id FROM socialmedia.events GROUP BY post_id;


[User] List views, updated_at, published_at from posts.

[Assistant] SELECT views, updated_at, published_at FROM socialmedia.posts;

[User] Sort the results by updated_at ascending.

[Assistant] SELECT views, updated_at, published_at FROM socialmedia.posts ORDER BY updated_at ASC;

[User] Limit the results to 5 rows.

[Assistant] SELECT views, updated_at, published_at FROM socialmedia.posts ORDER BY updated_at ASC 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 tradingplatform.metadata (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  payment_date timestamp without time zone,
  updated_at date,
  category character varying(64) NOT NULL,
  exchange_rate character varying(128),
  customer_id character varying(128) NOT NULL,
  trade_id integer NOT NULL -- reference to trades.order_id,
  FOREIGN KEY (trade_id) REFERENCES trades(order_id)
)

CREATE TABLE tradingplatform.trades (
  order_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  cancelled_at timestamp,
  buyer_id char -- identifier for buyer,
  amount decimal,
  currency char,
  user_id character varying(64) -- identifier for user,
  total smallint NOT NULL
)

[User] List trade_id, customer_id, category from metadata.

[Assistant] SELECT trade_id, customer_id, category FROM tradingplatform.metadata;

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

[Assistant] SELECT trade_id, customer_id, category FROM tradingplatform.metadata WHERE payment_date >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Tally up metadata by category.

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


[User] List all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

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

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

[User] Count the number of metadata in each trade_id category.

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


[User] Show me payment_date, category, updated_at for all metadata.

[Assistant] SELECT payment_date, category, updated_at FROM tradingplatform.metadata;

[User] List metadata that have trade_id > 64.

[Assistant] SELECT payment_date, category, updated_at FROM tradingplatform.metadata WHERE trade_id > 64;

[User] Get min of exchange_rate by payment_date from metadata.

[Assistant] SELECT payment_date, MIN(exchange_rate) AS min_exchange_rate FROM tradingplatform.metadata GROUP BY payment_date;


[User] What are the invoice_id, payment_date, updated_at of each metadata?

[Assistant] SELECT invoice_id, payment_date, updated_at FROM tradingplatform.metadata;

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

[Assistant] SELECT invoice_id, payment_date, updated_at FROM tradingplatform.metadata WHERE updated_at > '2023-01-01';

[User] Sort the results by payment_date descending.

[Assistant] SELECT invoice_id, payment_date, updated_at FROM tradingplatform.metadata WHERE updated_at > '2023-01-01' ORDER BY payment_date DESC;


[User] Get all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Get all metadata from last week.

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

[User] Get the distribution of metadata across different trade_id values.

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


[User] Get all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] List updated_at, trade_id, cancelled_at, total for each metadata along with their trade information.

[Assistant] SELECT *, trades.cancelled_at, trades.total FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.order_id;

[User] Order the output by trade_id descending.

[Assistant] SELECT *, trades.cancelled_at, trades.total FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.order_id ORDER BY trade_id DESC;


[User] Show me all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Get payment_date, updated_at, amount, total by joining metadata with trades.

[Assistant] SELECT *, trades.amount, trades.total FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.order_id;

[User] Get min of category by updated_at from metadata.

[Assistant] SELECT updated_at, MIN(category) AS min_category FROM tradingplatform.metadata GROUP BY updated_at;


[User] What are the updated_at, invoice_id, payment_date of each metadata?

[Assistant] SELECT updated_at, invoice_id, payment_date FROM tradingplatform.metadata;

[User] Show me trade_id, updated_at, updated_at, total from metadata and their related trades.

[Assistant] SELECT updated_at, invoice_id, payment_date, trades.updated_at, trades.total FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.order_id;

[User] Return just 15 rows.

[Assistant] SELECT updated_at, invoice_id, payment_date, trades.updated_at, trades.total FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.order_id LIMIT 15;


[User] List all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] List trade_id, payment_date, updated_at, currency for each metadata along with their trade information.

[Assistant] SELECT *, trades.updated_at, trades.currency FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.order_id;

[User] Return just 15 rows.

[Assistant] SELECT *, trades.updated_at, trades.currency FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.order_id LIMIT 15;


[User] List all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Get exchange_rate, updated_at, buyer_id, total by joining metadata with trades.

[Assistant] SELECT *, trades.buyer_id, trades.total FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.order_id;

[User] Only show the top 25 results.

[Assistant] SELECT *, trades.buyer_id, trades.total FROM tradingplatform.metadata JOIN tradingplatform.trades ON metadata.trade_id = trades.order_id 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.reviews (
  post_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  user_id character varying(256) NOT NULL -- identifier for user,
  description char,
  format character varying(128),
  shippin_id text NOT NULL -- reference to shipping.payment_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(payment_id)
)

CREATE TABLE e-commerce.order_items (
  item_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  thumbnail_url character varying(256),
  manufacturer character varying(256),
  rating text,
  discount numeric NOT NULL,
  image_url varchar,
  shippin_id text NOT NULL -- reference to shipping.payment_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(payment_id)
)

CREATE TABLE e-commerce.shipping (
  payment_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at timestamp without time zone,
  debit character varying(128),
  balance numeric NOT NULL,
  payee_id character varying(128) -- identifier for payee,
  category text
)

CREATE TABLE e-commerce.categories (
  product_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  expires_at timestamp,
  video_url text NOT NULL -- identifier for video_url,
  subcategory text NOT NULL,
  discount numeric,
  description text,
  cost decimal NOT NULL
)

[User] Get all order_items.

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

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

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

[User] Sort the results by shippin_id ascending.

[Assistant] SELECT * FROM e-commerce.order_items WHERE updated_at > '2023-12-01' ORDER BY shippin_id ASC;


[User] Get all reviews.

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

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

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

[User] Can you order these by shippin_id ascending?

[Assistant] SELECT * FROM e-commerce.reviews WHERE shippin_id LIKE 'A%' ORDER BY shippin_id ASC;


[User] Show me all order_items.

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

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

[Assistant] SELECT * FROM e-commerce.order_items WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Restrict the output to 100 items.

[Assistant] SELECT * FROM e-commerce.order_items WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 100;


[User] Retrieve user_id, format, description for every review.

[Assistant] SELECT user_id, format, description FROM e-commerce.reviews;

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

[Assistant] SELECT user_id, format, description FROM e-commerce.reviews WHERE shippin_id LIKE 'A%';

[User] Show only 100 records.

[Assistant] SELECT user_id, format, description FROM e-commerce.reviews WHERE shippin_id LIKE 'A%' LIMIT 100;


[User] What are the post_id, format, shippin_id of each review?

[Assistant] SELECT post_id, format, shippin_id FROM e-commerce.reviews;

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

[Assistant] SELECT post_id, format, shippin_id FROM e-commerce.reviews ORDER BY format DESC;

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

[Assistant] SELECT post_id, format, shippin_id FROM e-commerce.reviews ORDER BY updated_at ASC;


[User] Display all reviews.

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

[User] Get shippin_id, format, debit, created_at by joining reviews with shipping.

[Assistant] SELECT *, shipping.debit, shipping.created_at FROM e-commerce.reviews JOIN e-commerce.shipping ON reviews.shippin_id = shipping.payment_id;

[User] Tally up reviews by updated_at.

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


[User] Display all reviews.

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

[User] Can you order these by post_id ascending?

[Assistant] SELECT * FROM e-commerce.reviews ORDER BY post_id ASC;

[User] Sort the results by shippin_id descending.

[Assistant] SELECT * FROM e-commerce.reviews ORDER BY shippin_id DESC;


[User] What are the thumbnail_url, updated_at, item_id of each order_item?

[Assistant] SELECT thumbnail_url, updated_at, item_id FROM e-commerce.order_items;

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

[Assistant] SELECT thumbnail_url, updated_at, item_id FROM e-commerce.order_items WHERE rating LIKE 'A%';

[User] Calculate count of shippin_id for each manufacturer in order_items.

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


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,
  due_date timestamp without time zone,
  reconciliation_status text,
  user_id character varying(128) -- identifier for user,
  vendor_id text,
  approval_status character varying(128),
  balance integer,
  category char NOT NULL,
  currency char,
  like_id integer NOT NULL -- reference to likes.barcode,
  FOREIGN KEY (like_id) REFERENCES likes(barcode)
)

CREATE TABLE socialmedia.likes (
  barcode integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  expires_at timestamp,
  tax_rate text,
  image_url character varying(64) NOT NULL,
  reserved character varying(64),
  group_id text -- reference to groups.id,
  FOREIGN KEY (group_id) REFERENCES groups(id)
)

CREATE TABLE socialmedia.comments (
  content_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  user_id text,
  format character varying(256) NOT NULL,
  author_id character varying(256),
  group_id text NOT NULL -- reference to groups.id,
  FOREIGN KEY (group_id) REFERENCES groups(id)
)

[User] Get all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Find groups from last week.

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

[User] Get the distribution of groups across different currency values.

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


[User] List all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] What reserved, image_url, category, user_id do we have for likes and their associated groups?

[Assistant] SELECT *, groups.category, groups.user_id FROM socialmedia.likes JOIN socialmedia.groups ON likes.group_id = groups.id;

[User] Show me max of created_at grouped by tax_rate for likes.

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


[User] What are the group_id, user_id, created_at of each comment?

[Assistant] SELECT group_id, user_id, created_at FROM socialmedia.comments;

[User] What author_id, user_id, approval_status, currency do we have for comments and their associated groups?

[Assistant] SELECT group_id, user_id, created_at, groups.approval_status, groups.currency FROM socialmedia.comments JOIN socialmedia.groups ON comments.group_id = groups.id;

[User] Show only 20 records.

[Assistant] SELECT group_id, user_id, created_at, groups.approval_status, groups.currency FROM socialmedia.comments JOIN socialmedia.groups ON comments.group_id = groups.id LIMIT 20;


[User] Show me due_date, currency, user_id for all groups.

[Assistant] SELECT due_date, currency, user_id FROM socialmedia.groups;

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

[Assistant] SELECT due_date, currency, user_id FROM socialmedia.groups WHERE category LIKE 'A%';

[User] Group groups by balance and show the average of approval_status.

[Assistant] SELECT balance, AVERAGE(approval_status) AS average_approval_status FROM socialmedia.groups GROUP BY balance;


[User] Show me created_at, image_url, reserved for all likes.

[Assistant] SELECT created_at, image_url, reserved FROM socialmedia.likes;

[User] Retrieve created_at, image_url, vendor_id, balance showing the relationship between likes and groups.

[Assistant] SELECT created_at, image_url, reserved, groups.vendor_id, groups.balance FROM socialmedia.likes JOIN socialmedia.groups ON likes.group_id = groups.id;

[User] Show me min of expires_at grouped by expires_at for likes.

[Assistant] SELECT expires_at, MIN(expires_at) AS min_expires_at FROM socialmedia.likes GROUP BY expires_at;


[User] Get all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Show me vendor_id, reconciliation_status, image_url, reserved from groups and their related likes.

[Assistant] SELECT *, likes.image_url, likes.reserved FROM socialmedia.groups JOIN socialmedia.likes ON groups.like_id = likes.barcode;

[User] Calculate sum of user_id for each vendor_id in groups.

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


[User] What are the like_id, user_id, balance of each group?

[Assistant] SELECT like_id, user_id, balance FROM socialmedia.groups;

[User] Order the output by due_date ascending.

[Assistant] SELECT like_id, user_id, balance FROM socialmedia.groups ORDER BY due_date ASC;

[User] What is the max balance for each category in groups?

[Assistant] SELECT category, MAX(balance) AS max_balance FROM socialmedia.groups GROUP BY category;


[User] What are the vendor_id, due_date, category of each group?

[Assistant] SELECT vendor_id, due_date, category FROM socialmedia.groups;

[User] Sort the results by due_date descending.

[Assistant] SELECT vendor_id, due_date, category FROM socialmedia.groups ORDER BY due_date DESC;

[User] Count the number of groups in each reconciliation_status category.

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


[User] What are the currency, approval_status, reconciliation_status of each group?

[Assistant] SELECT currency, approval_status, reconciliation_status FROM socialmedia.groups;

[User] Show me reconciliation_status, currency, created_at, group_id from groups and their related likes.

[Assistant] SELECT currency, approval_status, reconciliation_status, likes.created_at, likes.group_id FROM socialmedia.groups JOIN socialmedia.likes ON groups.like_id = likes.barcode;

[User] Restrict the output to 20 items.

[Assistant] SELECT currency, approval_status, reconciliation_status, likes.created_at, likes.group_id FROM socialmedia.groups JOIN socialmedia.likes ON groups.like_id = likes.barcode LIMIT 20;


[User] Get group_id, reserved, expires_at from all likes.

[Assistant] SELECT group_id, reserved, expires_at FROM socialmedia.likes;

[User] Sort the results by expires_at descending.

[Assistant] SELECT group_id, reserved, expires_at FROM socialmedia.likes ORDER BY expires_at DESC;

[User] Show only 100 records.

[Assistant] SELECT group_id, reserved, expires_at FROM socialmedia.likes ORDER BY expires_at DESC LIMIT 100;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE banking.subscriptions (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  created_at timestamp without time zone,
  reconciliation_status char,
  invoice_number varchar NOT NULL,
  credit character varying(128),
  vendor_id varchar,
  user_id text NOT NULL -- reference to users.person_id,
  FOREIGN KEY (user_id) REFERENCES users(person_id)
)

CREATE TABLE banking.users (
  person_id varchar PRIMARY KEY -- unique identifier,
  last_active date,
  state character varying(64) NOT NULL,
  password_hash text,
  phone text,
  status varchar NOT NULL,
  language varchar NOT NULL,
  bio character varying(64) NOT NULL,
  token varchar NOT NULL
)

[User] Retrieve all subscriptions.

[Assistant] SELECT * FROM banking.subscriptions;

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

[Assistant] SELECT * FROM banking.subscriptions ORDER BY vendor_id ASC;

[User] Get sum of credit by reconciliation_status from subscriptions.

[Assistant] SELECT reconciliation_status, SUM(credit) AS sum_credit FROM banking.subscriptions GROUP BY reconciliation_status;


[User] Display all subscriptions.

[Assistant] SELECT * FROM banking.subscriptions;

[User] Order the output by credit ascending.

[Assistant] SELECT * FROM banking.subscriptions ORDER BY credit ASC;

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

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


[User] Display all subscriptions.

[Assistant] SELECT * FROM banking.subscriptions;

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

[Assistant] SELECT * FROM banking.subscriptions ORDER BY vendor_id ASC;

[User] Restrict the output to 50 items.

[Assistant] SELECT * FROM banking.subscriptions ORDER BY vendor_id ASC LIMIT 50;


[User] Retrieve invoice_number, reconciliation_status, vendor_id for every subscription.

[Assistant] SELECT invoice_number, reconciliation_status, vendor_id FROM banking.subscriptions;

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

[Assistant] SELECT invoice_number, reconciliation_status, vendor_id FROM banking.subscriptions WHERE created_at > '2023-01-01';

[User] Tally up subscriptions by invoice_id.

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


[User] Display all subscriptions.

[Assistant] SELECT * FROM banking.subscriptions;

[User] Find subscriptions created yesterday.

[Assistant] SELECT * FROM banking.subscriptions WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] What is the max invoice_id for each user_id in subscriptions?

[Assistant] SELECT user_id, MAX(invoice_id) AS max_invoice_id FROM banking.subscriptions GROUP BY user_id;


[User] Get created_at, vendor_id, user_id from all subscriptions.

[Assistant] SELECT created_at, vendor_id, user_id FROM banking.subscriptions;

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

[Assistant] SELECT created_at, vendor_id, user_id FROM banking.subscriptions WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Return just 20 rows.

[Assistant] SELECT created_at, vendor_id, user_id FROM banking.subscriptions WHERE created_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 20;


[User] Retrieve updated_at, invoice_id, reconciliation_status for every subscription.

[Assistant] SELECT updated_at, invoice_id, reconciliation_status FROM banking.subscriptions;

[User] What created_at, invoice_id, status, token do we have for subscriptions and their associated users?

[Assistant] SELECT updated_at, invoice_id, reconciliation_status, users.status, users.token FROM banking.subscriptions JOIN banking.users ON subscriptions.user_id = users.person_id;

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

[Assistant] SELECT updated_at, invoice_id, reconciliation_status, users.status, users.token FROM banking.subscriptions JOIN banking.users ON subscriptions.user_id = users.person_id ORDER BY created_at DESC;


[User] Show me invoice_number, reconciliation_status, credit for all subscriptions.

[Assistant] SELECT invoice_number, reconciliation_status, credit FROM banking.subscriptions;

[User] Find subscriptions between January and March.

[Assistant] SELECT invoice_number, reconciliation_status, credit FROM banking.subscriptions WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Get sum of credit by reconciliation_status from subscriptions.

[Assistant] SELECT reconciliation_status, SUM(credit) AS sum_credit FROM banking.subscriptions GROUP BY reconciliation_status;


[User] Retrieve invoice_number, reconciliation_status, invoice_id for every subscription.

[Assistant] SELECT invoice_number, reconciliation_status, invoice_id FROM banking.subscriptions;

[User] Order the output by user_id ascending.

[Assistant] SELECT invoice_number, reconciliation_status, invoice_id FROM banking.subscriptions ORDER BY user_id ASC;

[User] Limit the results to 25 rows.

[Assistant] SELECT invoice_number, reconciliation_status, invoice_id FROM banking.subscriptions ORDER BY user_id ASC LIMIT 25;


[User] Retrieve invoice_id, created_at, user_id for every subscription.

[Assistant] SELECT invoice_id, created_at, user_id FROM banking.subscriptions;

[User] Show me subscriptions with invoice_id LIKE 'A%'.

[Assistant] SELECT invoice_id, created_at, user_id FROM banking.subscriptions WHERE invoice_id LIKE 'A%';

[User] Order the output by created_at ascending.

[Assistant] SELECT invoice_id, created_at, user_id FROM banking.subscriptions WHERE invoice_id LIKE 'A%' ORDER BY created_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 music.venues (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  last_inspected timestamp,
  state character varying(256) NOT NULL,
  postal_code varchar,
  timezone char NOT NULL,
  parking_available character varying(256) NOT NULL,
  description character varying(128),
  country character varying(128) NOT NULL,
  post_id text NOT NULL -- reference to posts.content_id,
  FOREIGN KEY (post_id) REFERENCES posts(content_id)
)

CREATE TABLE music.posts (
  content_id text PRIMARY KEY -- unique identifier,
  published_at date,
  updated_at date,
  user_id character varying(64),
  likes text,
  format varchar,
  good_id integer NOT NULL -- reference to goods.barcode,
  transaction_id text -- reference to transactions.id,
  FOREIGN KEY (good_id) REFERENCES goods(barcode),
  FOREIGN KEY (transaction_id) REFERENCES transactions(id)
)

CREATE TABLE music.transactions (
  id text PRIMARY KEY -- unique identifier,
  traded_at date,
  processed_at timestamp,
  payment_status char,
  fee character varying(256),
  delivery_status char NOT NULL,
  exchange_rate text
)

CREATE TABLE music.goods (
  barcode integer PRIMARY KEY -- unique identifier,
  published_at timestamp,
  expires_at date,
  video_url text NOT NULL,
  image_url character varying(256) NOT NULL,
  popularity_score char NOT NULL,
  media_url char,
  featured_rank character varying(128),
  venue_id text -- reference to venues.id,
  FOREIGN KEY (venue_id) REFERENCES venues(id)
)

[User] Display all goods.

[Assistant] SELECT * FROM music.goods;

[User] Can you order these by venue_id ascending?

[Assistant] SELECT * FROM music.goods ORDER BY venue_id ASC;

[User] Order the output by expires_at ascending.

[Assistant] SELECT * FROM music.goods ORDER BY expires_at ASC;


[User] Retrieve all goods.

[Assistant] SELECT * FROM music.goods;

[User] Retrieve goods where venue_id LIKE 'A%'.

[Assistant] SELECT * FROM music.goods WHERE venue_id LIKE 'A%';

[User] Group goods by venue_id and show the min of published_at.

[Assistant] SELECT venue_id, MIN(published_at) AS min_published_at FROM music.goods GROUP BY venue_id;


[User] Get all posts.

[Assistant] SELECT * FROM music.posts;

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

[Assistant] SELECT * FROM music.posts WHERE published_at > '2023-12-01';

[User] Show only 100 records.

[Assistant] SELECT * FROM music.posts WHERE published_at > '2023-12-01' LIMIT 100;


[User] Get all posts.

[Assistant] SELECT * FROM music.posts;

[User] Can you order these by good_id ascending?

[Assistant] SELECT * FROM music.posts ORDER BY good_id ASC;

[User] Limit the results to 15 rows.

[Assistant] SELECT * FROM music.posts ORDER BY good_id ASC LIMIT 15;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.notifications (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  notes character varying(64) NOT NULL,
  payer_id varchar
)

CREATE TABLE tradingplatform.orders (
  id character varying(64) NOT NULL -- unique identifier,
  processed_at date,
  updated_at timestamp without time zone,
  delivery_status character varying(64),
  user_id character varying(64) -- identifier for user,
  fee text NOT NULL,
  currency varchar NOT NULL,
  notification_id text NOT NULL -- reference to notifications.id,
  FOREIGN KEY (notification_id) REFERENCES notifications(id)
)

[User] List currency, notification_id, processed_at from orders.

[Assistant] SELECT currency, notification_id, processed_at FROM tradingplatform.orders;

[User] Show the results sorted by updated_at ascending.

[Assistant] SELECT currency, notification_id, processed_at FROM tradingplatform.orders ORDER BY updated_at ASC;

[User] Can you order these by currency descending?

[Assistant] SELECT currency, notification_id, processed_at FROM tradingplatform.orders ORDER BY currency DESC;


[User] Retrieve all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

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

[User] Restrict the output to 10 items.

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


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

[Assistant] SELECT delivery_status, currency, processed_at FROM tradingplatform.orders;

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

[Assistant] SELECT delivery_status, currency, processed_at FROM tradingplatform.orders WHERE processed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Order the output by user_id descending.

[Assistant] SELECT delivery_status, currency, processed_at FROM tradingplatform.orders WHERE processed_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY user_id DESC;


[User] Display all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] List currency, processed_at, payer_id, notes for each order along with their notification information.

[Assistant] SELECT *, notifications.payer_id, notifications.notes FROM tradingplatform.orders JOIN tradingplatform.notifications ON orders.notification_id = notifications.id;

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

[Assistant] SELECT updated_at, SUM(updated_at) AS sum_updated_at FROM tradingplatform.orders GROUP BY updated_at;


[User] Retrieve all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

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

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM tradingplatform.orders WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 10;


[User] Get currency, processed_at, notification_id from all orders.

[Assistant] SELECT currency, processed_at, notification_id FROM tradingplatform.orders;

[User] Find orders where fee LIKE 'A%'.

[Assistant] SELECT currency, processed_at, notification_id FROM tradingplatform.orders WHERE fee LIKE 'A%';

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

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


[User] Get currency, updated_at, user_id from all orders.

[Assistant] SELECT currency, updated_at, user_id FROM tradingplatform.orders;

[User] What fee, updated_at, notes, updated_at do we have for orders and their associated notifications?

[Assistant] SELECT currency, updated_at, user_id, notifications.notes, notifications.updated_at FROM tradingplatform.orders JOIN tradingplatform.notifications ON orders.notification_id = notifications.id;

[User] What is the average currency for each notification_id in orders?

[Assistant] SELECT notification_id, AVERAGE(currency) AS average_currency FROM tradingplatform.orders GROUP BY notification_id;


[User] Get fee, user_id, updated_at from all orders.

[Assistant] SELECT fee, user_id, updated_at FROM tradingplatform.orders;

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

[Assistant] SELECT fee, user_id, updated_at FROM tradingplatform.orders WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

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

[Assistant] SELECT fee, user_id, updated_at FROM tradingplatform.orders WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY id ASC;


[User] What are the processed_at, updated_at, id of each order?

[Assistant] SELECT processed_at, updated_at, id FROM tradingplatform.orders;

[User] Can you order these by user_id ascending?

[Assistant] SELECT processed_at, updated_at, id FROM tradingplatform.orders ORDER BY user_id ASC;

[User] Show only 10 records.

[Assistant] SELECT processed_at, updated_at, id FROM tradingplatform.orders ORDER BY user_id ASC LIMIT 10;


[User] Show me all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Find orders from 2023.

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

[User] Sort the results by delivery_status descending.

[Assistant] SELECT * FROM tradingplatform.orders WHERE processed_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY delivery_status DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE transportation.payments (
  account_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  created_at timestamp without time zone,
  customer_id char NOT NULL -- identifier for customer,
  status character varying(64),
  verification_status character varying(64) NOT NULL
)

CREATE TABLE transportation.sales (
  payment_id character varying(64) NOT NULL -- unique identifier,
  completed_at timestamp without time zone,
  total decimal,
  approval_status character varying(128),
  product_id char,
  amount numeric,
  customer_id character varying(64),
  buyer_id varchar
)

CREATE TABLE transportation.branches (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  timezone text,
  city character varying(256) NOT NULL,
  geo_point varchar,
  payment_id text -- reference to payments.account_id,
  FOREIGN KEY (payment_id) REFERENCES payments(account_id)
)

[User] Show me all branches.

[Assistant] SELECT * FROM transportation.branches;

[User] Find branches where city LIKE 'A%'.

[Assistant] SELECT * FROM transportation.branches WHERE city LIKE 'A%';

[User] Calculate max of id for each timezone in branches.

[Assistant] SELECT timezone, MAX(id) AS max_id FROM transportation.branches GROUP BY timezone;


[User] Retrieve all branches.

[Assistant] SELECT * FROM transportation.branches;

[User] What city, geo_point, updated_at, verification_status do we have for branches and their associated payments?

[Assistant] SELECT *, payments.updated_at, payments.verification_status FROM transportation.branches JOIN transportation.payments ON branches.payment_id = payments.account_id;

[User] Restrict the output to 25 items.

[Assistant] SELECT *, payments.updated_at, payments.verification_status FROM transportation.branches JOIN transportation.payments ON branches.payment_id = payments.account_id LIMIT 25;


[User] Get all branches.

[Assistant] SELECT * FROM transportation.branches;

[User] Show the results sorted by id ascending.

[Assistant] SELECT * FROM transportation.branches ORDER BY id ASC;

[User] What is the max updated_at for each geo_point in branches?

[Assistant] SELECT geo_point, MAX(updated_at) AS max_updated_at FROM transportation.branches GROUP BY geo_point;


[User] What are the updated_at, city, payment_id of each branche?

[Assistant] SELECT updated_at, city, payment_id FROM transportation.branches;

[User] Can you order these by updated_at ascending?

[Assistant] SELECT updated_at, city, payment_id FROM transportation.branches ORDER BY updated_at ASC;

[User] Can you order these by id descending?

[Assistant] SELECT updated_at, city, payment_id FROM transportation.branches ORDER BY id DESC;


[User] Retrieve updated_at, geo_point, payment_id for every branche.

[Assistant] SELECT updated_at, geo_point, payment_id FROM transportation.branches;

[User] Get branches that match updated_at > '2023-01-01'.

[Assistant] SELECT updated_at, geo_point, payment_id FROM transportation.branches WHERE updated_at > '2023-01-01';

[User] Order the output by geo_point ascending.

[Assistant] SELECT updated_at, geo_point, payment_id FROM transportation.branches WHERE updated_at > '2023-01-01' ORDER BY geo_point ASC;


[User] Show me all branches.

[Assistant] SELECT * FROM transportation.branches;

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

[Assistant] SELECT * FROM transportation.branches ORDER BY updated_at DESC;

[User] Group branches by city and show the count of updated_at.

[Assistant] SELECT city, COUNT(updated_at) AS count_updated_at FROM transportation.branches GROUP BY city;


[User] Show me all branches.

[Assistant] SELECT * FROM transportation.branches;

[User] What city, timezone, updated_at, status do we have for branches and their associated payments?

[Assistant] SELECT *, payments.updated_at, payments.status FROM transportation.branches JOIN transportation.payments ON branches.payment_id = payments.account_id;

[User] Limit the results to 20 rows.

[Assistant] SELECT *, payments.updated_at, payments.status FROM transportation.branches JOIN transportation.payments ON branches.payment_id = payments.account_id LIMIT 20;


[User] Get updated_at, payment_id, city from all branches.

[Assistant] SELECT updated_at, payment_id, city FROM transportation.branches;

[User] Find branches where city LIKE 'A%'.

[Assistant] SELECT updated_at, payment_id, city FROM transportation.branches WHERE city LIKE 'A%';

[User] Return just 100 rows.

[Assistant] SELECT updated_at, payment_id, city FROM transportation.branches WHERE city LIKE 'A%' LIMIT 100;


[User] List geo_point, timezone, payment_id from branches.

[Assistant] SELECT geo_point, timezone, payment_id FROM transportation.branches;

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

[Assistant] SELECT geo_point, timezone, payment_id FROM transportation.branches WHERE updated_at > '2023-01-01';

[User] Get the distribution of branches across different city values.

[Assistant] SELECT city, COUNT(*) AS count FROM transportation.branches GROUP BY city ORDER BY count DESC;


[User] Get city, payment_id, timezone from all branches.

[Assistant] SELECT city, payment_id, timezone FROM transportation.branches;

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

[Assistant] SELECT city, payment_id, timezone FROM transportation.branches WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Only show the top 10 results.

[Assistant] SELECT city, payment_id, timezone FROM transportation.branches WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 10;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.likes (
  venue_id text PRIMARY KEY -- unique identifier,
  last_inspected date,
  updated_at timestamp without time zone,
  country character varying(128) NOT NULL,
  timezone text,
  name varchar,
  postal_code varchar,
  category varchar,
  state char NOT NULL,
  location_lat character varying(256),
  user_id text -- reference to users.id,
  FOREIGN KEY (user_id) REFERENCES users(id)
)

CREATE TABLE socialmedia.users (
  id varchar PRIMARY KEY -- unique identifier,
  joined_at date,
  last_active timestamp without time zone,
  api_key char,
  language text NOT NULL,
  zip_code char,
  like_id text NOT NULL -- reference to likes.venue_id,
  FOREIGN KEY (like_id) REFERENCES likes(venue_id)
)

CREATE TABLE socialmedia.comments (
  message_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  created_at timestamp,
  shares text,
  reply_to_id character varying(64) -- identifier for reply_to,
  tags character varying(128) NOT NULL,
  keywords text,
  categories varchar,
  body character varying(128),
  media_url character varying(128),
  like_id text NOT NULL -- reference to likes.venue_id,
  FOREIGN KEY (like_id) REFERENCES likes(venue_id)
)

[User] Retrieve keywords, message_id, updated_at for every comment.

[Assistant] SELECT keywords, message_id, updated_at FROM socialmedia.comments;

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

[Assistant] SELECT keywords, message_id, updated_at FROM socialmedia.comments WHERE like_id LIKE 'A%';

[User] Show me the count of comments grouped by reply_to_id.

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


[User] Display all likes.

[Assistant] SELECT * FROM socialmedia.likes;

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

[Assistant] SELECT * FROM socialmedia.likes WHERE state LIKE 'A%';

[User] Sort the results by location_lat ascending.

[Assistant] SELECT * FROM socialmedia.likes WHERE state LIKE 'A%' ORDER BY location_lat ASC;


[User] Show me zip_code, like_id, last_active for all users.

[Assistant] SELECT zip_code, like_id, last_active FROM socialmedia.users;

[User] Retrieve api_key, last_active, country, location_lat showing the relationship between users and likes.

[Assistant] SELECT zip_code, like_id, last_active, likes.country, likes.location_lat FROM socialmedia.users JOIN socialmedia.likes ON users.like_id = likes.venue_id;

[User] Get sum of zip_code by zip_code from users.

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


[User] Get keywords, tags, created_at from all comments.

[Assistant] SELECT keywords, tags, created_at FROM socialmedia.comments;

[User] Show me shares, like_id, updated_at, name from comments and their related likes.

[Assistant] SELECT keywords, tags, created_at, likes.updated_at, likes.name FROM socialmedia.comments JOIN socialmedia.likes ON comments.like_id = likes.venue_id;

[User] Only show the top 25 results.

[Assistant] SELECT keywords, tags, created_at, likes.updated_at, likes.name FROM socialmedia.comments JOIN socialmedia.likes ON comments.like_id = likes.venue_id LIMIT 25;


[User] List all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Get body, keywords, category, last_inspected by joining comments with likes.

[Assistant] SELECT *, likes.category, likes.last_inspected FROM socialmedia.comments JOIN socialmedia.likes ON comments.like_id = likes.venue_id;

[User] Get max of keywords by keywords from comments.

[Assistant] SELECT keywords, MAX(keywords) AS max_keywords FROM socialmedia.comments GROUP BY keywords;


[User] Display all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Get users that match joined_at > '2023-01-01'.

[Assistant] SELECT * FROM socialmedia.users WHERE joined_at > '2023-01-01';

[User] Only show the top 15 results.

[Assistant] SELECT * FROM socialmedia.users WHERE joined_at > '2023-01-01' LIMIT 15;


[User] Get location_lat, last_inspected, name from all likes.

[Assistant] SELECT location_lat, last_inspected, name FROM socialmedia.likes;

[User] Sort the results by last_inspected ascending.

[Assistant] SELECT location_lat, last_inspected, name FROM socialmedia.likes ORDER BY last_inspected ASC;

[User] Group likes by category and show the min of location_lat.

[Assistant] SELECT category, MIN(location_lat) AS min_location_lat FROM socialmedia.likes GROUP BY category;


[User] Display all users.

[Assistant] SELECT * FROM socialmedia.users;

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

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

[User] Sort the results by api_key ascending.

[Assistant] SELECT * FROM socialmedia.users WHERE joined_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY api_key ASC;


[User] Retrieve all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Find likes where last_inspected > '2023-01-01'.

[Assistant] SELECT * FROM socialmedia.likes WHERE last_inspected > '2023-01-01';

[User] Return just 25 rows.

[Assistant] SELECT * FROM socialmedia.likes WHERE last_inspected > '2023-01-01' LIMIT 25;


[User] Show me all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Show the results sorted by state ascending.

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

[User] Tally up likes by category.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE music.comments (
  comment_id text PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at timestamp,
  categories character varying(64) NOT NULL,
  reply_to_id char -- identifier for reply_to,
  subject text
)

CREATE TABLE music.products (
  id character varying(64) NOT NULL -- unique identifier,
  expires_at timestamp,
  quantity character varying(64) NOT NULL,
  thumbnail_url varchar,
  tax_rate character varying(256),
  comment_id text -- reference to comments.comment_id,
  FOREIGN KEY (comment_id) REFERENCES comments(comment_id)
)

[User] Retrieve id, thumbnail_url, comment_id for every product.

[Assistant] SELECT id, thumbnail_url, comment_id FROM music.products;

[User] List products with dates from last week.

[Assistant] SELECT id, thumbnail_url, comment_id FROM music.products WHERE expires_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Calculate max of expires_at for each expires_at in products.

[Assistant] SELECT expires_at, MAX(expires_at) AS max_expires_at FROM music.products GROUP BY expires_at;


[User] Show me expires_at, tax_rate, id for all products.

[Assistant] SELECT expires_at, tax_rate, id FROM music.products;

[User] Retrieve expires_at, id, reply_to_id, updated_at showing the relationship between products and comments.

[Assistant] SELECT expires_at, tax_rate, id, comments.reply_to_id, comments.updated_at FROM music.products JOIN music.comments ON products.comment_id = comments.comment_id;

[User] What is the sum thumbnail_url for each expires_at in products?

[Assistant] SELECT expires_at, SUM(thumbnail_url) AS sum_thumbnail_url FROM music.products GROUP BY expires_at;


[User] List tax_rate, thumbnail_url, expires_at from products.

[Assistant] SELECT tax_rate, thumbnail_url, expires_at FROM music.products;

[User] Show me quantity, tax_rate, reply_to_id, subject from products and their related comments.

[Assistant] SELECT tax_rate, thumbnail_url, expires_at, comments.reply_to_id, comments.subject FROM music.products JOIN music.comments ON products.comment_id = comments.comment_id;

[User] Order the output by comment_id descending.

[Assistant] SELECT tax_rate, thumbnail_url, expires_at, comments.reply_to_id, comments.subject FROM music.products JOIN music.comments ON products.comment_id = comments.comment_id ORDER BY comment_id DESC;


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

[Assistant] SELECT thumbnail_url, quantity, expires_at FROM music.products;

[User] Show the results sorted by id ascending.

[Assistant] SELECT thumbnail_url, quantity, expires_at FROM music.products ORDER BY id ASC;

[User] Sort the results by comment_id descending.

[Assistant] SELECT thumbnail_url, quantity, expires_at FROM music.products ORDER BY comment_id DESC;


[User] Display all products.

[Assistant] SELECT * FROM music.products;

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

[Assistant] SELECT * FROM music.products WHERE expires_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Restrict the output to 20 items.

[Assistant] SELECT * FROM music.products WHERE expires_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 20;


[User] List all products.

[Assistant] SELECT * FROM music.products;

[User] Get thumbnail_url, quantity, categories, created_at by joining products with comments.

[Assistant] SELECT *, comments.categories, comments.created_at FROM music.products JOIN music.comments ON products.comment_id = comments.comment_id;

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

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


[User] Retrieve all products.

[Assistant] SELECT * FROM music.products;

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

[Assistant] SELECT * FROM music.products ORDER BY thumbnail_url ASC;

[User] Order the output by id descending.

[Assistant] SELECT * FROM music.products ORDER BY id DESC;


[User] Show me comment_id, tax_rate, id for all products.

[Assistant] SELECT comment_id, tax_rate, id FROM music.products;

[User] What quantity, comment_id, created_at, reply_to_id do we have for products and their associated comments?

[Assistant] SELECT comment_id, tax_rate, id, comments.created_at, comments.reply_to_id FROM music.products JOIN music.comments ON products.comment_id = comments.comment_id;

[User] What is the sum expires_at for each comment_id in products?

[Assistant] SELECT comment_id, SUM(expires_at) AS sum_expires_at FROM music.products GROUP BY comment_id;


[User] List id, expires_at, tax_rate from products.

[Assistant] SELECT id, expires_at, tax_rate FROM music.products;

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

[Assistant] SELECT id, expires_at, tax_rate FROM music.products WHERE quantity LIKE 'A%';

[User] Calculate count of tax_rate for each id in products.

[Assistant] SELECT id, COUNT(tax_rate) AS count_tax_rate FROM music.products GROUP BY id;


[User] List all products.

[Assistant] SELECT * FROM music.products;

[User] Show the results sorted by comment_id ascending.

[Assistant] SELECT * FROM music.products ORDER BY comment_id ASC;

[User] Get count of thumbnail_url by id from products.

[Assistant] SELECT id, COUNT(thumbnail_url) AS count_thumbnail_url FROM music.products GROUP BY 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.audits (
  id text PRIMARY KEY -- unique identifier,
  completed_at timestamp without time zone,
  status character varying(256) NOT NULL,
  buyer_id text NOT NULL -- identifier for buyer,
  tax smallint,
  card_type char NOT NULL,
  exchange_rate varchar,
  fee text
)

CREATE TABLE finance.customers (
  employee_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  zip_code character varying(256),
  last_login timestamp without time zone,
  language character varying(64),
  username text NOT NULL
)

CREATE TABLE finance.accounts (
  account_id character varying(64) NOT NULL -- unique identifier,
  due_date date,
  status character varying(256),
  payee_id character varying(64) -- identifier for payee,
  approval_status text
)

[User] Get all audits.

[Assistant] SELECT * FROM finance.audits;

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

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

[User] Show the results sorted by tax descending.

[Assistant] SELECT * FROM finance.audits WHERE buyer_id LIKE 'A%' ORDER BY tax DESC;


[User] List exchange_rate, tax, status from audits.

[Assistant] SELECT exchange_rate, tax, status FROM finance.audits;

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

[Assistant] SELECT exchange_rate, tax, status FROM finance.audits WHERE exchange_rate LIKE 'A%';

[User] Show me min of card_type grouped by status for audits.

[Assistant] SELECT status, MIN(card_type) AS min_card_type FROM finance.audits GROUP BY status;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Show the results sorted by username descending.

[Assistant] SELECT * FROM finance.customers ORDER BY username DESC;


[User] Get fee, buyer_id, card_type from all audits.

[Assistant] SELECT fee, buyer_id, card_type FROM finance.audits;

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

[Assistant] SELECT fee, buyer_id, card_type FROM finance.audits WHERE completed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Show only 15 records.

[Assistant] SELECT fee, buyer_id, card_type FROM finance.audits WHERE completed_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 15;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Can you order these by updated_at descending?

[Assistant] SELECT * FROM finance.customers ORDER BY updated_at DESC;

[User] Show the results sorted by employee_id ascending.

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


[User] What are the account_id, payee_id, status of each account?

[Assistant] SELECT account_id, payee_id, status FROM finance.accounts;

[User] Retrieve accounts where approval_status LIKE 'A%'.

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

[User] Sort the results by due_date descending.

[Assistant] SELECT account_id, payee_id, status FROM finance.accounts WHERE approval_status LIKE 'A%' ORDER BY due_date DESC;


[User] Show me last_login, employee_id, username for all customers.

[Assistant] SELECT last_login, employee_id, username FROM finance.customers;

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

[Assistant] SELECT last_login, employee_id, username FROM finance.customers WHERE last_login > '2023-12-01';

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

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


[User] What are the status, completed_at, card_type of each audit?

[Assistant] SELECT status, completed_at, card_type FROM finance.audits;

[User] Sort the results by buyer_id descending.

[Assistant] SELECT status, completed_at, card_type FROM finance.audits ORDER BY buyer_id DESC;

[User] What is the min exchange_rate for each completed_at in audits?

[Assistant] SELECT completed_at, MIN(exchange_rate) AS min_exchange_rate FROM finance.audits GROUP BY completed_at;


[User] List tax, fee, status from audits.

[Assistant] SELECT tax, fee, status FROM finance.audits;

[User] Order the output by tax ascending.

[Assistant] SELECT tax, fee, status FROM finance.audits ORDER BY tax ASC;

[User] Show the results sorted by tax ascending.

[Assistant] SELECT tax, fee, status FROM finance.audits ORDER BY tax ASC;


[User] Display all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

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

[User] Show only 10 records.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.orders (
  order_id integer PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  created_at timestamp without time zone,
  payment_method varchar NOT NULL,
  payment_status text,
  exchange_rate character varying(128) NOT NULL,
  tax decimal NOT NULL,
  approval_status character varying(128) NOT NULL,
  asset_id text NOT NULL -- reference to assets.barcode,
  FOREIGN KEY (asset_id) REFERENCES assets(barcode)
)

CREATE TABLE tradingplatform.assets (
  barcode varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  published_at timestamp,
  image_url character varying(128),
  description character varying(64) NOT NULL,
  available character varying(256) NOT NULL,
  media_url character varying(128),
  tax_rate character varying(64) NOT NULL,
  featured_rank character varying(128),
  order_id integer NOT NULL -- reference to orders.order_id,
  FOREIGN KEY (order_id) REFERENCES orders(order_id)
)

[User] Show me tax_rate, image_url, media_url for all assets.

[Assistant] SELECT tax_rate, image_url, media_url FROM tradingplatform.assets;

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

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

[User] Sort the results by description descending.

[Assistant] SELECT tax_rate, image_url, media_url FROM tradingplatform.assets ORDER BY description DESC;


[User] Show me all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] List orders with dates from 2023.

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

[User] Tally up orders by payment_method.

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


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

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

[User] Get all assets older than 6 months.

[Assistant] SELECT order_id, published_at, created_at FROM tradingplatform.assets WHERE published_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Return just 50 rows.

[Assistant] SELECT order_id, published_at, created_at FROM tradingplatform.assets WHERE published_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 50;


[User] Show me all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Sort the results by featured_rank descending.

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

[User] Show only 15 records.

[Assistant] SELECT * FROM tradingplatform.assets ORDER BY featured_rank DESC LIMIT 15;


[User] Get featured_rank, image_url, tax_rate from all assets.

[Assistant] SELECT featured_rank, image_url, tax_rate FROM tradingplatform.assets;

[User] Get media_url, published_at, payment_method, tax by joining assets with orders.

[Assistant] SELECT featured_rank, image_url, tax_rate, orders.payment_method, orders.tax FROM tradingplatform.assets JOIN tradingplatform.orders ON assets.order_id = orders.order_id;

[User] Sort the results by tax_rate descending.

[Assistant] SELECT featured_rank, image_url, tax_rate, orders.payment_method, orders.tax FROM tradingplatform.assets JOIN tradingplatform.orders ON assets.order_id = orders.order_id ORDER BY tax_rate DESC;


[User] List all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Retrieve assets where order_id > 78.

[Assistant] SELECT * FROM tradingplatform.assets WHERE order_id > 78;

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

[Assistant] SELECT media_url, MAX(media_url) AS max_media_url FROM tradingplatform.assets GROUP BY media_url;


[User] List payment_status, tax, exchange_rate from orders.

[Assistant] SELECT payment_status, tax, exchange_rate FROM tradingplatform.orders;

[User] Retrieve created_at, exchange_rate, image_url, description showing the relationship between orders and assets.

[Assistant] SELECT payment_status, tax, exchange_rate, assets.image_url, assets.description FROM tradingplatform.orders JOIN tradingplatform.assets ON orders.asset_id = assets.barcode;

[User] Show only 20 records.

[Assistant] SELECT payment_status, tax, exchange_rate, assets.image_url, assets.description FROM tradingplatform.orders JOIN tradingplatform.assets ON orders.asset_id = assets.barcode LIMIT 20;


[User] Show me order_id, description, created_at for all assets.

[Assistant] SELECT order_id, description, created_at FROM tradingplatform.assets;

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

[Assistant] SELECT order_id, description, created_at FROM tradingplatform.assets WHERE published_at = CURRENT_DATE - INTERVAL '1 day';

[User] Limit the results to 5 rows.

[Assistant] SELECT order_id, description, created_at FROM tradingplatform.assets WHERE published_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 5;


[User] List all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Find assets where media_url LIKE 'A%'.

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

[User] What is the average published_at for each image_url in assets?

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


[User] List all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] List orders with dates from last week.

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

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

[Assistant] SELECT tax, COUNT(*) AS count FROM tradingplatform.orders GROUP BY tax 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 healthcare.departments (
  employee_id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp,
  updated_at timestamp,
  timezone character varying(128),
  is_verified boolean -- indicates if verified is true,
  bio character varying(128),
  avatar varchar,
  last_login timestamp,
  patient_id integer -- reference to patients.user_id,
  FOREIGN KEY (patient_id) REFERENCES patients(user_id)
)

CREATE TABLE healthcare.patients (
  user_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  first_name char,
  nationality varchar,
  address character varying(128),
  membership_level varchar
)

CREATE TABLE healthcare.billing (
  employee_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  age character varying(128),
  last_login timestamp without time zone NOT NULL,
  salt character varying(64),
  phone character varying(64),
  patient_id integer -- reference to patients.user_id,
  FOREIGN KEY (patient_id) REFERENCES patients(user_id)
)

[User] Show me all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] List avatar, is_verified, updated_at, nationality for each department along with their patient information.

[Assistant] SELECT *, patients.updated_at, patients.nationality FROM healthcare.departments JOIN healthcare.patients ON departments.patient_id = patients.user_id;

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

[Assistant] SELECT updated_at, MIN(patient_id) AS min_patient_id FROM healthcare.departments GROUP BY updated_at;


[User] Retrieve all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Show the results sorted by updated_at ascending.

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

[User] Group departments by avatar and show the count of avatar.

[Assistant] SELECT avatar, COUNT(avatar) AS count_avatar FROM healthcare.departments GROUP BY avatar;


[User] Get all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

[Assistant] SELECT * FROM healthcare.billing WHERE last_login = CURRENT_DATE - INTERVAL '1 day';

[User] How many billing are there per employee_id?

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


[User] List joined_at, avatar, last_login from departments.

[Assistant] SELECT joined_at, avatar, last_login FROM healthcare.departments;

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

[Assistant] SELECT joined_at, avatar, last_login FROM healthcare.departments WHERE joined_at > '2023-01-01';

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

[Assistant] SELECT joined_at, avatar, last_login FROM healthcare.departments WHERE joined_at > '2023-01-01' ORDER BY patient_id DESC;


[User] Get all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] Only show the top 25 results.

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


[User] Show me is_verified, bio, timezone for all departments.

[Assistant] SELECT is_verified, bio, timezone FROM healthcare.departments;

[User] Get all departments between January and March.

[Assistant] SELECT is_verified, bio, timezone FROM healthcare.departments WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] What is the sum updated_at for each timezone in departments?

[Assistant] SELECT timezone, SUM(updated_at) AS sum_updated_at FROM healthcare.departments GROUP BY timezone;


[User] List timezone, last_login, is_verified from departments.

[Assistant] SELECT timezone, last_login, is_verified FROM healthcare.departments;

[User] Show the results sorted by joined_at descending.

[Assistant] SELECT timezone, last_login, is_verified FROM healthcare.departments ORDER BY joined_at DESC;

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

[Assistant] SELECT timezone, last_login, is_verified FROM healthcare.departments ORDER BY patient_id ASC;


[User] List age, phone, updated_at from billing.

[Assistant] SELECT age, phone, updated_at FROM healthcare.billing;

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

[Assistant] SELECT age, phone, updated_at FROM healthcare.billing WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Show the results sorted by employee_id descending.

[Assistant] SELECT age, phone, updated_at FROM healthcare.billing WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY employee_id DESC;


[User] Display all departments.

[Assistant] SELECT * FROM healthcare.departments;

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

[Assistant] SELECT * FROM healthcare.departments WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Limit the results to 25 rows.

[Assistant] SELECT * FROM healthcare.departments WHERE updated_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 25;


[User] What are the avatar, joined_at, bio of each department?

[Assistant] SELECT avatar, joined_at, bio FROM healthcare.departments;

[User] Get departments that match updated_at > '2023-01-01'.

[Assistant] SELECT avatar, joined_at, bio FROM healthcare.departments WHERE updated_at > '2023-01-01';

[User] Show me the count of departments grouped by last_login.

[Assistant] SELECT last_login, COUNT(*) AS count FROM healthcare.departments GROUP BY last_login 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.messages (
  message_id character varying(64) NOT NULL -- unique identifier,
  edited_at timestamp,
  categories varchar NOT NULL,
  author_id character varying(128) NOT NULL -- identifier for author,
  reply_to_id character varying(64) -- identifier for reply_to,
  description text,
  score character varying(128),
  format character varying(64) NOT NULL,
  follower_id text NOT NULL -- reference to followers.id,
  FOREIGN KEY (follower_id) REFERENCES followers(id)
)

CREATE TABLE socialmedia.followers (
  id text PRIMARY KEY -- unique identifier,
  expires_at timestamp,
  created_at timestamp,
  description character varying(256),
  tax_rate character varying(256) NOT NULL,
  category char,
  currency varchar
)

CREATE TABLE socialmedia.comments (
  id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  image_url character varying(256),
  user_id varchar -- identifier for user,
  follower_id text -- reference to followers.id,
  FOREIGN KEY (follower_id) REFERENCES followers(id)
)

[User] Show me image_url, edited_at, follower_id for all comments.

[Assistant] SELECT image_url, edited_at, follower_id FROM socialmedia.comments;

[User] Retrieve follower_id, edited_at, expires_at, tax_rate showing the relationship between comments and followers.

[Assistant] SELECT image_url, edited_at, follower_id, followers.expires_at, followers.tax_rate FROM socialmedia.comments JOIN socialmedia.followers ON comments.follower_id = followers.id;

[User] What is the count user_id for each follower_id in comments?

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


[User] List all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

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

[User] Tally up comments by user_id.

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


[User] Retrieve message_id, score, format for every message.

[Assistant] SELECT message_id, score, format FROM socialmedia.messages;

[User] Get messages that match categories LIKE 'A%'.

[Assistant] SELECT message_id, score, format FROM socialmedia.messages WHERE categories LIKE 'A%';

[User] Calculate average of description for each score in messages.

[Assistant] SELECT score, AVERAGE(description) AS average_description FROM socialmedia.messages GROUP BY score;


[User] List all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] List comments with dates created yesterday.

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

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

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


[User] Get all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Show me edited_at, user_id, created_at, expires_at from comments and their related followers.

[Assistant] SELECT *, followers.created_at, followers.expires_at FROM socialmedia.comments JOIN socialmedia.followers ON comments.follower_id = followers.id;

[User] Show me min of follower_id grouped by user_id for comments.

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


[User] Display all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

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

[User] Return just 20 rows.

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


[User] Display all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Order the output by follower_id ascending.

[Assistant] SELECT * FROM socialmedia.comments ORDER BY follower_id ASC;

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

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


[User] Get all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Retrieve comments where image_url LIKE 'A%'.

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

[User] Can you order these by follower_id ascending?

[Assistant] SELECT * FROM socialmedia.comments WHERE image_url LIKE 'A%' ORDER BY follower_id ASC;


[User] What are the edited_at, author_id, message_id of each message?

[Assistant] SELECT edited_at, author_id, message_id FROM socialmedia.messages;

[User] Find messages created yesterday.

[Assistant] SELECT edited_at, author_id, message_id FROM socialmedia.messages WHERE edited_at = CURRENT_DATE - INTERVAL '1 day';

[User] Group messages by categories and show the average of edited_at.

[Assistant] SELECT categories, AVERAGE(edited_at) AS average_edited_at FROM socialmedia.messages GROUP BY categories;


[User] Retrieve score, format, author_id for every message.

[Assistant] SELECT score, format, author_id FROM socialmedia.messages;

[User] Can you order these by reply_to_id descending?

[Assistant] SELECT score, format, author_id FROM socialmedia.messages ORDER BY reply_to_id DESC;

[User] Get average of edited_at by description from messages.

[Assistant] SELECT description, AVERAGE(edited_at) AS average_edited_at FROM socialmedia.messages GROUP BY description;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.departments (
  product_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  created_at date,
  thumbnail_url varchar,
  tax_rate character varying(128) NOT NULL,
  quantity character varying(64),
  reserved character varying(64) NOT NULL,
  description text,
  name char,
  patient_id text NOT NULL -- reference to patients.employee_id,
  FOREIGN KEY (patient_id) REFERENCES patients(employee_id)
)

CREATE TABLE healthcare.patients (
  employee_id varchar PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  salt char,
  gender character varying(64) NOT NULL,
  display_name character varying(64) NOT NULL,
  nationality character varying(128) NOT NULL,
  age character varying(256),
  department_id integer -- reference to departments.product_id,
  FOREIGN KEY (department_id) REFERENCES departments(product_id)
)

[User] List all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Find patients older than 6 months.

[Assistant] SELECT * FROM healthcare.patients WHERE last_active <= CURRENT_DATE - INTERVAL '6 months';

[User] Can you order these by salt descending?

[Assistant] SELECT * FROM healthcare.patients WHERE last_active <= CURRENT_DATE - INTERVAL '6 months' ORDER BY salt DESC;


[User] Get description, updated_at, reserved from all departments.

[Assistant] SELECT description, updated_at, reserved FROM healthcare.departments;

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

[Assistant] SELECT description, updated_at, reserved FROM healthcare.departments WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Get the distribution of departments across different name values.

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


[User] What are the created_at, tax_rate, thumbnail_url of each department?

[Assistant] SELECT created_at, tax_rate, thumbnail_url FROM healthcare.departments;

[User] Get thumbnail_url, quantity, display_name, department_id by joining departments with patients.

[Assistant] SELECT created_at, tax_rate, thumbnail_url, patients.display_name, patients.department_id FROM healthcare.departments JOIN healthcare.patients ON departments.patient_id = patients.employee_id;

[User] Calculate sum of thumbnail_url for each patient_id in departments.

[Assistant] SELECT patient_id, SUM(thumbnail_url) AS sum_thumbnail_url FROM healthcare.departments GROUP BY patient_id;


[User] Get gender, age, last_active from all patients.

[Assistant] SELECT gender, age, last_active FROM healthcare.patients;

[User] Get salt, gender, created_at, patient_id by joining patients with departments.

[Assistant] SELECT gender, age, last_active, departments.created_at, departments.patient_id FROM healthcare.patients JOIN healthcare.departments ON patients.department_id = departments.product_id;

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

[Assistant] SELECT gender, age, last_active, departments.created_at, departments.patient_id FROM healthcare.patients JOIN healthcare.departments ON patients.department_id = departments.product_id ORDER BY nationality DESC;


[User] Show me gender, salt, department_id for all patients.

[Assistant] SELECT gender, salt, department_id FROM healthcare.patients;

[User] List patients that have department_id > 5.

[Assistant] SELECT gender, salt, department_id FROM healthcare.patients WHERE department_id > 5;

[User] Return just 5 rows.

[Assistant] SELECT gender, salt, department_id FROM healthcare.patients WHERE department_id > 5 LIMIT 5;


[User] List age, display_name, department_id from patients.

[Assistant] SELECT age, display_name, department_id FROM healthcare.patients;

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

[Assistant] SELECT age, display_name, department_id FROM healthcare.patients WHERE last_active = CURRENT_DATE - INTERVAL '1 day';

[User] Return just 20 rows.

[Assistant] SELECT age, display_name, department_id FROM healthcare.patients WHERE last_active = CURRENT_DATE - INTERVAL '1 day' LIMIT 20;