System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.logs (
  payment_id text PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  payment_status character varying(256),
  exchange_rate varchar NOT NULL,
  approval_status char NOT NULL,
  order_id integer NOT NULL -- reference to orders.transaction_id,
  FOREIGN KEY (order_id) REFERENCES orders(transaction_id)
)

CREATE TABLE tradingplatform.orders (
  transaction_id integer PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  payment_method character varying(64),
  currency varchar NOT NULL,
  subtotal smallint,
  payment_status character varying(256),
  exchange_rate character varying(256),
  quantity char NOT NULL,
  product_id character varying(256) NOT NULL -- identifier for product,
  log_id text NOT NULL -- reference to logs.payment_id,
  FOREIGN KEY (log_id) REFERENCES logs(payment_id)
)

CREATE TABLE tradingplatform.trades (
  payment_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  total integer NOT NULL,
  payment_method varchar,
  exchange_rate character varying(256) NOT NULL,
  amount decimal,
  user_id character varying(64) -- identifier for user,
  order_id integer NOT NULL -- reference to orders.transaction_id,
  log_id text -- reference to logs.payment_id,
  FOREIGN KEY (order_id) REFERENCES orders(transaction_id),
  FOREIGN KEY (log_id) REFERENCES logs(payment_id)
)

[User] Display all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

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

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

[User] Restrict the output to 15 items.

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


[User] Display all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

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

[User] How many orders are there per cancelled_at?

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


[User] Retrieve all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Find orders from last week.

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

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

[Assistant] SELECT * FROM tradingplatform.orders WHERE cancelled_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY currency ASC;


[User] Retrieve exchange_rate, cancelled_at, payment_status for every log.

[Assistant] SELECT exchange_rate, cancelled_at, payment_status FROM tradingplatform.logs;

[User] Show me logs with order_id > 47.

[Assistant] SELECT exchange_rate, cancelled_at, payment_status FROM tradingplatform.logs WHERE order_id > 47;

[User] Restrict the output to 50 items.

[Assistant] SELECT exchange_rate, cancelled_at, payment_status FROM tradingplatform.logs WHERE order_id > 47 LIMIT 50;


[User] Display all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Find orders between January and March.

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

[User] How many orders are there per log_id?

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


[User] Show me payment_status, log_id, quantity for all orders.

[Assistant] SELECT payment_status, log_id, quantity FROM tradingplatform.orders;

[User] Find orders older than 6 months.

[Assistant] SELECT payment_status, log_id, quantity FROM tradingplatform.orders WHERE cancelled_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Show only 20 records.

[Assistant] SELECT payment_status, log_id, quantity FROM tradingplatform.orders WHERE cancelled_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 20;


[User] Retrieve payment_method, currency, product_id for every order.

[Assistant] SELECT payment_method, currency, product_id FROM tradingplatform.orders;

[User] Show the results sorted by currency descending.

[Assistant] SELECT payment_method, currency, product_id FROM tradingplatform.orders ORDER BY currency DESC;

[User] Can you order these by product_id ascending?

[Assistant] SELECT payment_method, currency, product_id FROM tradingplatform.orders ORDER BY product_id ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE inventory.products (
  product_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  published_at date,
  title character varying(256) NOT NULL,
  image_url varchar,
  tax_rate text,
  purchase_id text NOT NULL -- reference to purchases.transaction_id,
  FOREIGN KEY (purchase_id) REFERENCES purchases(transaction_id)
)

CREATE TABLE inventory.purchases (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  cancelled_at date,
  fee varchar,
  payment_method char,
  card_type character varying(256),
  delivery_status character varying(256),
  account_id character varying(128),
  exchange_rate text,
  product_id text NOT NULL -- reference to products.product_id,
  FOREIGN KEY (product_id) REFERENCES products(product_id)
)

[User] What are the image_url, purchase_id, tax_rate of each product?

[Assistant] SELECT image_url, purchase_id, tax_rate FROM inventory.products;

[User] Get all products from last week.

[Assistant] SELECT image_url, purchase_id, tax_rate FROM inventory.products WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Can you order these by title descending?

[Assistant] SELECT image_url, purchase_id, tax_rate FROM inventory.products WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY title DESC;


[User] Show me title, tax_rate, image_url for all products.

[Assistant] SELECT title, tax_rate, image_url FROM inventory.products;

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

[Assistant] SELECT title, tax_rate, image_url FROM inventory.products WHERE tax_rate LIKE 'A%';

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

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


[User] Get all products.

[Assistant] SELECT * FROM inventory.products;

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

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

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

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


[User] What are the account_id, card_type, delivery_status of each purchase?

[Assistant] SELECT account_id, card_type, delivery_status FROM inventory.purchases;

[User] Find purchases where delivery_status LIKE 'A%'.

[Assistant] SELECT account_id, card_type, delivery_status FROM inventory.purchases WHERE delivery_status LIKE 'A%';

[User] Sort the results by fee ascending.

[Assistant] SELECT account_id, card_type, delivery_status FROM inventory.purchases WHERE delivery_status LIKE 'A%' ORDER BY fee ASC;


[User] Show me all purchases.

[Assistant] SELECT * FROM inventory.purchases;

[User] Show the results sorted by delivery_status descending.

[Assistant] SELECT * FROM inventory.purchases ORDER BY delivery_status DESC;

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

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


[User] Retrieve all products.

[Assistant] SELECT * FROM inventory.products;

[User] Sort the results by updated_at ascending.

[Assistant] SELECT * FROM inventory.products ORDER BY updated_at ASC;

[User] Only show the top 50 results.

[Assistant] SELECT * FROM inventory.products ORDER BY updated_at ASC LIMIT 50;


[User] List all products.

[Assistant] SELECT * FROM inventory.products;

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

[Assistant] SELECT * FROM inventory.products WHERE title LIKE 'A%';

[User] Get sum of updated_at by purchase_id from products.

[Assistant] SELECT purchase_id, SUM(updated_at) AS sum_updated_at FROM inventory.products GROUP BY purchase_id;


[User] List all products.

[Assistant] SELECT * FROM inventory.products;

[User] What image_url, purchase_id, card_type, product_id do we have for products and their associated purchases?

[Assistant] SELECT *, purchases.card_type, purchases.product_id FROM inventory.products JOIN inventory.purchases ON products.purchase_id = purchases.transaction_id;

[User] Group products by tax_rate and show the count of tax_rate.

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


[User] List all purchases.

[Assistant] SELECT * FROM inventory.purchases;

[User] Retrieve delivery_status, exchange_rate, image_url, title showing the relationship between purchases and products.

[Assistant] SELECT *, products.image_url, products.title FROM inventory.purchases JOIN inventory.products ON purchases.product_id = products.product_id;

[User] Show the results sorted by account_id descending.

[Assistant] SELECT *, products.image_url, products.title FROM inventory.purchases JOIN inventory.products ON purchases.product_id = products.product_id ORDER BY account_id DESC;


[User] Get title, updated_at, purchase_id from all products.

[Assistant] SELECT title, updated_at, purchase_id FROM inventory.products;

[User] Show me updated_at, tax_rate, card_type, delivery_status from products and their related purchases.

[Assistant] SELECT title, updated_at, purchase_id, purchases.card_type, purchases.delivery_status FROM inventory.products JOIN inventory.purchases ON products.purchase_id = purchases.transaction_id;

[User] Can you order these by image_url descending?

[Assistant] SELECT title, updated_at, purchase_id, purchases.card_type, purchases.delivery_status FROM inventory.products JOIN inventory.purchases ON products.purchase_id = purchases.transaction_id ORDER BY image_url DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.posts (
  post_id text PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  format character varying(128),
  visibility text,
  content character varying(256),
  title char NOT NULL,
  message_id text NOT NULL -- reference to messages.post_id,
  FOREIGN KEY (message_id) REFERENCES messages(post_id)
)

CREATE TABLE socialmedia.messages (
  post_id text PRIMARY KEY -- unique identifier,
  created_at date,
  reply_to_id character varying(128),
  subject character varying(256),
  title character varying(64)
)

[User] Get all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] Can you order these by title ascending?

[Assistant] SELECT * FROM socialmedia.posts ORDER BY title ASC;

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

[Assistant] SELECT * FROM socialmedia.posts ORDER BY message_id ASC;


[User] Get content, format, title from all posts.

[Assistant] SELECT content, format, title FROM socialmedia.posts;

[User] List posts that have title LIKE 'A%'.

[Assistant] SELECT content, format, title FROM socialmedia.posts WHERE title LIKE 'A%';

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

[Assistant] SELECT content, format, title FROM socialmedia.posts WHERE title LIKE 'A%' ORDER BY format ASC;


[User] Show me visibility, title, published_at for all posts.

[Assistant] SELECT visibility, title, published_at FROM socialmedia.posts;

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

[Assistant] SELECT visibility, title, published_at FROM socialmedia.posts ORDER BY format ASC;

[User] Show me the count of posts grouped by title.

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


[User] Display all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] Get published_at, title, reply_to_id, subject by joining posts with messages.

[Assistant] SELECT *, messages.reply_to_id, messages.subject FROM socialmedia.posts JOIN socialmedia.messages ON posts.message_id = messages.post_id;

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

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


[User] List all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] Show me posts with content LIKE 'A%'.

[Assistant] SELECT * FROM socialmedia.posts WHERE content LIKE 'A%';

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

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


[User] Get published_at, format, content from all posts.

[Assistant] SELECT published_at, format, content FROM socialmedia.posts;

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

[Assistant] SELECT published_at, format, content FROM socialmedia.posts WHERE format LIKE 'A%';

[User] Show me average of published_at grouped by visibility for posts.

[Assistant] SELECT visibility, AVERAGE(published_at) AS average_published_at FROM socialmedia.posts GROUP BY visibility;


[User] Display all posts.

[Assistant] SELECT * FROM socialmedia.posts;

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

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

[User] Get average of visibility by visibility from posts.

[Assistant] SELECT visibility, AVERAGE(visibility) AS average_visibility FROM socialmedia.posts GROUP BY visibility;


[User] Display all posts.

[Assistant] SELECT * FROM socialmedia.posts;

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

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

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

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


[User] List published_at, message_id, title from posts.

[Assistant] SELECT published_at, message_id, title FROM socialmedia.posts;

[User] List title, format, reply_to_id, subject for each post along with their message information.

[Assistant] SELECT published_at, message_id, title, messages.reply_to_id, messages.subject FROM socialmedia.posts JOIN socialmedia.messages ON posts.message_id = messages.post_id;

[User] Order the output by content descending.

[Assistant] SELECT published_at, message_id, title, messages.reply_to_id, messages.subject FROM socialmedia.posts JOIN socialmedia.messages ON posts.message_id = messages.post_id ORDER BY content DESC;


[User] Get all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] What visibility, message_id, subject, created_at do we have for posts and their associated messages?

[Assistant] SELECT *, messages.subject, messages.created_at FROM socialmedia.posts JOIN socialmedia.messages ON posts.message_id = messages.post_id;

[User] Order the output by published_at descending.

[Assistant] SELECT *, messages.subject, messages.created_at FROM socialmedia.posts JOIN socialmedia.messages ON posts.message_id = messages.post_id ORDER BY published_at DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.billing (
  address_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  parking_available text NOT NULL,
  timezone character varying(256),
  address_line2 character varying(128),
  operating_hours varchar NOT NULL,
  appointment_id text -- reference to appointments.post_id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(post_id)
)

CREATE TABLE healthcare.appointments (
  post_id varchar PRIMARY KEY -- unique identifier,
  edited_at date,
  published_at timestamp,
  user_id character varying(256),
  tags varchar,
  score character varying(128),
  media_url character varying(64),
  rating char
)

[User] Display all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Retrieve updated_at, appointment_id, score, user_id showing the relationship between billing and appointments.

[Assistant] SELECT *, appointments.score, appointments.user_id FROM healthcare.billing JOIN healthcare.appointments ON billing.appointment_id = appointments.post_id;

[User] Order the output by operating_hours descending.

[Assistant] SELECT *, appointments.score, appointments.user_id FROM healthcare.billing JOIN healthcare.appointments ON billing.appointment_id = appointments.post_id ORDER BY operating_hours DESC;


[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] Calculate min of operating_hours for each appointment_id in billing.

[Assistant] SELECT appointment_id, MIN(operating_hours) AS min_operating_hours FROM healthcare.billing GROUP BY appointment_id;


[User] Retrieve all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] Order the output by parking_available ascending.

[Assistant] SELECT * FROM healthcare.billing WHERE timezone LIKE 'A%' ORDER BY parking_available ASC;


[User] Get all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] Return just 25 rows.

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


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

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

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

[Assistant] SELECT operating_hours, address_line2, appointment_id FROM healthcare.billing WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31';

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

[Assistant] SELECT operating_hours, address_line2, appointment_id FROM healthcare.billing WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY timezone DESC;


[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Order the output by appointment_id descending.

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

[User] Show me max of updated_at grouped by timezone for billing.

[Assistant] SELECT timezone, MAX(updated_at) AS max_updated_at FROM healthcare.billing GROUP BY timezone;


[User] What are the updated_at, address_id, parking_available of each billing?

[Assistant] SELECT updated_at, address_id, parking_available FROM healthcare.billing;

[User] Retrieve updated_at, parking_available, media_url, edited_at showing the relationship between billing and appointments.

[Assistant] SELECT updated_at, address_id, parking_available, appointments.media_url, appointments.edited_at FROM healthcare.billing JOIN healthcare.appointments ON billing.appointment_id = appointments.post_id;

[User] Can you order these by address_line2 descending?

[Assistant] SELECT updated_at, address_id, parking_available, appointments.media_url, appointments.edited_at FROM healthcare.billing JOIN healthcare.appointments ON billing.appointment_id = appointments.post_id ORDER BY address_line2 DESC;


[User] List parking_available, address_line2, appointment_id from billing.

[Assistant] SELECT parking_available, address_line2, appointment_id FROM healthcare.billing;

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

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

[User] Only show the top 25 results.

[Assistant] SELECT parking_available, address_line2, appointment_id FROM healthcare.billing WHERE appointment_id LIKE 'A%' LIMIT 25;


[User] Get operating_hours, parking_available, address_id from all billing.

[Assistant] SELECT operating_hours, parking_available, address_id FROM healthcare.billing;

[User] Get timezone, address_id, published_at, tags by joining billing with appointments.

[Assistant] SELECT operating_hours, parking_available, address_id, appointments.published_at, appointments.tags FROM healthcare.billing JOIN healthcare.appointments ON billing.appointment_id = appointments.post_id;

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

[Assistant] SELECT operating_hours, parking_available, address_id, appointments.published_at, appointments.tags FROM healthcare.billing JOIN healthcare.appointments ON billing.appointment_id = appointments.post_id ORDER BY operating_hours DESC;


[User] Get operating_hours, timezone, address_line2 from all billing.

[Assistant] SELECT operating_hours, timezone, address_line2 FROM healthcare.billing;

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

[Assistant] SELECT operating_hours, timezone, address_line2 FROM healthcare.billing ORDER BY updated_at ASC;

[User] Group billing by address_id and show the average of parking_available.

[Assistant] SELECT address_id, AVERAGE(parking_available) AS average_parking_available FROM healthcare.billing GROUP BY address_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.followers (
  id character varying(64) NOT NULL -- unique identifier,
  last_active date,
  email character varying(256) NOT NULL,
  birth_date timestamp NOT NULL,
  username character varying(128),
  bio text,
  is_verified boolean NOT NULL -- indicates if verified is true,
  like_id integer NOT NULL -- reference to likes.id,
  FOREIGN KEY (like_id) REFERENCES likes(id)
)

CREATE TABLE socialmedia.posts (
  post_id integer PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at date,
  author_id text -- identifier for author,
  rating char,
  text varchar
)

CREATE TABLE socialmedia.likes (
  id integer PRIMARY KEY -- unique identifier,
  edited_at date,
  likes varchar,
  thumbnail character varying(256),
  user_id char,
  format varchar,
  views varchar
)

CREATE TABLE socialmedia.events (
  store_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  last_inspected timestamp without time zone,
  address_line1 character varying(128) NOT NULL,
  street varchar,
  latitude char NOT NULL,
  post_id integer -- reference to posts.post_id,
  FOREIGN KEY (post_id) REFERENCES posts(post_id)
)

[User] Show me all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

[User] Show the results sorted by username ascending.

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


[User] Display all events.

[Assistant] SELECT * FROM socialmedia.events;

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

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

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

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


[User] List last_inspected, latitude, post_id from events.

[Assistant] SELECT last_inspected, latitude, post_id FROM socialmedia.events;

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

[Assistant] SELECT last_inspected, latitude, post_id FROM socialmedia.events WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Calculate sum of latitude for each updated_at in events.

[Assistant] SELECT updated_at, SUM(latitude) AS sum_latitude FROM socialmedia.events GROUP BY updated_at;


[User] Display all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Show me events with post_id > 39.

[Assistant] SELECT * FROM socialmedia.events WHERE post_id > 39;

[User] Only show the top 15 results.

[Assistant] SELECT * FROM socialmedia.events WHERE post_id > 39 LIMIT 15;


[User] What are the like_id, bio, is_verified of each follower?

[Assistant] SELECT like_id, bio, is_verified FROM socialmedia.followers;

[User] Sort the results by is_verified ascending.

[Assistant] SELECT like_id, bio, is_verified FROM socialmedia.followers ORDER BY is_verified ASC;

[User] Calculate sum of email for each username in followers.

[Assistant] SELECT username, SUM(email) AS sum_email FROM socialmedia.followers GROUP BY username;


[User] Show me all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

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

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


[User] What are the address_line1, latitude, post_id of each event?

[Assistant] SELECT address_line1, latitude, post_id FROM socialmedia.events;

[User] Can you order these by post_id descending?

[Assistant] SELECT address_line1, latitude, post_id FROM socialmedia.events ORDER BY post_id DESC;

[User] Limit the results to 100 rows.

[Assistant] SELECT address_line1, latitude, post_id FROM socialmedia.events ORDER BY post_id DESC LIMIT 100;


[User] List post_id, address_line1, updated_at from events.

[Assistant] SELECT post_id, address_line1, updated_at FROM socialmedia.events;

[User] Get updated_at, post_id, rating, text by joining events with posts.

[Assistant] SELECT post_id, address_line1, updated_at, posts.rating, posts.text FROM socialmedia.events JOIN socialmedia.posts ON events.post_id = posts.post_id;

[User] Show me the count of events grouped by street.

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


[User] Get bio, username, like_id from all followers.

[Assistant] SELECT bio, username, like_id FROM socialmedia.followers;

[User] Order the output by like_id descending.

[Assistant] SELECT bio, username, like_id FROM socialmedia.followers ORDER BY like_id DESC;

[User] Show only 15 records.

[Assistant] SELECT bio, username, like_id FROM socialmedia.followers ORDER BY like_id DESC LIMIT 15;


[User] What are the updated_at, post_id, address_line1 of each event?

[Assistant] SELECT updated_at, post_id, address_line1 FROM socialmedia.events;

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

[Assistant] SELECT updated_at, post_id, address_line1 FROM socialmedia.events ORDER BY last_inspected DESC;

[User] Tally up events by address_line1.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE travel.reservations (
  order_id integer PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  processed_at timestamp without time zone,
  account_id character varying(256),
  tax decimal NOT NULL,
  user_id character varying(256) -- identifier for user,
  fee character varying(64)
)

CREATE TABLE travel.employees (
  employee_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  is_active boolean NOT NULL -- indicates if active is true,
  membership_level character varying(256),
  phone char,
  gender character varying(128)
)

CREATE TABLE travel.facilities (
  address_id character varying(64) NOT NULL -- unique identifier,
  last_inspected timestamp,
  created_at date,
  postal_code character varying(128),
  street character varying(128),
  location_lat character varying(128) NOT NULL,
  zip_code varchar,
  operating_hours char NOT NULL,
  address_line2 character varying(128),
  reservation_id integer -- reference to reservations.order_id,
  FOREIGN KEY (reservation_id) REFERENCES reservations(order_id)
)

[User] List all facilities.

[Assistant] SELECT * FROM travel.facilities;

[User] List location_lat, address_id, processed_at, account_id for each facilitie along with their reservation information.

[Assistant] SELECT *, reservations.processed_at, reservations.account_id FROM travel.facilities JOIN travel.reservations ON facilities.reservation_id = reservations.order_id;

[User] Restrict the output to 10 items.

[Assistant] SELECT *, reservations.processed_at, reservations.account_id FROM travel.facilities JOIN travel.reservations ON facilities.reservation_id = reservations.order_id LIMIT 10;


[User] Get all facilities.

[Assistant] SELECT * FROM travel.facilities;

[User] What created_at, postal_code, processed_at, user_id do we have for facilities and their associated reservations?

[Assistant] SELECT *, reservations.processed_at, reservations.user_id FROM travel.facilities JOIN travel.reservations ON facilities.reservation_id = reservations.order_id;

[User] Show the results sorted by reservation_id ascending.

[Assistant] SELECT *, reservations.processed_at, reservations.user_id FROM travel.facilities JOIN travel.reservations ON facilities.reservation_id = reservations.order_id ORDER BY reservation_id ASC;


[User] Get all facilities.

[Assistant] SELECT * FROM travel.facilities;

[User] Retrieve location_lat, created_at, tax, fee showing the relationship between facilities and reservations.

[Assistant] SELECT *, reservations.tax, reservations.fee FROM travel.facilities JOIN travel.reservations ON facilities.reservation_id = reservations.order_id;

[User] Calculate count of zip_code for each street in facilities.

[Assistant] SELECT street, COUNT(zip_code) AS count_zip_code FROM travel.facilities GROUP BY street;


[User] List all facilities.

[Assistant] SELECT * FROM travel.facilities;

[User] Get all facilities from last week.

[Assistant] SELECT * FROM travel.facilities WHERE last_inspected >= CURRENT_DATE - INTERVAL '7 days';

[User] Tally up facilities by street.

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


[User] Retrieve all facilities.

[Assistant] SELECT * FROM travel.facilities;

[User] Show the results sorted by zip_code descending.

[Assistant] SELECT * FROM travel.facilities ORDER BY zip_code DESC;

[User] Can you order these by reservation_id ascending?

[Assistant] SELECT * FROM travel.facilities ORDER BY reservation_id ASC;


[User] Retrieve all facilities.

[Assistant] SELECT * FROM travel.facilities;

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

[Assistant] SELECT * FROM travel.facilities WHERE last_inspected <= CURRENT_DATE - INTERVAL '6 months';

[User] Tally up facilities by reservation_id.

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


[User] List street, postal_code, address_id from facilities.

[Assistant] SELECT street, postal_code, address_id FROM travel.facilities;

[User] Find facilities where street LIKE 'A%'.

[Assistant] SELECT street, postal_code, address_id FROM travel.facilities WHERE street LIKE 'A%';

[User] Show me max of created_at grouped by location_lat for facilities.

[Assistant] SELECT location_lat, MAX(created_at) AS max_created_at FROM travel.facilities GROUP BY location_lat;


[User] Get all facilities.

[Assistant] SELECT * FROM travel.facilities;

[User] List created_at, postal_code, processed_at, traded_at for each facilitie along with their reservation information.

[Assistant] SELECT *, reservations.processed_at, reservations.traded_at FROM travel.facilities JOIN travel.reservations ON facilities.reservation_id = reservations.order_id;

[User] Only show the top 15 results.

[Assistant] SELECT *, reservations.processed_at, reservations.traded_at FROM travel.facilities JOIN travel.reservations ON facilities.reservation_id = reservations.order_id LIMIT 15;


[User] Get last_inspected, reservation_id, zip_code from all facilities.

[Assistant] SELECT last_inspected, reservation_id, zip_code FROM travel.facilities;

[User] What address_id, operating_hours, tax, account_id do we have for facilities and their associated reservations?

[Assistant] SELECT last_inspected, reservation_id, zip_code, reservations.tax, reservations.account_id FROM travel.facilities JOIN travel.reservations ON facilities.reservation_id = reservations.order_id;

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

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


[User] Display all facilities.

[Assistant] SELECT * FROM travel.facilities;

[User] Show me facilities with last_inspected > '2023-01-01'.

[Assistant] SELECT * FROM travel.facilities WHERE last_inspected > '2023-01-01';

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

[Assistant] SELECT * FROM travel.facilities WHERE last_inspected > '2023-01-01' 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.reservations (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  cancelled_at timestamp,
  buyer_id varchar,
  approval_status varchar,
  fee varchar,
  user_id char -- identifier for user,
  conten_id text -- reference to content.id,
  FOREIGN KEY (conten_id) REFERENCES content(id)
)

CREATE TABLE music.content (
  id text PRIMARY KEY -- unique identifier,
  edited_at date,
  attachment_url character varying(256),
  categories char NOT NULL,
  shares character varying(256),
  text text,
  keywords character varying(128),
  reservation_id text NOT NULL -- reference to reservations.invoice_id,
  FOREIGN KEY (reservation_id) REFERENCES reservations(invoice_id)
)

CREATE TABLE music.users (
  employee_id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  updated_at timestamp,
  api_key varchar,
  last_login timestamp,
  last_name character varying(128) NOT NULL,
  email varchar,
  timezone char
)

[User] Retrieve all content.

[Assistant] SELECT * FROM music.content;

[User] List text, attachment_url, user_id, fee for each content along with their reservation information.

[Assistant] SELECT *, reservations.user_id, reservations.fee FROM music.content JOIN music.reservations ON content.reservation_id = reservations.invoice_id;

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

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


[User] Show me all reservations.

[Assistant] SELECT * FROM music.reservations;

[User] Can you order these by buyer_id ascending?

[Assistant] SELECT * FROM music.reservations ORDER BY buyer_id ASC;

[User] Return just 5 rows.

[Assistant] SELECT * FROM music.reservations ORDER BY buyer_id ASC LIMIT 5;


[User] Show me all content.

[Assistant] SELECT * FROM music.content;

[User] Show me content with edited_at > '2023-01-01'.

[Assistant] SELECT * FROM music.content WHERE edited_at > '2023-01-01';

[User] Get the distribution of content across different text values.

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


[User] Retrieve all content.

[Assistant] SELECT * FROM music.content;

[User] Get attachment_url, categories, approval_status, created_at by joining content with reservations.

[Assistant] SELECT *, reservations.approval_status, reservations.created_at FROM music.content JOIN music.reservations ON content.reservation_id = reservations.invoice_id;

[User] Show the results sorted by text descending.

[Assistant] SELECT *, reservations.approval_status, reservations.created_at FROM music.content JOIN music.reservations ON content.reservation_id = reservations.invoice_id ORDER BY text DESC;


[User] Get shares, categories, reservation_id from all content.

[Assistant] SELECT shares, categories, reservation_id FROM music.content;

[User] Get reservation_id, edited_at, cancelled_at, fee by joining content with reservations.

[Assistant] SELECT shares, categories, reservation_id, reservations.cancelled_at, reservations.fee FROM music.content JOIN music.reservations ON content.reservation_id = reservations.invoice_id;

[User] Show me min of categories grouped by attachment_url for content.

[Assistant] SELECT attachment_url, MIN(categories) AS min_categories FROM music.content GROUP BY attachment_url;


[User] What are the conten_id, buyer_id, user_id of each reservation?

[Assistant] SELECT conten_id, buyer_id, user_id FROM music.reservations;

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

[Assistant] SELECT conten_id, buyer_id, user_id FROM music.reservations WHERE created_at > '2023-12-01';

[User] Show the results sorted by user_id descending.

[Assistant] SELECT conten_id, buyer_id, user_id FROM music.reservations WHERE created_at > '2023-12-01' ORDER BY user_id DESC;


[User] Retrieve cancelled_at, created_at, approval_status for every reservation.

[Assistant] SELECT cancelled_at, created_at, approval_status FROM music.reservations;

[User] Sort the results by user_id descending.

[Assistant] SELECT cancelled_at, created_at, approval_status FROM music.reservations ORDER BY user_id DESC;

[User] Calculate average of buyer_id for each buyer_id in reservations.

[Assistant] SELECT buyer_id, AVERAGE(buyer_id) AS average_buyer_id FROM music.reservations GROUP BY buyer_id;


[User] Retrieve shares, edited_at, attachment_url for every content.

[Assistant] SELECT shares, edited_at, attachment_url FROM music.content;

[User] Show the results sorted by attachment_url ascending.

[Assistant] SELECT shares, edited_at, attachment_url FROM music.content ORDER BY attachment_url ASC;

[User] Show the results sorted by attachment_url ascending.

[Assistant] SELECT shares, edited_at, attachment_url FROM music.content ORDER BY attachment_url ASC;


[User] What are the cancelled_at, fee, approval_status of each reservation?

[Assistant] SELECT cancelled_at, fee, approval_status FROM music.reservations;

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

[Assistant] SELECT cancelled_at, fee, approval_status FROM music.reservations WHERE buyer_id LIKE 'A%';

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

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


[User] Retrieve all content.

[Assistant] SELECT * FROM music.content;

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

[Assistant] SELECT * FROM music.content ORDER BY attachment_url DESC;

[User] Tally up content by edited_at.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.courses (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  processed_at timestamp,
  updated_at timestamp without time zone,
  payer_id character varying(64) -- identifier for payer,
  credit character varying(256),
  category character varying(64)
)

CREATE TABLE education.grades (
  id text PRIMARY KEY -- unique identifier,
  expires_at date,
  tax_rate character varying(128),
  available char NOT NULL,
  brand character varying(256)
)

CREATE TABLE education.teachers (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  traded_at timestamp without time zone,
  tax numeric,
  payment_method char,
  product_id text NOT NULL,
  grade_id text -- reference to grades.id,
  FOREIGN KEY (grade_id) REFERENCES grades(id)
)

[User] List traded_at, tax, payment_method from teachers.

[Assistant] SELECT traded_at, tax, payment_method FROM education.teachers;

[User] Get teachers that match product_id LIKE 'A%'.

[Assistant] SELECT traded_at, tax, payment_method FROM education.teachers WHERE product_id LIKE 'A%';

[User] Show the results sorted by grade_id ascending.

[Assistant] SELECT traded_at, tax, payment_method FROM education.teachers WHERE product_id LIKE 'A%' ORDER BY grade_id ASC;


[User] Retrieve all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

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

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


[User] What are the payment_method, traded_at, transaction_id of each teacher?

[Assistant] SELECT payment_method, traded_at, transaction_id FROM education.teachers;

[User] List product_id, transaction_id, brand, expires_at for each teacher along with their grade information.

[Assistant] SELECT payment_method, traded_at, transaction_id, grades.brand, grades.expires_at FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.id;

[User] Show only 20 records.

[Assistant] SELECT payment_method, traded_at, transaction_id, grades.brand, grades.expires_at FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.id LIMIT 20;


[User] Retrieve payment_method, traded_at, grade_id for every teacher.

[Assistant] SELECT payment_method, traded_at, grade_id FROM education.teachers;

[User] Get teachers that match transaction_id LIKE 'A%'.

[Assistant] SELECT payment_method, traded_at, grade_id FROM education.teachers WHERE transaction_id LIKE 'A%';

[User] Show the results sorted by traded_at ascending.

[Assistant] SELECT payment_method, traded_at, grade_id FROM education.teachers WHERE transaction_id LIKE 'A%' ORDER BY traded_at ASC;


[User] Retrieve grade_id, transaction_id, payment_method for every teacher.

[Assistant] SELECT grade_id, transaction_id, payment_method FROM education.teachers;

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

[Assistant] SELECT grade_id, transaction_id, payment_method FROM education.teachers WHERE traded_at > '2023-12-01';

[User] What is the min product_id for each transaction_id in teachers?

[Assistant] SELECT transaction_id, MIN(product_id) AS min_product_id FROM education.teachers GROUP BY transaction_id;


[User] Get payment_method, tax, grade_id from all teachers.

[Assistant] SELECT payment_method, tax, grade_id FROM education.teachers;

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

[Assistant] SELECT payment_method, tax, grade_id FROM education.teachers WHERE traded_at > '2023-12-01';

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

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


[User] Display all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

[User] Only show the top 25 results.

[Assistant] SELECT * FROM education.teachers WHERE traded_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 25;


[User] Show me payment_method, product_id, grade_id for all teachers.

[Assistant] SELECT payment_method, product_id, grade_id FROM education.teachers;

[User] List tax, payment_method, tax_rate, brand for each teacher along with their grade information.

[Assistant] SELECT payment_method, product_id, grade_id, grades.tax_rate, grades.brand FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.id;

[User] Show the results sorted by grade_id ascending.

[Assistant] SELECT payment_method, product_id, grade_id, grades.tax_rate, grades.brand FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.id ORDER BY grade_id ASC;


[User] Get all teachers.

[Assistant] SELECT * FROM education.teachers;

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

[Assistant] SELECT * FROM education.teachers ORDER BY traded_at DESC;

[User] Return just 25 rows.

[Assistant] SELECT * FROM education.teachers ORDER BY traded_at DESC LIMIT 25;


[User] What are the traded_at, product_id, grade_id of each teacher?

[Assistant] SELECT traded_at, product_id, grade_id FROM education.teachers;

[User] Retrieve transaction_id, product_id, tax_rate, brand showing the relationship between teachers and grades.

[Assistant] SELECT traded_at, product_id, grade_id, grades.tax_rate, grades.brand FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.id;

[User] Get average of product_id by transaction_id from teachers.

[Assistant] SELECT transaction_id, AVERAGE(product_id) AS average_product_id FROM education.teachers GROUP BY transaction_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 e-commerce.orders (
  id varchar PRIMARY KEY -- unique identifier,
  traded_at date,
  exchange_rate character varying(64) NOT NULL,
  customer_id character varying(64) -- identifier for customer,
  card_type varchar,
  total integer NOT NULL,
  payment_method character varying(128),
  subtotal numeric,
  order_item_id integer -- reference to order_items.store_id,
  FOREIGN KEY (order_item_id) REFERENCES order_items(store_id)
)

CREATE TABLE e-commerce.order_items (
  store_id integer PRIMARY KEY -- unique identifier,
  last_inspected date,
  updated_at date,
  parking_available character varying(128),
  capacity varchar,
  name character varying(256),
  timezone character varying(128) NOT NULL
)

[User] Retrieve all orders.

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

[User] Sort the results by payment_method ascending.

[Assistant] SELECT * FROM e-commerce.orders ORDER BY payment_method ASC;

[User] Limit the results to 10 rows.

[Assistant] SELECT * FROM e-commerce.orders ORDER BY payment_method ASC LIMIT 10;


[User] List all orders.

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

[User] Order the output by traded_at descending.

[Assistant] SELECT * FROM e-commerce.orders ORDER BY traded_at DESC;

[User] Return just 15 rows.

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


[User] Display all orders.

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

[User] Get orders that match traded_at > '2023-01-01'.

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

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

[Assistant] SELECT * FROM e-commerce.orders WHERE traded_at > '2023-01-01' ORDER BY order_item_id ASC;


[User] Get order_item_id, total, subtotal from all orders.

[Assistant] SELECT order_item_id, total, subtotal FROM e-commerce.orders;

[User] Sort the results by order_item_id descending.

[Assistant] SELECT order_item_id, total, subtotal FROM e-commerce.orders ORDER BY order_item_id DESC;

[User] How many orders are there per subtotal?

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


[User] List payment_method, customer_id, exchange_rate from orders.

[Assistant] SELECT payment_method, customer_id, exchange_rate FROM e-commerce.orders;

[User] Find orders from 2023.

[Assistant] SELECT payment_method, customer_id, exchange_rate FROM e-commerce.orders WHERE traded_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Calculate count of exchange_rate for each payment_method in orders.

[Assistant] SELECT payment_method, COUNT(exchange_rate) AS count_exchange_rate FROM e-commerce.orders GROUP BY payment_method;


[User] Show me all orders.

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

[User] Retrieve order_item_id, customer_id, timezone, capacity showing the relationship between orders and order_items.

[Assistant] SELECT *, order_items.timezone, order_items.capacity FROM e-commerce.orders JOIN e-commerce.order_items ON orders.order_item_id = order_items.store_id;

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

[Assistant] SELECT *, order_items.timezone, order_items.capacity FROM e-commerce.orders JOIN e-commerce.order_items ON orders.order_item_id = order_items.store_id ORDER BY traded_at DESC;


[User] What are the exchange_rate, card_type, order_item_id of each order?

[Assistant] SELECT exchange_rate, card_type, order_item_id FROM e-commerce.orders;

[User] Get total, traded_at, last_inspected, name by joining orders with order_items.

[Assistant] SELECT exchange_rate, card_type, order_item_id, order_items.last_inspected, order_items.name FROM e-commerce.orders JOIN e-commerce.order_items ON orders.order_item_id = order_items.store_id;

[User] Only show the top 20 results.

[Assistant] SELECT exchange_rate, card_type, order_item_id, order_items.last_inspected, order_items.name FROM e-commerce.orders JOIN e-commerce.order_items ON orders.order_item_id = order_items.store_id LIMIT 20;


[User] Retrieve all orders.

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

[User] Get payment_method, traded_at, updated_at, capacity by joining orders with order_items.

[Assistant] SELECT *, order_items.updated_at, order_items.capacity FROM e-commerce.orders JOIN e-commerce.order_items ON orders.order_item_id = order_items.store_id;

[User] Show only 25 records.

[Assistant] SELECT *, order_items.updated_at, order_items.capacity FROM e-commerce.orders JOIN e-commerce.order_items ON orders.order_item_id = order_items.store_id LIMIT 25;


[User] Retrieve order_item_id, payment_method, card_type for every order.

[Assistant] SELECT order_item_id, payment_method, card_type FROM e-commerce.orders;

[User] Show me customer_id, subtotal, parking_available, updated_at from orders and their related order_items.

[Assistant] SELECT order_item_id, payment_method, card_type, order_items.parking_available, order_items.updated_at FROM e-commerce.orders JOIN e-commerce.order_items ON orders.order_item_id = order_items.store_id;

[User] Order the output by total ascending.

[Assistant] SELECT order_item_id, payment_method, card_type, order_items.parking_available, order_items.updated_at FROM e-commerce.orders JOIN e-commerce.order_items ON orders.order_item_id = order_items.store_id ORDER BY total ASC;


[User] Show me all orders.

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

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

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

[User] Tally up orders by card_type.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE government.customers (
  id text PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  gender char,
  profile_picture_url char NOT NULL,
  timezone character varying(128) NOT NULL,
  status char,
  is_active bit NOT NULL -- indicates if active is true,
  last_name character varying(128),
  good_id text -- reference to goods.id,
  FOREIGN KEY (good_id) REFERENCES goods(id)
)

CREATE TABLE government.goods (
  id text PRIMARY KEY -- unique identifier,
  published_at timestamp,
  expires_at timestamp,
  title character varying(64) NOT NULL,
  cost numeric,
  description character varying(128),
  price smallint,
  customer_id text NOT NULL -- reference to customers.id,
  FOREIGN KEY (customer_id) REFERENCES customers(id)
)

[User] Get all goods.

[Assistant] SELECT * FROM government.goods;

[User] Can you order these by cost descending?

[Assistant] SELECT * FROM government.goods ORDER BY cost DESC;

[User] Order the output by cost ascending.

[Assistant] SELECT * FROM government.goods ORDER BY cost ASC;


[User] What are the is_active, good_id, profile_picture_url of each customer?

[Assistant] SELECT is_active, good_id, profile_picture_url FROM government.customers;

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

[Assistant] SELECT is_active, good_id, profile_picture_url FROM government.customers ORDER BY joined_at DESC;

[User] Sort the results by timezone descending.

[Assistant] SELECT is_active, good_id, profile_picture_url FROM government.customers ORDER BY timezone DESC;


[User] List all goods.

[Assistant] SELECT * FROM government.goods;

[User] List goods that have expires_at > '2023-01-01'.

[Assistant] SELECT * FROM government.goods WHERE expires_at > '2023-01-01';

[User] Return just 50 rows.

[Assistant] SELECT * FROM government.goods WHERE expires_at > '2023-01-01' LIMIT 50;


[User] Display all customers.

[Assistant] SELECT * FROM government.customers;

[User] List customers that have good_id LIKE 'A%'.

[Assistant] SELECT * FROM government.customers WHERE good_id LIKE 'A%';

[User] Show me average of timezone grouped by gender for customers.

[Assistant] SELECT gender, AVERAGE(timezone) AS average_timezone FROM government.customers GROUP BY gender;


[User] List timezone, is_active, good_id from customers.

[Assistant] SELECT timezone, is_active, good_id FROM government.customers;

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

[Assistant] SELECT timezone, is_active, good_id FROM government.customers WHERE joined_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Can you order these by profile_picture_url descending?

[Assistant] SELECT timezone, is_active, good_id FROM government.customers WHERE joined_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY profile_picture_url DESC;


[User] What are the cost, title, published_at of each good?

[Assistant] SELECT cost, title, published_at FROM government.goods;

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

[Assistant] SELECT cost, title, published_at FROM government.goods WHERE expires_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Show me the count of goods grouped by price.

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


[User] Get published_at, expires_at, price from all goods.

[Assistant] SELECT published_at, expires_at, price FROM government.goods;

[User] Show the results sorted by cost ascending.

[Assistant] SELECT published_at, expires_at, price FROM government.goods ORDER BY cost ASC;

[User] Get the distribution of goods across different customer_id values.

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


[User] List all goods.

[Assistant] SELECT * FROM government.goods;

[User] Sort the results by description ascending.

[Assistant] SELECT * FROM government.goods ORDER BY description ASC;

[User] Show only 15 records.

[Assistant] SELECT * FROM government.goods ORDER BY description ASC LIMIT 15;


[User] Get customer_id, expires_at, description from all goods.

[Assistant] SELECT customer_id, expires_at, description FROM government.goods;

[User] Retrieve title, cost, profile_picture_url, status showing the relationship between goods and customers.

[Assistant] SELECT customer_id, expires_at, description, customers.profile_picture_url, customers.status FROM government.goods JOIN government.customers ON goods.customer_id = customers.id;

[User] Get the distribution of goods across different expires_at values.

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


[User] Display all goods.

[Assistant] SELECT * FROM government.goods;

[User] Show me goods with cost > 35.

[Assistant] SELECT * FROM government.goods WHERE cost > 35;

[User] How many goods are there per title?

[Assistant] SELECT title, COUNT(*) AS count FROM government.goods GROUP BY title 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 finance.customers (
  employee_id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  updated_at timestamp,
  nationality character varying(256),
  email character varying(128),
  membership_level character varying(128) NOT NULL,
  is_active bit -- indicates if active is true,
  last_login timestamp NOT NULL,
  phone char,
  password_hash character varying(128)
)

CREATE TABLE finance.loans (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  processed_at date,
  status varchar,
  customer_id character varying(128) NOT NULL -- identifier for customer,
  approval_status char,
  amount numeric(38,14),
  vendor_id character varying(64),
  reconciliation_status varchar
)

[User] Display all loans.

[Assistant] SELECT * FROM finance.loans;

[User] List loans that have approval_status LIKE 'A%'.

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

[User] Limit the results to 15 rows.

[Assistant] SELECT * FROM finance.loans WHERE approval_status LIKE 'A%' LIMIT 15;


[User] What are the reconciliation_status, amount, customer_id of each loan?

[Assistant] SELECT reconciliation_status, amount, customer_id FROM finance.loans;

[User] Show me loans with amount > 66.

[Assistant] SELECT reconciliation_status, amount, customer_id FROM finance.loans WHERE amount > 66;

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

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


[User] Show me all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Calculate max of email for each last_login in customers.

[Assistant] SELECT last_login, MAX(email) AS max_email FROM finance.customers GROUP BY last_login;


[User] Retrieve approval_status, processed_at, reconciliation_status for every loan.

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

[User] Get loans that match amount > 63.

[Assistant] SELECT approval_status, processed_at, reconciliation_status FROM finance.loans WHERE amount > 63;

[User] Limit the results to 100 rows.

[Assistant] SELECT approval_status, processed_at, reconciliation_status FROM finance.loans WHERE amount > 63 LIMIT 100;


[User] Retrieve all loans.

[Assistant] SELECT * FROM finance.loans;

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

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

[User] Only show the top 50 results.

[Assistant] SELECT * FROM finance.loans WHERE processed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 50;


[User] Show me all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Get loans that match vendor_id LIKE 'A%'.

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

[User] Sort the results by customer_id ascending.

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


[User] List updated_at, last_login, is_active from customers.

[Assistant] SELECT updated_at, last_login, is_active FROM finance.customers;

[User] Show me customers with phone LIKE 'A%'.

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

[User] What is the max joined_at for each password_hash in customers?

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


[User] Retrieve all loans.

[Assistant] SELECT * FROM finance.loans;

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

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

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

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


[User] Show me status, reconciliation_status, processed_at for all loans.

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

[User] Find loans where vendor_id LIKE 'A%'.

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

[User] What is the max vendor_id for each processed_at in loans?

[Assistant] SELECT processed_at, MAX(vendor_id) AS max_vendor_id FROM finance.loans GROUP BY processed_at;


[User] List joined_at, is_active, nationality from customers.

[Assistant] SELECT joined_at, is_active, nationality FROM finance.customers;

[User] Find customers from last week.

[Assistant] SELECT joined_at, is_active, nationality FROM finance.customers WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Can you order these by password_hash descending?

[Assistant] SELECT joined_at, is_active, nationality FROM finance.customers WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY password_hash 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 restaurant.transactions (
  invoice_id integer PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  updated_at timestamp without time zone,
  price numeric(38,14),
  buyer_id char -- identifier for buyer,
  approval_status character varying(128),
  status varchar,
  user_id character varying(64),
  article_id integer -- reference to articles.message_id,
  merchandis_id text -- reference to merchandise.id,
  FOREIGN KEY (article_id) REFERENCES articles(message_id),
  FOREIGN KEY (merchandis_id) REFERENCES merchandise(id)
)

CREATE TABLE restaurant.articles (
  message_id integer PRIMARY KEY -- unique identifier,
  published_at date,
  edited_at timestamp,
  image_url text NOT NULL,
  body character varying(64),
  shares varchar,
  merchandis_id text -- reference to merchandise.id,
  FOREIGN KEY (merchandis_id) REFERENCES merchandise(id)
)

CREATE TABLE restaurant.merchandise (
  id varchar PRIMARY KEY -- unique identifier,
  expires_at timestamp without time zone,
  published_at timestamp without time zone,
  tax_rate character varying(64),
  rating varchar,
  media_url text,
  popularity_score character varying(128),
  article_id integer -- reference to articles.message_id,
  transaction_id integer -- reference to transactions.invoice_id,
  FOREIGN KEY (article_id) REFERENCES articles(message_id),
  FOREIGN KEY (transaction_id) REFERENCES transactions(invoice_id)
)

[User] Retrieve all transactions.

[Assistant] SELECT * FROM restaurant.transactions;

[User] Get all transactions older than 6 months.

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

[User] Show me sum of price grouped by status for transactions.

[Assistant] SELECT status, SUM(price) AS sum_price FROM restaurant.transactions GROUP BY status;


[User] Retrieve all transactions.

[Assistant] SELECT * FROM restaurant.transactions;

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

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

[User] Return just 50 rows.

[Assistant] SELECT * FROM restaurant.transactions WHERE updated_at > '2023-12-01' LIMIT 50;


[User] Show me all articles.

[Assistant] SELECT * FROM restaurant.articles;

[User] List articles that have shares LIKE 'A%'.

[Assistant] SELECT * FROM restaurant.articles WHERE shares LIKE 'A%';

[User] Restrict the output to 15 items.

[Assistant] SELECT * FROM restaurant.articles WHERE shares LIKE 'A%' LIMIT 15;


[User] List all transactions.

[Assistant] SELECT * FROM restaurant.transactions;

[User] Retrieve transactions where buyer_id LIKE 'A%'.

[Assistant] SELECT * FROM restaurant.transactions WHERE buyer_id LIKE 'A%';

[User] Order the output by status ascending.

[Assistant] SELECT * FROM restaurant.transactions WHERE buyer_id LIKE 'A%' ORDER BY status ASC;


[User] Show me all articles.

[Assistant] SELECT * FROM restaurant.articles;

[User] Sort the results by body descending.

[Assistant] SELECT * FROM restaurant.articles ORDER BY body DESC;

[User] Limit the results to 5 rows.

[Assistant] SELECT * FROM restaurant.articles ORDER BY body DESC LIMIT 5;


[User] Show me all articles.

[Assistant] SELECT * FROM restaurant.articles;

[User] Get all articles from 2023.

[Assistant] SELECT * FROM restaurant.articles WHERE edited_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Order the output by published_at descending.

[Assistant] SELECT * FROM restaurant.articles WHERE edited_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY published_at DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.customers (
  id character varying(64) NOT NULL -- unique identifier,
  last_active date,
  joined_at timestamp without time zone,
  city char,
  salt character varying(256) NOT NULL,
  last_name character varying(64) NOT NULL,
  website varchar,
  full_name text NOT NULL,
  display_name text,
  loan_id text NOT NULL -- reference to loans.content_id,
  FOREIGN KEY (loan_id) REFERENCES loans(content_id)
)

CREATE TABLE finance.loans (
  content_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at date,
  views character varying(64) NOT NULL,
  parent_id character varying(256) -- identifier for parent,
  title character varying(64) NOT NULL
)

[User] Show me all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

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

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


[User] What are the website, city, full_name of each customer?

[Assistant] SELECT website, city, full_name FROM finance.customers;

[User] Show me joined_at, city, updated_at, parent_id from customers and their related loans.

[Assistant] SELECT website, city, full_name, loans.updated_at, loans.parent_id FROM finance.customers JOIN finance.loans ON customers.loan_id = loans.content_id;

[User] Tally up customers by id.

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


[User] What are the city, website, full_name of each customer?

[Assistant] SELECT city, website, full_name FROM finance.customers;

[User] Order the output by display_name ascending.

[Assistant] SELECT city, website, full_name FROM finance.customers ORDER BY display_name ASC;

[User] Tally up customers by salt.

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


[User] Retrieve joined_at, last_name, last_active for every customer.

[Assistant] SELECT joined_at, last_name, last_active FROM finance.customers;

[User] Order the output by salt ascending.

[Assistant] SELECT joined_at, last_name, last_active FROM finance.customers ORDER BY salt ASC;

[User] Tally up customers by city.

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


[User] Retrieve website, salt, last_name for every customer.

[Assistant] SELECT website, salt, last_name FROM finance.customers;

[User] Order the output by display_name ascending.

[Assistant] SELECT website, salt, last_name FROM finance.customers ORDER BY display_name ASC;

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

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


[User] Retrieve id, last_name, joined_at for every customer.

[Assistant] SELECT id, last_name, joined_at FROM finance.customers;

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

[Assistant] SELECT id, last_name, joined_at FROM finance.customers WHERE loan_id LIKE 'A%';

[User] Return just 100 rows.

[Assistant] SELECT id, last_name, joined_at FROM finance.customers WHERE loan_id LIKE 'A%' LIMIT 100;


[User] Retrieve all customers.

[Assistant] SELECT * FROM finance.customers;

[User] List last_name, display_name, views, parent_id for each customer along with their loan information.

[Assistant] SELECT *, loans.views, loans.parent_id FROM finance.customers JOIN finance.loans ON customers.loan_id = loans.content_id;

[User] How many customers are there per joined_at?

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


[User] What are the joined_at, city, id of each customer?

[Assistant] SELECT joined_at, city, id FROM finance.customers;

[User] List customers that have display_name LIKE 'A%'.

[Assistant] SELECT joined_at, city, id FROM finance.customers WHERE display_name LIKE 'A%';

[User] Can you order these by id ascending?

[Assistant] SELECT joined_at, city, id FROM finance.customers WHERE display_name LIKE 'A%' ORDER BY id ASC;


[User] What are the website, salt, city of each customer?

[Assistant] SELECT website, salt, city FROM finance.customers;

[User] Retrieve customers where last_active > '2023-01-01'.

[Assistant] SELECT website, salt, city FROM finance.customers WHERE last_active > '2023-01-01';

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

[Assistant] SELECT loan_id, SUM(loan_id) AS sum_loan_id FROM finance.customers GROUP BY loan_id;


[User] Retrieve id, display_name, salt for every customer.

[Assistant] SELECT id, display_name, salt FROM finance.customers;

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

[Assistant] SELECT id, display_name, salt FROM finance.customers ORDER BY display_name ASC;

[User] How many customers are there per last_name?

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.products (
  item_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp,
  name char,
  media_url text,
  stock_level varchar NOT NULL,
  order_id integer -- reference to orders.invoice_id,
  FOREIGN KEY (order_id) REFERENCES orders(invoice_id)
)

CREATE TABLE e-commerce.orders (
  invoice_id integer PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  exchange_rate character varying(128),
  delivery_status text,
  discount decimal,
  subtotal numeric,
  approval_status character varying(128),
  status varchar NOT NULL
)

[User] Get all products.

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

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

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

[User] Limit the results to 20 rows.

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


[User] List name, item_id, order_id from products.

[Assistant] SELECT name, item_id, order_id FROM e-commerce.products;

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

[Assistant] SELECT name, item_id, order_id FROM e-commerce.products WHERE media_url LIKE 'A%';

[User] Return just 10 rows.

[Assistant] SELECT name, item_id, order_id FROM e-commerce.products WHERE media_url LIKE 'A%' LIMIT 10;


[User] Get all products.

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

[User] Find products from last week.

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

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

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


[User] What are the order_id, media_url, stock_level of each product?

[Assistant] SELECT order_id, media_url, stock_level FROM e-commerce.products;

[User] Get all products between January and March.

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

[User] Group products by published_at and show the count of item_id.

[Assistant] SELECT published_at, COUNT(item_id) AS count_item_id FROM e-commerce.products GROUP BY published_at;


[User] Retrieve all products.

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

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

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

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

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


[User] Get all products.

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

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

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

[User] What is the average item_id for each published_at in products?

[Assistant] SELECT published_at, AVERAGE(item_id) AS average_item_id FROM e-commerce.products GROUP BY published_at;


[User] Show me order_id, name, stock_level for all products.

[Assistant] SELECT order_id, name, stock_level FROM e-commerce.products;

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

[Assistant] SELECT order_id, name, stock_level FROM e-commerce.products WHERE item_id LIKE 'A%';

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

[Assistant] SELECT media_url, MAX(published_at) AS max_published_at FROM e-commerce.products GROUP BY media_url;


[User] Get all products.

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

[User] Show me item_id, name, processed_at, subtotal from products and their related orders.

[Assistant] SELECT *, orders.processed_at, orders.subtotal FROM e-commerce.products JOIN e-commerce.orders ON products.order_id = orders.invoice_id;

[User] Group products by media_url and show the sum of stock_level.

[Assistant] SELECT media_url, SUM(stock_level) AS sum_stock_level FROM e-commerce.products GROUP BY media_url;


[User] Get order_id, name, media_url from all products.

[Assistant] SELECT order_id, name, media_url FROM e-commerce.products;

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

[Assistant] SELECT order_id, name, media_url FROM e-commerce.products WHERE published_at <= CURRENT_DATE - INTERVAL '6 months';

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

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


[User] Display all products.

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

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

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

[User] Order the output by name ascending.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.patients (
  customer_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  status character varying(128) NOT NULL,
  first_name text,
  birth_date date NOT NULL,
  bio text NOT NULL,
  salt char NOT NULL,
  city character varying(256) NOT NULL,
  website char,
  doctor_id text NOT NULL -- reference to doctors.id,
  FOREIGN KEY (doctor_id) REFERENCES doctors(id)
)

CREATE TABLE healthcare.doctors (
  id varchar PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  quantity char NOT NULL,
  currency character varying(256),
  amount smallint,
  prescription_id integer NOT NULL -- reference to prescriptions.transaction_id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(transaction_id)
)

CREATE TABLE healthcare.prescriptions (
  transaction_id integer PRIMARY KEY -- unique identifier,
  payment_date date,
  due_date date,
  verification_status character varying(128),
  payer_id text,
  approval_status character varying(128),
  invoice_number character varying(256),
  balance bigint,
  patient_id text -- reference to patients.customer_id,
  FOREIGN KEY (patient_id) REFERENCES patients(customer_id)
)

[User] Retrieve first_name, doctor_id, birth_date for every patient.

[Assistant] SELECT first_name, doctor_id, birth_date FROM healthcare.patients;

[User] Get city, salt, quantity, amount by joining patients with doctors.

[Assistant] SELECT first_name, doctor_id, birth_date, doctors.quantity, doctors.amount FROM healthcare.patients JOIN healthcare.doctors ON patients.doctor_id = doctors.id;

[User] Count the number of patients in each city category.

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


[User] Show me prescription_id, currency, amount for all doctors.

[Assistant] SELECT prescription_id, currency, amount FROM healthcare.doctors;

[User] Retrieve doctors where prescription_id > 1.

[Assistant] SELECT prescription_id, currency, amount FROM healthcare.doctors WHERE prescription_id > 1;

[User] Limit the results to 50 rows.

[Assistant] SELECT prescription_id, currency, amount FROM healthcare.doctors WHERE prescription_id > 1 LIMIT 50;


[User] List cancelled_at, quantity, currency from doctors.

[Assistant] SELECT cancelled_at, quantity, currency FROM healthcare.doctors;

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

[Assistant] SELECT cancelled_at, quantity, currency FROM healthcare.doctors WHERE cancelled_at > '2023-12-01';

[User] Can you order these by cancelled_at descending?

[Assistant] SELECT cancelled_at, quantity, currency FROM healthcare.doctors WHERE cancelled_at > '2023-12-01' ORDER BY cancelled_at DESC;


[User] Get last_active, first_name, doctor_id from all patients.

[Assistant] SELECT last_active, first_name, doctor_id FROM healthcare.patients;

[User] Order the output by doctor_id descending.

[Assistant] SELECT last_active, first_name, doctor_id FROM healthcare.patients ORDER BY doctor_id DESC;

[User] Get sum of bio by bio from patients.

[Assistant] SELECT bio, SUM(bio) AS sum_bio FROM healthcare.patients GROUP BY bio;


[User] Show me all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Sort the results by prescription_id ascending.

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

[User] Restrict the output to 15 items.

[Assistant] SELECT * FROM healthcare.doctors ORDER BY prescription_id ASC LIMIT 15;


[User] Retrieve all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Retrieve bio, doctor_id, cancelled_at, quantity showing the relationship between patients and doctors.

[Assistant] SELECT *, doctors.cancelled_at, doctors.quantity FROM healthcare.patients JOIN healthcare.doctors ON patients.doctor_id = doctors.id;

[User] Group patients by last_active and show the min of bio.

[Assistant] SELECT last_active, MIN(bio) AS min_bio FROM healthcare.patients GROUP BY last_active;


[User] Get invoice_number, payment_date, patient_id from all prescriptions.

[Assistant] SELECT invoice_number, payment_date, patient_id FROM healthcare.prescriptions;

[User] Show me prescriptions that were created yesterday.

[Assistant] SELECT invoice_number, payment_date, patient_id FROM healthcare.prescriptions WHERE due_date = CURRENT_DATE - INTERVAL '1 day';

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

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


[User] What are the status, salt, website of each patient?

[Assistant] SELECT status, salt, website FROM healthcare.patients;

[User] Get patients that match bio LIKE 'A%'.

[Assistant] SELECT status, salt, website FROM healthcare.patients WHERE bio LIKE 'A%';

[User] Show only 50 records.

[Assistant] SELECT status, salt, website FROM healthcare.patients WHERE bio LIKE 'A%' LIMIT 50;


[User] Get salt, first_name, bio from all patients.

[Assistant] SELECT salt, first_name, bio FROM healthcare.patients;

[User] Order the output by salt ascending.

[Assistant] SELECT salt, first_name, bio FROM healthcare.patients ORDER BY salt ASC;

[User] Order the output by status descending.

[Assistant] SELECT salt, first_name, bio FROM healthcare.patients ORDER BY status DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE manufacturing.messages (
  message_id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp without time zone,
  tags character varying(64),
  views varchar,
  description varchar NOT NULL,
  merchandis_id integer -- reference to merchandise.product_id,
  FOREIGN KEY (merchandis_id) REFERENCES merchandise(product_id)
)

CREATE TABLE manufacturing.merchandise (
  product_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  views character varying(256) NOT NULL,
  featured_rank character varying(128),
  video_url character varying(256),
  thumbnail_url text,
  subcategory character varying(256) NOT NULL,
  reserved char,
  media_url character varying(256) NOT NULL,
  message_id integer -- reference to messages.message_id,
  FOREIGN KEY (message_id) REFERENCES messages(message_id)
)

[User] Get all merchandise.

[Assistant] SELECT * FROM manufacturing.merchandise;

[User] Get merchandise that match media_url LIKE 'A%'.

[Assistant] SELECT * FROM manufacturing.merchandise WHERE media_url LIKE 'A%';

[User] Limit the results to 10 rows.

[Assistant] SELECT * FROM manufacturing.merchandise WHERE media_url LIKE 'A%' LIMIT 10;


[User] Show me all messages.

[Assistant] SELECT * FROM manufacturing.messages;

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

[Assistant] SELECT * FROM manufacturing.messages WHERE edited_at >= CURRENT_DATE - INTERVAL '7 days';

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

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


[User] Get all messages.

[Assistant] SELECT * FROM manufacturing.messages;

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

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

[User] Get count of merchandis_id by description from messages.

[Assistant] SELECT description, COUNT(merchandis_id) AS count_merchandis_id FROM manufacturing.messages GROUP BY description;


[User] Retrieve thumbnail_url, message_id, featured_rank for every merchandise.

[Assistant] SELECT thumbnail_url, message_id, featured_rank FROM manufacturing.merchandise;

[User] What updated_at, reserved, tags, description do we have for merchandise and their associated messages?

[Assistant] SELECT thumbnail_url, message_id, featured_rank, messages.tags, messages.description FROM manufacturing.merchandise JOIN manufacturing.messages ON merchandise.message_id = messages.message_id;

[User] Only show the top 5 results.

[Assistant] SELECT thumbnail_url, message_id, featured_rank, messages.tags, messages.description FROM manufacturing.merchandise JOIN manufacturing.messages ON merchandise.message_id = messages.message_id LIMIT 5;


[User] Get all messages.

[Assistant] SELECT * FROM manufacturing.messages;

[User] List edited_at, description, thumbnail_url, video_url for each message along with their merchandise information.

[Assistant] SELECT *, merchandise.thumbnail_url, merchandise.video_url FROM manufacturing.messages JOIN manufacturing.merchandise ON messages.merchandis_id = merchandise.product_id;

[User] Limit the results to 10 rows.

[Assistant] SELECT *, merchandise.thumbnail_url, merchandise.video_url FROM manufacturing.messages JOIN manufacturing.merchandise ON messages.merchandis_id = merchandise.product_id LIMIT 10;


[User] Get description, tags, merchandis_id from all messages.

[Assistant] SELECT description, tags, merchandis_id FROM manufacturing.messages;

[User] Show the results sorted by description descending.

[Assistant] SELECT description, tags, merchandis_id FROM manufacturing.messages ORDER BY description DESC;

[User] Get the distribution of messages across different edited_at values.

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


[User] Retrieve all messages.

[Assistant] SELECT * FROM manufacturing.messages;

[User] Show the results sorted by edited_at ascending.

[Assistant] SELECT * FROM manufacturing.messages ORDER BY edited_at ASC;

[User] Return just 50 rows.

[Assistant] SELECT * FROM manufacturing.messages ORDER BY edited_at ASC LIMIT 50;


[User] Display all messages.

[Assistant] SELECT * FROM manufacturing.messages;

[User] List merchandis_id, edited_at, media_url, subcategory for each message along with their merchandise information.

[Assistant] SELECT *, merchandise.media_url, merchandise.subcategory FROM manufacturing.messages JOIN manufacturing.merchandise ON messages.merchandis_id = merchandise.product_id;

[User] Calculate max of tags for each views in messages.

[Assistant] SELECT views, MAX(tags) AS max_tags FROM manufacturing.messages GROUP BY views;


[User] Retrieve tags, description, edited_at for every message.

[Assistant] SELECT tags, description, edited_at FROM manufacturing.messages;

[User] Show the results sorted by description ascending.

[Assistant] SELECT tags, description, edited_at FROM manufacturing.messages ORDER BY description ASC;

[User] Show only 15 records.

[Assistant] SELECT tags, description, edited_at FROM manufacturing.messages ORDER BY description ASC LIMIT 15;


[User] List all messages.

[Assistant] SELECT * FROM manufacturing.messages;

[User] Show me merchandis_id, views, media_url, thumbnail_url from messages and their related merchandise.

[Assistant] SELECT *, merchandise.media_url, merchandise.thumbnail_url FROM manufacturing.messages JOIN manufacturing.merchandise ON messages.merchandis_id = merchandise.product_id;

[User] Sort the results by tags descending.

[Assistant] SELECT *, merchandise.media_url, merchandise.thumbnail_url FROM manufacturing.messages JOIN manufacturing.merchandise ON messages.merchandis_id = merchandise.product_id ORDER BY tags DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.followers (
  address_id varchar PRIMARY KEY -- unique identifier,
  last_inspected timestamp,
  type varchar NOT NULL,
  description varchar NOT NULL,
  category character varying(256),
  state character varying(64),
  coordinates char,
  accessibility varchar NOT NULL,
  message_id text -- reference to messages.message_id,
  FOREIGN KEY (message_id) REFERENCES messages(message_id)
)

CREATE TABLE socialmedia.users (
  employee_id character varying(64) NOT NULL -- unique identifier,
  last_active timestamp without time zone,
  language character varying(128),
  full_name char,
  avatar character varying(256) NOT NULL,
  city character varying(64),
  age varchar
)

CREATE TABLE socialmedia.messages (
  message_id text PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  created_at timestamp,
  subject character varying(256) NOT NULL,
  thumbnail character varying(256),
  image_url varchar
)

[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] List last_inspected, message_id, created_at, edited_at for each follower along with their message information.

[Assistant] SELECT *, messages.created_at, messages.edited_at FROM socialmedia.followers JOIN socialmedia.messages ON followers.message_id = messages.message_id;

[User] Group followers by category and show the count of type.

[Assistant] SELECT category, COUNT(type) AS count_type FROM socialmedia.followers GROUP BY category;


[User] Show me description, category, state for all followers.

[Assistant] SELECT description, category, state FROM socialmedia.followers;

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

[Assistant] SELECT description, category, state FROM socialmedia.followers WHERE coordinates LIKE 'A%';

[User] Show me max of category grouped by accessibility for followers.

[Assistant] SELECT accessibility, MAX(category) AS max_category FROM socialmedia.followers GROUP BY accessibility;


[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show me followers that were from 2023.

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

[User] What is the average message_id for each coordinates in followers?

[Assistant] SELECT coordinates, AVERAGE(message_id) AS average_message_id FROM socialmedia.followers GROUP BY coordinates;


[User] Show me message_id, last_inspected, state for all followers.

[Assistant] SELECT message_id, last_inspected, state FROM socialmedia.followers;

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

[Assistant] SELECT message_id, last_inspected, state FROM socialmedia.followers ORDER BY description ASC;

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

[Assistant] SELECT message_id, last_inspected, state FROM socialmedia.followers ORDER BY accessibility DESC;


[User] Show me all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

[User] Show the results sorted by message_id ascending.

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


[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Get message_id, category, subject, created_at by joining followers with messages.

[Assistant] SELECT *, messages.subject, messages.created_at FROM socialmedia.followers JOIN socialmedia.messages ON followers.message_id = messages.message_id;

[User] Group followers by last_inspected and show the count of category.

[Assistant] SELECT last_inspected, COUNT(category) AS count_category FROM socialmedia.followers GROUP BY last_inspected;


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Sort the results by accessibility ascending.

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

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

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


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show me description, accessibility, edited_at, subject from followers and their related messages.

[Assistant] SELECT *, messages.edited_at, messages.subject FROM socialmedia.followers JOIN socialmedia.messages ON followers.message_id = messages.message_id;

[User] Return just 20 rows.

[Assistant] SELECT *, messages.edited_at, messages.subject FROM socialmedia.followers JOIN socialmedia.messages ON followers.message_id = messages.message_id LIMIT 20;


[User] List category, message_id, state from followers.

[Assistant] SELECT category, message_id, state FROM socialmedia.followers;

[User] Show me coordinates, description, thumbnail, image_url from followers and their related messages.

[Assistant] SELECT category, message_id, state, messages.thumbnail, messages.image_url FROM socialmedia.followers JOIN socialmedia.messages ON followers.message_id = messages.message_id;

[User] Get max of type by message_id from followers.

[Assistant] SELECT message_id, MAX(type) AS max_type FROM socialmedia.followers GROUP BY message_id;


[User] Display all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show the results sorted by description descending.

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

[User] Show only 10 records.

[Assistant] SELECT * FROM socialmedia.followers ORDER BY description DESC LIMIT 10;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.shipping (
  comment_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  text character varying(256),
  rating character varying(256),
  attachment_url char,
  shares char,
  user_id character varying(128) -- identifier for user,
  format character varying(256) NOT NULL,
  product_id text -- reference to products.barcode,
  FOREIGN KEY (product_id) REFERENCES products(barcode)
)

CREATE TABLE e-commerce.reviews (
  post_id text PRIMARY KEY -- unique identifier,
  published_at date,
  created_at timestamp without time zone,
  reply_to_id varchar,
  thumbnail character varying(256) NOT NULL,
  rating character varying(256),
  image_url varchar,
  user_id character varying(64) -- identifier for user,
  shippin_id text NOT NULL -- reference to shipping.comment_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(comment_id)
)

CREATE TABLE e-commerce.products (
  barcode varchar PRIMARY KEY -- unique identifier,
  published_at timestamp,
  created_at date,
  video_url character varying(128),
  image_url varchar,
  thumbnail_url character varying(64),
  price numeric,
  reserved varchar,
  msrp character varying(256) NOT NULL,
  currency character varying(256),
  review_id text -- reference to reviews.post_id,
  shippin_id text NOT NULL -- reference to shipping.comment_id,
  FOREIGN KEY (review_id) REFERENCES reviews(post_id),
  FOREIGN KEY (shippin_id) REFERENCES shipping(comment_id)
)

[User] List all shipping.

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

[User] List shipping with dates created yesterday.

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

[User] Tally up shipping by created_at.

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


[User] Get all reviews.

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

[User] Order the output by thumbnail ascending.

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

[User] Show only 25 records.

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


[User] Show me all shipping.

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

[User] Find shipping where format LIKE 'A%'.

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

[User] Restrict the output to 15 items.

[Assistant] SELECT * FROM e-commerce.shipping WHERE format LIKE 'A%' LIMIT 15;


[User] Show me all products.

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

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

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

[User] Sort the results by created_at ascending.

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


[User] List all reviews.

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

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

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

[User] Can you order these by published_at ascending?

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


[User] Retrieve all shipping.

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

[User] Get shipping that match format LIKE 'A%'.

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

[User] Only show the top 10 results.

[Assistant] SELECT * FROM e-commerce.shipping WHERE format LIKE 'A%' LIMIT 10;


[User] Display all shipping.

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

[User] Show me shipping with product_id LIKE 'A%'.

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

[User] Return just 20 rows.

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