[User] Retrieve last_inspected, location_lon, address_id for every store.

[Assistant] SELECT last_inspected, location_lon, address_id FROM government.stores;

[User] Get all stores created yesterday.

[Assistant] SELECT last_inspected, location_lon, address_id FROM government.stores WHERE last_inspected = CURRENT_DATE - INTERVAL '1 day';

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

[Assistant] SELECT accessibility, COUNT(*) AS count FROM government.stores GROUP BY accessibility 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.clients (
  user_id integer PRIMARY KEY -- unique identifier,
  created_at date,
  last_active timestamp without time zone,
  bio character varying(256),
  email text,
  website text,
  api_key char,
  age char NOT NULL,
  language text
)

CREATE TABLE government.stores (
  address_id character varying(64) NOT NULL -- unique identifier,
  last_inspected timestamp,
  accessibility character varying(256),
  location_lon character varying(64) NOT NULL,
  name varchar
)

CREATE TABLE government.goods (
  sku integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  expires_at timestamp,
  stock_level char NOT NULL,
  title character varying(64),
  subcategory varchar,
  available character varying(256)
)

[User] Get all goods.

[Assistant] SELECT * FROM government.goods;

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

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

[User] Show me max of created_at grouped by stock_level for goods.

[Assistant] SELECT stock_level, MAX(created_at) AS max_created_at FROM government.goods GROUP BY stock_level;


[User] Display all goods.

[Assistant] SELECT * FROM government.goods;

[User] Order the output by subcategory descending.

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

[User] Order the output by title descending.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.events (
  store_id varchar PRIMARY KEY -- unique identifier,
  last_inspected timestamp,
  created_at date,
  operating_hours varchar,
  state character varying(256),
  latitude text,
  accessibility varchar,
  parking_available text,
  comment_id text -- reference to comments.id,
  follower_id text -- reference to followers.payment_id,
  FOREIGN KEY (comment_id) REFERENCES comments(id),
  FOREIGN KEY (follower_id) REFERENCES followers(payment_id)
)

CREATE TABLE socialmedia.comments (
  id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp,
  reply_to_id character varying(256),
  description character varying(128),
  parent_id text NOT NULL -- identifier for parent,
  body character varying(256) NOT NULL,
  event_id text NOT NULL -- reference to events.store_id,
  FOREIGN KEY (event_id) REFERENCES events(store_id)
)

CREATE TABLE socialmedia.followers (
  payment_id varchar PRIMARY KEY -- unique identifier,
  processed_at date,
  discount numeric,
  user_id character varying(256) -- identifier for user,
  price numeric NOT NULL,
  comment_id text NOT NULL -- reference to comments.id,
  FOREIGN KEY (comment_id) REFERENCES comments(id)
)

[User] Show me last_inspected, parking_available, accessibility for all events.

[Assistant] SELECT last_inspected, parking_available, accessibility FROM socialmedia.events;

[User] Find events between January and March.

[Assistant] SELECT last_inspected, parking_available, accessibility FROM socialmedia.events WHERE last_inspected BETWEEN '2023-01-01' AND '2023-03-31';

[User] Only show the top 25 results.

[Assistant] SELECT last_inspected, parking_available, accessibility FROM socialmedia.events WHERE last_inspected BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 25;


[User] Show me all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

[Assistant] SELECT * FROM socialmedia.comments WHERE published_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Show only 100 records.

[Assistant] SELECT * FROM socialmedia.comments WHERE published_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 100;


[User] What are the created_at, accessibility, last_inspected of each event?

[Assistant] SELECT created_at, accessibility, last_inspected FROM socialmedia.events;

[User] List comment_id, state, published_at, reply_to_id for each event along with their comment information.

[Assistant] SELECT created_at, accessibility, last_inspected, comments.published_at, comments.reply_to_id FROM socialmedia.events JOIN socialmedia.comments ON events.comment_id = comments.id;

[User] Show only 15 records.

[Assistant] SELECT created_at, accessibility, last_inspected, comments.published_at, comments.reply_to_id FROM socialmedia.events JOIN socialmedia.comments ON events.comment_id = comments.id LIMIT 15;


[User] Retrieve parking_available, comment_id, last_inspected for every event.

[Assistant] SELECT parking_available, comment_id, last_inspected FROM socialmedia.events;

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

[Assistant] SELECT parking_available, comment_id, last_inspected FROM socialmedia.events WHERE latitude LIKE 'A%';

[User] Get average of accessibility by last_inspected from events.

[Assistant] SELECT last_inspected, AVERAGE(accessibility) AS average_accessibility FROM socialmedia.events GROUP BY last_inspected;


[User] Display all events.

[Assistant] SELECT * FROM socialmedia.events;

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

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

[User] Only show the top 50 results.

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


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show the results sorted by comment_id ascending.

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

[User] Show me sum of comment_id grouped by comment_id for followers.

[Assistant] SELECT comment_id, SUM(comment_id) AS sum_comment_id FROM socialmedia.followers GROUP BY comment_id;


[User] Retrieve follower_id, state, accessibility for every event.

[Assistant] SELECT follower_id, state, accessibility FROM socialmedia.events;

[User] Get latitude, follower_id, body, published_at by joining events with comments.

[Assistant] SELECT follower_id, state, accessibility, comments.body, comments.published_at FROM socialmedia.events JOIN socialmedia.comments ON events.comment_id = comments.id;

[User] Show only 20 records.

[Assistant] SELECT follower_id, state, accessibility, comments.body, comments.published_at FROM socialmedia.events JOIN socialmedia.comments ON events.comment_id = comments.id LIMIT 20;


[User] List all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Show me event_id, published_at, accessibility, created_at from comments and their related events.

[Assistant] SELECT *, events.accessibility, events.created_at FROM socialmedia.comments JOIN socialmedia.events ON comments.event_id = events.store_id;

[User] Show the results sorted by description ascending.

[Assistant] SELECT *, events.accessibility, events.created_at FROM socialmedia.comments JOIN socialmedia.events ON comments.event_id = events.store_id ORDER BY description ASC;


[User] List price, processed_at, comment_id from followers.

[Assistant] SELECT price, processed_at, comment_id FROM socialmedia.followers;

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

[Assistant] SELECT price, processed_at, comment_id FROM socialmedia.followers WHERE processed_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Tally up followers by processed_at.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE insurance.invoices (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  due_date date,
  vendor_id char -- identifier for vendor,
  approval_status character varying(256),
  exchange_rate character varying(256) NOT NULL,
  user_id char -- identifier for user,
  customer_id char NOT NULL -- identifier for customer,
  addresse_id text -- reference to addresses.venue_id,
  FOREIGN KEY (addresse_id) REFERENCES addresses(venue_id)
)

CREATE TABLE insurance.reviews (
  comment_id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  views character varying(128),
  likes character varying(256),
  description character varying(128),
  format character varying(64),
  score char NOT NULL,
  parent_id character varying(256),
  thumbnail character varying(128),
  addresse_id text NOT NULL -- reference to addresses.venue_id,
  invoice_id text -- reference to invoices.id,
  FOREIGN KEY (addresse_id) REFERENCES addresses(venue_id),
  FOREIGN KEY (invoice_id) REFERENCES invoices(id)
)

CREATE TABLE insurance.addresses (
  venue_id text PRIMARY KEY -- unique identifier,
  last_inspected timestamp without time zone,
  parking_available character varying(256) NOT NULL,
  type text,
  operating_hours character varying(64),
  coordinates char,
  name char,
  invoice_id text NOT NULL -- reference to invoices.id,
  FOREIGN KEY (invoice_id) REFERENCES invoices(id)
)

[User] Retrieve all reviews.

[Assistant] SELECT * FROM insurance.reviews;

[User] Sort the results by addresse_id descending.

[Assistant] SELECT * FROM insurance.reviews ORDER BY addresse_id DESC;

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

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


[User] Get all reviews.

[Assistant] SELECT * FROM insurance.reviews;

[User] Get all reviews from last week.

[Assistant] SELECT * FROM insurance.reviews WHERE published_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Get the distribution of reviews across different addresse_id values.

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


[User] Get all reviews.

[Assistant] SELECT * FROM insurance.reviews;

[User] Find reviews where parent_id LIKE 'A%'.

[Assistant] SELECT * FROM insurance.reviews WHERE parent_id LIKE 'A%';

[User] Group reviews by likes and show the max of format.

[Assistant] SELECT likes, MAX(format) AS max_format FROM insurance.reviews GROUP BY likes;


[User] Show me all reviews.

[Assistant] SELECT * FROM insurance.reviews;

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

[Assistant] SELECT * FROM insurance.reviews WHERE thumbnail LIKE 'A%';

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

[Assistant] SELECT likes, MIN(published_at) AS min_published_at FROM insurance.reviews GROUP BY likes;


[User] What are the addresse_id, published_at, views of each review?

[Assistant] SELECT addresse_id, published_at, views FROM insurance.reviews;

[User] Order the output by likes ascending.

[Assistant] SELECT addresse_id, published_at, views FROM insurance.reviews ORDER BY likes ASC;

[User] Group reviews by score and show the sum of thumbnail.

[Assistant] SELECT score, SUM(thumbnail) AS sum_thumbnail FROM insurance.reviews GROUP BY score;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.events (
  invoice_id integer PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  amount decimal,
  verification_status character varying(256),
  exchange_rate character varying(128),
  debit character varying(64) NOT NULL,
  payer_id character varying(256) -- identifier for payer,
  invoice_number character varying(64),
  user_id text -- reference to users.id,
  FOREIGN KEY (user_id) REFERENCES users(id)
)

CREATE TABLE socialmedia.users (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  last_active date,
  is_active boolean,
  website varchar NOT NULL,
  first_name character varying(256) NOT NULL,
  event_id integer NOT NULL -- reference to events.invoice_id,
  FOREIGN KEY (event_id) REFERENCES events(invoice_id)
)

[User] Retrieve website, updated_at, is_active for every user.

[Assistant] SELECT website, updated_at, is_active FROM socialmedia.users;

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

[Assistant] SELECT website, updated_at, is_active FROM socialmedia.users WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Limit the results to 50 rows.

[Assistant] SELECT website, updated_at, is_active FROM socialmedia.users WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 50;


[User] List verification_status, invoice_number, exchange_rate from events.

[Assistant] SELECT verification_status, invoice_number, exchange_rate FROM socialmedia.events;

[User] Get user_id, exchange_rate, updated_at, last_active by joining events with users.

[Assistant] SELECT verification_status, invoice_number, exchange_rate, users.updated_at, users.last_active FROM socialmedia.events JOIN socialmedia.users ON events.user_id = users.id;

[User] Only show the top 5 results.

[Assistant] SELECT verification_status, invoice_number, exchange_rate, users.updated_at, users.last_active FROM socialmedia.events JOIN socialmedia.users ON events.user_id = users.id LIMIT 5;


[User] Show me website, last_active, is_active for all users.

[Assistant] SELECT website, last_active, is_active FROM socialmedia.users;

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

[Assistant] SELECT website, last_active, is_active FROM socialmedia.users ORDER BY updated_at DESC;

[User] Can you order these by last_active ascending?

[Assistant] SELECT website, last_active, is_active FROM socialmedia.users ORDER BY last_active ASC;


[User] List all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Show the results sorted by debit ascending.

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

[User] Return just 20 rows.

[Assistant] SELECT * FROM socialmedia.events ORDER BY debit ASC LIMIT 20;


[User] Retrieve verification_status, debit, amount for every event.

[Assistant] SELECT verification_status, debit, amount FROM socialmedia.events;

[User] Get verification_status, payment_date, is_active, last_active by joining events with users.

[Assistant] SELECT verification_status, debit, amount, users.is_active, users.last_active FROM socialmedia.events JOIN socialmedia.users ON events.user_id = users.id;

[User] Restrict the output to 20 items.

[Assistant] SELECT verification_status, debit, amount, users.is_active, users.last_active FROM socialmedia.events JOIN socialmedia.users ON events.user_id = users.id LIMIT 20;


[User] Show me verification_status, payer_id, debit for all events.

[Assistant] SELECT verification_status, payer_id, debit FROM socialmedia.events;

[User] Show me events with payment_date > '2023-01-01'.

[Assistant] SELECT verification_status, payer_id, debit FROM socialmedia.events WHERE payment_date > '2023-01-01';

[User] Limit the results to 100 rows.

[Assistant] SELECT verification_status, payer_id, debit FROM socialmedia.events WHERE payment_date > '2023-01-01' LIMIT 100;


[User] List all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Show the results sorted by user_id descending.

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

[User] Tally up events by debit.

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


[User] Retrieve first_name, last_active, is_active for every user.

[Assistant] SELECT first_name, last_active, is_active FROM socialmedia.users;

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

[Assistant] SELECT first_name, last_active, is_active FROM socialmedia.users ORDER BY website DESC;

[User] What is the average last_active for each is_active in users?

[Assistant] SELECT is_active, AVERAGE(last_active) AS average_last_active FROM socialmedia.users GROUP BY is_active;


[User] List verification_status, payment_date, invoice_number from events.

[Assistant] SELECT verification_status, payment_date, invoice_number FROM socialmedia.events;

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

[Assistant] SELECT verification_status, payment_date, invoice_number FROM socialmedia.events ORDER BY exchange_rate ASC;

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

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


[User] Get last_active, updated_at, website from all users.

[Assistant] SELECT last_active, updated_at, website FROM socialmedia.users;

[User] Show the results sorted by is_active ascending.

[Assistant] SELECT last_active, updated_at, website FROM socialmedia.users ORDER BY is_active ASC;

[User] Sort the results by last_active ascending.

[Assistant] SELECT last_active, updated_at, website FROM socialmedia.users ORDER BY last_active ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.students (
  employee_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  created_at timestamp without time zone,
  website text NOT NULL,
  account_status character varying(256),
  full_name char NOT NULL,
  state text,
  password_hash text NOT NULL,
  course_id text -- reference to courses.account_id,
  enrollment_id text NOT NULL -- reference to enrollments.content_id,
  FOREIGN KEY (course_id) REFERENCES courses(account_id),
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(content_id)
)

CREATE TABLE education.enrollments (
  content_id text PRIMARY KEY -- unique identifier,
  created_at date,
  visibility character varying(64) NOT NULL,
  title character varying(256),
  thumbnail char NOT NULL,
  parent_id text NOT NULL -- identifier for parent,
  shares text,
  course_id text NOT NULL -- reference to courses.account_id,
  FOREIGN KEY (course_id) REFERENCES courses(account_id)
)

CREATE TABLE education.grades (
  barcode integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  published_at timestamp without time zone,
  video_url character varying(64) -- identifier for video_url,
  media_url character varying(128) NOT NULL,
  subcategory character varying(128) NOT NULL
)

CREATE TABLE education.courses (
  account_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  updated_at date,
  customer_id char NOT NULL -- identifier for customer,
  amount decimal,
  debit char,
  payer_id varchar
)

[User] Get all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Sort the results by shares descending.

[Assistant] SELECT * FROM education.enrollments ORDER BY shares DESC;

[User] Get max of course_id by thumbnail from enrollments.

[Assistant] SELECT thumbnail, MAX(course_id) AS max_course_id FROM education.enrollments GROUP BY thumbnail;


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 (
  transaction_id integer PRIMARY KEY -- unique identifier,
  traded_at timestamp without time zone,
  discount decimal,
  price numeric(38,14),
  payment_method character varying(128)
)

CREATE TABLE e-commerce.shipping (
  transaction_id integer PRIMARY KEY -- unique identifier,
  completed_at timestamp,
  payment_status varchar,
  currency varchar,
  exchange_rate char NOT NULL,
  amount decimal
)

CREATE TABLE e-commerce.inventory (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  expires_at timestamp,
  brand text NOT NULL,
  title character varying(64),
  available varchar,
  subcategory character varying(256),
  order_id integer -- reference to orders.transaction_id,
  FOREIGN KEY (order_id) REFERENCES orders(transaction_id)
)

[User] Retrieve all inventory.

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

[User] List title, brand, price, discount for each inventory along with their order information.

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

[User] How many inventory are there per id?

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


[User] Display all inventory.

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

[User] Find inventory where updated_at > '2023-01-01'.

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

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

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


[User] Get brand, updated_at, available from all inventory.

[Assistant] SELECT brand, updated_at, available FROM e-commerce.inventory;

[User] Order the output by title ascending.

[Assistant] SELECT brand, updated_at, available FROM e-commerce.inventory ORDER BY title ASC;

[User] Get average of updated_at by title from inventory.

[Assistant] SELECT title, AVERAGE(updated_at) AS average_updated_at FROM e-commerce.inventory GROUP BY title;


[User] Retrieve all inventory.

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

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

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

[User] Restrict the output to 25 items.

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


[User] What are the expires_at, available, updated_at of each inventory?

[Assistant] SELECT expires_at, available, updated_at FROM e-commerce.inventory;

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

[Assistant] SELECT expires_at, available, updated_at FROM e-commerce.inventory WHERE title LIKE 'A%';

[User] Show the results sorted by updated_at ascending.

[Assistant] SELECT expires_at, available, updated_at FROM e-commerce.inventory WHERE title LIKE 'A%' ORDER BY updated_at ASC;


[User] List all inventory.

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

[User] Find inventory from last week.

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

[User] Return just 10 rows.

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


[User] What are the brand, subcategory, updated_at of each inventory?

[Assistant] SELECT brand, subcategory, updated_at FROM e-commerce.inventory;

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

[Assistant] SELECT brand, subcategory, updated_at FROM e-commerce.inventory ORDER BY id ASC;

[User] Get average of available by expires_at from inventory.

[Assistant] SELECT expires_at, AVERAGE(available) AS average_available FROM e-commerce.inventory GROUP BY expires_at;


[User] Show me subcategory, id, available for all inventory.

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

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

[Assistant] SELECT subcategory, id, available FROM e-commerce.inventory WHERE title LIKE 'A%';

[User] Order the output by subcategory descending.

[Assistant] SELECT subcategory, id, available FROM e-commerce.inventory WHERE title LIKE 'A%' ORDER BY subcategory DESC;


[User] Show me available, title, expires_at for all inventory.

[Assistant] SELECT available, title, expires_at FROM e-commerce.inventory;

[User] Sort the results by order_id descending.

[Assistant] SELECT available, title, expires_at FROM e-commerce.inventory ORDER BY order_id DESC;

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

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


[User] Show me all inventory.

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

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

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

[User] Tally up inventory by expires_at.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE library.venues (
  store_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  operating_hours character varying(256) NOT NULL,
  accessibility varchar,
  state text,
  coordinates character varying(256),
  location_lon text,
  payment_id integer NOT NULL -- reference to payments.payment_id,
  FOREIGN KEY (payment_id) REFERENCES payments(payment_id)
)

CREATE TABLE library.payments (
  payment_id integer PRIMARY KEY -- unique identifier,
  payment_date date,
  notes char,
  amount numeric,
  customer_id text NOT NULL -- identifier for customer
)

[User] Show me state, location_lon, store_id for all venues.

[Assistant] SELECT state, location_lon, store_id FROM library.venues;

[User] List venues that have store_id LIKE 'A%'.

[Assistant] SELECT state, location_lon, store_id FROM library.venues WHERE store_id LIKE 'A%';

[User] Restrict the output to 20 items.

[Assistant] SELECT state, location_lon, store_id FROM library.venues WHERE store_id LIKE 'A%' LIMIT 20;


[User] List store_id, updated_at, payment_id from venues.

[Assistant] SELECT store_id, updated_at, payment_id FROM library.venues;

[User] Find venues modified within the last hour.

[Assistant] SELECT store_id, updated_at, payment_id FROM library.venues WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Show only 50 records.

[Assistant] SELECT store_id, updated_at, payment_id FROM library.venues WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 50;


[User] Display all venues.

[Assistant] SELECT * FROM library.venues;

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

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

[User] Get the distribution of venues across different location_lon values.

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


[User] Get coordinates, location_lon, operating_hours from all venues.

[Assistant] SELECT coordinates, location_lon, operating_hours FROM library.venues;

[User] Find venues where location_lon LIKE 'A%'.

[Assistant] SELECT coordinates, location_lon, operating_hours FROM library.venues WHERE location_lon LIKE 'A%';

[User] How many venues are there per operating_hours?

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


[User] Show me coordinates, operating_hours, updated_at for all venues.

[Assistant] SELECT coordinates, operating_hours, updated_at FROM library.venues;

[User] Find venues where payment_id > 63.

[Assistant] SELECT coordinates, operating_hours, updated_at FROM library.venues WHERE payment_id > 63;

[User] Show only 20 records.

[Assistant] SELECT coordinates, operating_hours, updated_at FROM library.venues WHERE payment_id > 63 LIMIT 20;


[User] Get operating_hours, updated_at, location_lon from all venues.

[Assistant] SELECT operating_hours, updated_at, location_lon FROM library.venues;

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

[Assistant] SELECT operating_hours, updated_at, location_lon FROM library.venues WHERE operating_hours LIKE 'A%';

[User] Count the number of venues in each coordinates category.

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


[User] Display all venues.

[Assistant] SELECT * FROM library.venues;

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

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

[User] Show me max of operating_hours grouped by store_id for venues.

[Assistant] SELECT store_id, MAX(operating_hours) AS max_operating_hours FROM library.venues GROUP BY store_id;


[User] List accessibility, state, store_id from venues.

[Assistant] SELECT accessibility, state, store_id FROM library.venues;

[User] List venues that have accessibility LIKE 'A%'.

[Assistant] SELECT accessibility, state, store_id FROM library.venues WHERE accessibility LIKE 'A%';

[User] Get sum of location_lon by updated_at from venues.

[Assistant] SELECT updated_at, SUM(location_lon) AS sum_location_lon FROM library.venues GROUP BY updated_at;


[User] List all venues.

[Assistant] SELECT * FROM library.venues;

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

[Assistant] SELECT * FROM library.venues WHERE coordinates LIKE 'A%';

[User] Calculate min of accessibility for each updated_at in venues.

[Assistant] SELECT updated_at, MIN(accessibility) AS min_accessibility FROM library.venues GROUP BY updated_at;


[User] Retrieve all venues.

[Assistant] SELECT * FROM library.venues;

[User] Can you order these by state descending?

[Assistant] SELECT * FROM library.venues ORDER BY state DESC;

[User] Get the distribution of venues across different location_lon values.

[Assistant] SELECT location_lon, COUNT(*) AS count FROM library.venues GROUP BY location_lon 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.categories (
  id character varying(64) NOT NULL -- unique identifier,
  expires_at timestamp,
  image_url varchar NOT NULL,
  rating character varying(256),
  price decimal NOT NULL,
  backorder character varying(128) NOT NULL,
  order_id text -- reference to orders.transaction_id,
  FOREIGN KEY (order_id) REFERENCES orders(transaction_id)
)

CREATE TABLE e-commerce.orders (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  completed_at date,
  exchange_rate text NOT NULL,
  buyer_id text -- identifier for buyer,
  discount smallint
)

[User] Get all categories.

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

[User] Find categories where backorder LIKE 'A%'.

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

[User] Get max of price by rating from categories.

[Assistant] SELECT rating, MAX(price) AS max_price FROM e-commerce.categories GROUP BY rating;


[User] Get rating, price, backorder from all categories.

[Assistant] SELECT rating, price, backorder FROM e-commerce.categories;

[User] Can you order these by order_id descending?

[Assistant] SELECT rating, price, backorder FROM e-commerce.categories ORDER BY order_id DESC;

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

[Assistant] SELECT rating, price, backorder FROM e-commerce.categories ORDER BY backorder ASC;


[User] Get id, price, rating from all categories.

[Assistant] SELECT id, price, rating FROM e-commerce.categories;

[User] List categories that have backorder LIKE 'A%'.

[Assistant] SELECT id, price, rating FROM e-commerce.categories WHERE backorder LIKE 'A%';

[User] Show only 25 records.

[Assistant] SELECT id, price, rating FROM e-commerce.categories WHERE backorder LIKE 'A%' LIMIT 25;


[User] Show me expires_at, order_id, image_url for all categories.

[Assistant] SELECT expires_at, order_id, image_url FROM e-commerce.categories;

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

[Assistant] SELECT expires_at, order_id, image_url FROM e-commerce.categories WHERE expires_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Group categories by image_url and show the sum of order_id.

[Assistant] SELECT image_url, SUM(order_id) AS sum_order_id FROM e-commerce.categories GROUP BY image_url;


[User] What are the id, price, image_url of each categorie?

[Assistant] SELECT id, price, image_url FROM e-commerce.categories;

[User] Show me categories with price > 51.

[Assistant] SELECT id, price, image_url FROM e-commerce.categories WHERE price > 51;

[User] What is the count image_url for each rating in categories?

[Assistant] SELECT rating, COUNT(image_url) AS count_image_url FROM e-commerce.categories GROUP BY rating;


[User] What are the expires_at, id, price of each categorie?

[Assistant] SELECT expires_at, id, price FROM e-commerce.categories;

[User] Find categories from 2023.

[Assistant] SELECT expires_at, id, price FROM e-commerce.categories WHERE expires_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] What is the min expires_at for each id in categories?

[Assistant] SELECT id, MIN(expires_at) AS min_expires_at FROM e-commerce.categories GROUP BY id;


[User] List expires_at, backorder, image_url from categories.

[Assistant] SELECT expires_at, backorder, image_url FROM e-commerce.categories;

[User] Retrieve categories where price > 72.

[Assistant] SELECT expires_at, backorder, image_url FROM e-commerce.categories WHERE price > 72;

[User] Count the number of categories in each image_url category.

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


[User] Show me price, rating, backorder for all categories.

[Assistant] SELECT price, rating, backorder FROM e-commerce.categories;

[User] Can you order these by backorder ascending?

[Assistant] SELECT price, rating, backorder FROM e-commerce.categories ORDER BY backorder ASC;

[User] Only show the top 100 results.

[Assistant] SELECT price, rating, backorder FROM e-commerce.categories ORDER BY backorder ASC LIMIT 100;


[User] Show me all categories.

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

[User] Find categories older than 6 months.

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

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

[Assistant] SELECT * FROM e-commerce.categories WHERE expires_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY rating ASC;


[User] Get expires_at, price, id from all categories.

[Assistant] SELECT expires_at, price, id FROM e-commerce.categories;

[User] Retrieve categories where order_id LIKE 'A%'.

[Assistant] SELECT expires_at, price, id FROM e-commerce.categories WHERE order_id LIKE 'A%';

[User] Show only 5 records.

[Assistant] SELECT expires_at, price, id FROM e-commerce.categories WHERE order_id LIKE 'A%' LIMIT 5;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.audits (
  order_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  created_at timestamp without time zone,
  seller_id text NOT NULL -- identifier for seller,
  approval_status character varying(64) NOT NULL,
  delivery_status character varying(64) NOT NULL,
  transaction_id text NOT NULL -- reference to transactions.invoice_id,
  FOREIGN KEY (transaction_id) REFERENCES transactions(invoice_id)
)

CREATE TABLE finance.transactions (
  invoice_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  amount integer,
  currency text,
  approval_status character varying(128)
)

[User] Retrieve updated_at, created_at, transaction_id for every audit.

[Assistant] SELECT updated_at, created_at, transaction_id FROM finance.audits;

[User] Retrieve approval_status, seller_id, approval_status, updated_at showing the relationship between audits and transactions.

[Assistant] SELECT updated_at, created_at, transaction_id, transactions.approval_status, transactions.updated_at FROM finance.audits JOIN finance.transactions ON audits.transaction_id = transactions.invoice_id;

[User] Group audits by approval_status and show the sum of approval_status.

[Assistant] SELECT approval_status, SUM(approval_status) AS sum_approval_status FROM finance.audits GROUP BY approval_status;


[User] List all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Retrieve approval_status, updated_at, approval_status, currency showing the relationship between audits and transactions.

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

[User] Show the results sorted by delivery_status descending.

[Assistant] SELECT *, transactions.approval_status, transactions.currency FROM finance.audits JOIN finance.transactions ON audits.transaction_id = transactions.invoice_id ORDER BY delivery_status DESC;


[User] Display all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Find audits from 2023.

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

[User] Tally up audits by approval_status.

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


[User] Retrieve seller_id, approval_status, created_at for every audit.

[Assistant] SELECT seller_id, approval_status, created_at FROM finance.audits;

[User] Find audits from 2023.

[Assistant] SELECT seller_id, approval_status, created_at FROM finance.audits WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Only show the top 100 results.

[Assistant] SELECT seller_id, approval_status, created_at FROM finance.audits WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 100;


[User] What are the updated_at, transaction_id, created_at of each audit?

[Assistant] SELECT updated_at, transaction_id, created_at FROM finance.audits;

[User] Show me created_at, approval_status, approval_status, amount from audits and their related transactions.

[Assistant] SELECT updated_at, transaction_id, created_at, transactions.approval_status, transactions.amount FROM finance.audits JOIN finance.transactions ON audits.transaction_id = transactions.invoice_id;

[User] Calculate average of delivery_status for each approval_status in audits.

[Assistant] SELECT approval_status, AVERAGE(delivery_status) AS average_delivery_status FROM finance.audits GROUP BY approval_status;


[User] Display all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Show me audits that were from 2023.

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

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

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


[User] Show me all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Retrieve approval_status, delivery_status, updated_at, approval_status showing the relationship between audits and transactions.

[Assistant] SELECT *, transactions.updated_at, transactions.approval_status FROM finance.audits JOIN finance.transactions ON audits.transaction_id = transactions.invoice_id;

[User] Return just 50 rows.

[Assistant] SELECT *, transactions.updated_at, transactions.approval_status FROM finance.audits JOIN finance.transactions ON audits.transaction_id = transactions.invoice_id LIMIT 50;


[User] List created_at, transaction_id, delivery_status from audits.

[Assistant] SELECT created_at, transaction_id, delivery_status FROM finance.audits;

[User] Retrieve delivery_status, updated_at, amount, updated_at showing the relationship between audits and transactions.

[Assistant] SELECT created_at, transaction_id, delivery_status, transactions.amount, transactions.updated_at FROM finance.audits JOIN finance.transactions ON audits.transaction_id = transactions.invoice_id;

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

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


[User] Show me transaction_id, created_at, approval_status for all audits.

[Assistant] SELECT transaction_id, created_at, approval_status FROM finance.audits;

[User] Find audits from last week.

[Assistant] SELECT transaction_id, created_at, approval_status FROM finance.audits WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Get min of transaction_id by created_at from audits.

[Assistant] SELECT created_at, MIN(transaction_id) AS min_transaction_id FROM finance.audits GROUP BY created_at;


[User] What are the delivery_status, transaction_id, created_at of each audit?

[Assistant] SELECT delivery_status, transaction_id, created_at FROM finance.audits;

[User] Show the results sorted by transaction_id ascending.

[Assistant] SELECT delivery_status, transaction_id, created_at FROM finance.audits ORDER BY transaction_id ASC;

[User] Return just 10 rows.

[Assistant] SELECT delivery_status, transaction_id, created_at FROM finance.audits ORDER BY transaction_id ASC 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 restaurant.reviews (
  content_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  parent_id varchar NOT NULL,
  categories text,
  keywords character varying(256) NOT NULL,
  inventor_id text -- reference to inventory.product_id,
  FOREIGN KEY (inventor_id) REFERENCES inventory(product_id)
)

CREATE TABLE restaurant.inventory (
  product_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  published_at timestamp,
  views character varying(256),
  reserved character varying(256),
  featured_rank varchar NOT NULL,
  thumbnail_url character varying(128),
  rating character varying(128) NOT NULL
)

[User] Retrieve all reviews.

[Assistant] SELECT * FROM restaurant.reviews;

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

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

[User] How many reviews are there per categories?

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


[User] Show me keywords, inventor_id, parent_id for all reviews.

[Assistant] SELECT keywords, inventor_id, parent_id FROM restaurant.reviews;

[User] Order the output by parent_id ascending.

[Assistant] SELECT keywords, inventor_id, parent_id FROM restaurant.reviews ORDER BY parent_id ASC;

[User] Group reviews by content_id and show the max of inventor_id.

[Assistant] SELECT content_id, MAX(inventor_id) AS max_inventor_id FROM restaurant.reviews GROUP BY content_id;


[User] Show me all reviews.

[Assistant] SELECT * FROM restaurant.reviews;

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

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

[User] How many reviews are there per content_id?

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


[User] What are the updated_at, inventor_id, categories of each review?

[Assistant] SELECT updated_at, inventor_id, categories FROM restaurant.reviews;

[User] Show me parent_id, content_id, reserved, thumbnail_url from reviews and their related inventory.

[Assistant] SELECT updated_at, inventor_id, categories, inventory.reserved, inventory.thumbnail_url FROM restaurant.reviews JOIN restaurant.inventory ON reviews.inventor_id = inventory.product_id;

[User] What is the average inventor_id for each content_id in reviews?

[Assistant] SELECT content_id, AVERAGE(inventor_id) AS average_inventor_id FROM restaurant.reviews GROUP BY content_id;


[User] List all reviews.

[Assistant] SELECT * FROM restaurant.reviews;

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

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

[User] Limit the results to 25 rows.

[Assistant] SELECT * FROM restaurant.reviews WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 25;


[User] List all reviews.

[Assistant] SELECT * FROM restaurant.reviews;

[User] Show me parent_id, categories, created_at, published_at from reviews and their related inventory.

[Assistant] SELECT *, inventory.created_at, inventory.published_at FROM restaurant.reviews JOIN restaurant.inventory ON reviews.inventor_id = inventory.product_id;

[User] Show the results sorted by updated_at ascending.

[Assistant] SELECT *, inventory.created_at, inventory.published_at FROM restaurant.reviews JOIN restaurant.inventory ON reviews.inventor_id = inventory.product_id ORDER BY updated_at ASC;


[User] Get categories, keywords, updated_at from all reviews.

[Assistant] SELECT categories, keywords, updated_at FROM restaurant.reviews;

[User] Can you order these by inventor_id ascending?

[Assistant] SELECT categories, keywords, updated_at FROM restaurant.reviews ORDER BY inventor_id ASC;

[User] Show the results sorted by inventor_id descending.

[Assistant] SELECT categories, keywords, updated_at FROM restaurant.reviews ORDER BY inventor_id DESC;


[User] Display all reviews.

[Assistant] SELECT * FROM restaurant.reviews;

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

[Assistant] SELECT * FROM restaurant.reviews WHERE keywords LIKE 'A%';

[User] Show the results sorted by inventor_id ascending.

[Assistant] SELECT * FROM restaurant.reviews WHERE keywords LIKE 'A%' ORDER BY inventor_id ASC;


[User] Show me all reviews.

[Assistant] SELECT * FROM restaurant.reviews;

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

[Assistant] SELECT * FROM restaurant.reviews WHERE inventor_id LIKE 'A%';

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

[Assistant] SELECT * FROM restaurant.reviews WHERE inventor_id LIKE 'A%' ORDER BY parent_id ASC;


[User] Get all reviews.

[Assistant] SELECT * FROM restaurant.reviews;

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

[Assistant] SELECT * FROM restaurant.reviews WHERE parent_id LIKE 'A%';

[User] Calculate max of categories for each categories in reviews.

[Assistant] SELECT categories, MAX(categories) AS max_categories FROM restaurant.reviews GROUP BY categories;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE media.subscriptions (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  due_date timestamp without time zone,
  processed_at date,
  reconciliation_status character varying(256),
  user_id text,
  payer_id character varying(256),
  client_id integer NOT NULL -- reference to clients.user_id,
  location_id text NOT NULL -- reference to locations.address_id,
  FOREIGN KEY (client_id) REFERENCES clients(user_id),
  FOREIGN KEY (location_id) REFERENCES locations(address_id)
)

CREATE TABLE media.clients (
  user_id integer PRIMARY KEY -- unique identifier,
  joined_at timestamp,
  avatar character varying(128),
  timezone character varying(128) NOT NULL,
  nationality varchar NOT NULL,
  location_id text -- reference to locations.address_id,
  FOREIGN KEY (location_id) REFERENCES locations(address_id)
)

CREATE TABLE media.locations (
  address_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  address_line1 character varying(64) NOT NULL,
  accessibility character varying(64),
  category character varying(128),
  parking_available varchar NOT NULL,
  timezone varchar NOT NULL,
  subscription_id text NOT NULL -- reference to subscriptions.invoice_id,
  FOREIGN KEY (subscription_id) REFERENCES subscriptions(invoice_id)
)

[User] Retrieve accessibility, subscription_id, timezone for every location.

[Assistant] SELECT accessibility, subscription_id, timezone FROM media.locations;

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

[Assistant] SELECT accessibility, subscription_id, timezone FROM media.locations WHERE created_at > '2023-01-01';

[User] What is the count subscription_id for each accessibility in locations?

[Assistant] SELECT accessibility, COUNT(subscription_id) AS count_subscription_id FROM media.locations GROUP BY accessibility;


[User] Show me all subscriptions.

[Assistant] SELECT * FROM media.subscriptions;

[User] Get subscriptions that match location_id LIKE 'A%'.

[Assistant] SELECT * FROM media.subscriptions WHERE location_id LIKE 'A%';

[User] Restrict the output to 50 items.

[Assistant] SELECT * FROM media.subscriptions WHERE location_id LIKE 'A%' LIMIT 50;


[User] Display all clients.

[Assistant] SELECT * FROM media.clients;

[User] Get avatar, location_id, timezone, subscription_id by joining clients with locations.

[Assistant] SELECT *, locations.timezone, locations.subscription_id FROM media.clients JOIN media.locations ON clients.location_id = locations.address_id;

[User] Order the output by avatar descending.

[Assistant] SELECT *, locations.timezone, locations.subscription_id FROM media.clients JOIN media.locations ON clients.location_id = locations.address_id ORDER BY avatar DESC;


[User] What are the timezone, avatar, joined_at of each client?

[Assistant] SELECT timezone, avatar, joined_at FROM media.clients;

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

[Assistant] SELECT timezone, avatar, joined_at FROM media.clients WHERE joined_at > '2023-01-01';

[User] Calculate max of timezone for each avatar in clients.

[Assistant] SELECT avatar, MAX(timezone) AS max_timezone FROM media.clients GROUP BY avatar;


[User] Retrieve joined_at, timezone, nationality for every client.

[Assistant] SELECT joined_at, timezone, nationality FROM media.clients;

[User] List clients that have nationality LIKE 'A%'.

[Assistant] SELECT joined_at, timezone, nationality FROM media.clients WHERE nationality LIKE 'A%';

[User] Restrict the output to 20 items.

[Assistant] SELECT joined_at, timezone, nationality FROM media.clients WHERE nationality LIKE 'A%' LIMIT 20;


[User] Get payer_id, client_id, due_date from all subscriptions.

[Assistant] SELECT payer_id, client_id, due_date FROM media.subscriptions;

[User] Sort the results by payer_id descending.

[Assistant] SELECT payer_id, client_id, due_date FROM media.subscriptions ORDER BY payer_id DESC;

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

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


[User] What are the joined_at, nationality, timezone of each client?

[Assistant] SELECT joined_at, nationality, timezone FROM media.clients;

[User] Sort the results by nationality ascending.

[Assistant] SELECT joined_at, nationality, timezone FROM media.clients ORDER BY nationality ASC;

[User] What is the min avatar for each timezone in clients?

[Assistant] SELECT timezone, MIN(avatar) AS min_avatar FROM media.clients GROUP BY timezone;


[User] Display all subscriptions.

[Assistant] SELECT * FROM media.subscriptions;

[User] List payer_id, location_id, location_id, timezone for each subscription along with their client information.

[Assistant] SELECT *, clients.location_id, clients.timezone FROM media.subscriptions JOIN media.clients ON subscriptions.client_id = clients.user_id;

[User] What is the count due_date for each processed_at in subscriptions?

[Assistant] SELECT processed_at, COUNT(due_date) AS count_due_date FROM media.subscriptions GROUP BY processed_at;


[User] List all subscriptions.

[Assistant] SELECT * FROM media.subscriptions;

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

[Assistant] SELECT * FROM media.subscriptions WHERE user_id LIKE 'A%';

[User] Show me average of client_id grouped by user_id for subscriptions.

[Assistant] SELECT user_id, AVERAGE(client_id) AS average_client_id FROM media.subscriptions GROUP BY user_id;


[User] Get timezone, avatar, joined_at from all clients.

[Assistant] SELECT timezone, avatar, joined_at FROM media.clients;

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

[Assistant] SELECT timezone, avatar, joined_at FROM media.clients ORDER BY timezone ASC;

[User] Restrict the output to 10 items.

[Assistant] SELECT timezone, avatar, joined_at FROM media.clients ORDER BY timezone ASC LIMIT 10;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.groups (
  sku character varying(64) NOT NULL -- unique identifier,
  created_at date,
  quantity varchar NOT NULL,
  price integer NOT NULL,
  stock_level character varying(256) NOT NULL,
  available character varying(64),
  title varchar,
  event_id integer NOT NULL -- reference to events.order_id,
  FOREIGN KEY (event_id) REFERENCES events(order_id)
)

CREATE TABLE socialmedia.events (
  order_id integer PRIMARY KEY -- unique identifier,
  completed_at date,
  tax smallint,
  payment_method character varying(64),
  payment_status text NOT NULL,
  user_id character varying(128) NOT NULL,
  status varchar,
  approval_status character varying(128) NOT NULL
)

[User] List all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Find groups between January and March.

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

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

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


[User] Show me all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Order the output by title ascending.

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

[User] Sort the results by sku descending.

[Assistant] SELECT * FROM socialmedia.groups ORDER BY sku DESC;


[User] Retrieve all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] List price, title, payment_status, approval_status for each group along with their event information.

[Assistant] SELECT *, events.payment_status, events.approval_status FROM socialmedia.groups JOIN socialmedia.events ON groups.event_id = events.order_id;

[User] Show me sum of stock_level grouped by created_at for groups.

[Assistant] SELECT created_at, SUM(stock_level) AS sum_stock_level FROM socialmedia.groups GROUP BY created_at;


[User] Show me all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Show me groups with title LIKE 'A%'.

[Assistant] SELECT * FROM socialmedia.groups WHERE title LIKE 'A%';

[User] Show the results sorted by created_at descending.

[Assistant] SELECT * FROM socialmedia.groups WHERE title LIKE 'A%' ORDER BY created_at DESC;


[User] Get all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] What available, title, completed_at, status do we have for groups and their associated events?

[Assistant] SELECT *, events.completed_at, events.status FROM socialmedia.groups JOIN socialmedia.events ON groups.event_id = events.order_id;

[User] Can you order these by sku ascending?

[Assistant] SELECT *, events.completed_at, events.status FROM socialmedia.groups JOIN socialmedia.events ON groups.event_id = events.order_id ORDER BY sku ASC;


[User] Retrieve all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Show the results sorted by event_id descending.

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

[User] Limit the results to 10 rows.

[Assistant] SELECT * FROM socialmedia.groups ORDER BY event_id DESC LIMIT 10;


[User] List available, stock_level, created_at from groups.

[Assistant] SELECT available, stock_level, created_at FROM socialmedia.groups;

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

[Assistant] SELECT available, stock_level, created_at FROM socialmedia.groups WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] How many groups are there per event_id?

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


[User] Get all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Order the output by stock_level ascending.

[Assistant] SELECT * FROM socialmedia.groups ORDER BY stock_level ASC;

[User] How many groups are there per event_id?

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


[User] Retrieve title, created_at, stock_level for every group.

[Assistant] SELECT title, created_at, stock_level FROM socialmedia.groups;

[User] Show me title, price, tax, payment_status from groups and their related events.

[Assistant] SELECT title, created_at, stock_level, events.tax, events.payment_status FROM socialmedia.groups JOIN socialmedia.events ON groups.event_id = events.order_id;

[User] Order the output by available descending.

[Assistant] SELECT title, created_at, stock_level, events.tax, events.payment_status FROM socialmedia.groups JOIN socialmedia.events ON groups.event_id = events.order_id ORDER BY available DESC;


[User] Show me title, event_id, quantity for all groups.

[Assistant] SELECT title, event_id, quantity FROM socialmedia.groups;

[User] Get groups that match event_id > 29.

[Assistant] SELECT title, event_id, quantity FROM socialmedia.groups WHERE event_id > 29;

[User] Show me min of stock_level grouped by created_at for groups.

[Assistant] SELECT created_at, MIN(stock_level) AS min_stock_level FROM socialmedia.groups GROUP BY created_at;


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 (
  payment_id character varying(64) NOT NULL -- unique identifier,
  processed_at timestamp,
  currency varchar,
  notes character varying(128) NOT NULL,
  description varchar NOT NULL,
  verification_status character varying(256) NOT NULL,
  group_id integer NOT NULL -- reference to groups.product_id,
  FOREIGN KEY (group_id) REFERENCES groups(product_id)
)

CREATE TABLE socialmedia.comments (
  message_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  tags varchar,
  text character varying(128) NOT NULL,
  author_id char -- identifier for author,
  subject char NOT NULL
)

CREATE TABLE socialmedia.messages (
  comment_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  subject character varying(128),
  attachment_url character varying(128) NOT NULL,
  author_id char,
  title character varying(128),
  group_id integer NOT NULL -- reference to groups.product_id,
  FOREIGN KEY (group_id) REFERENCES groups(product_id)
)

CREATE TABLE socialmedia.groups (
  product_id integer PRIMARY KEY -- unique identifier,
  expires_at timestamp,
  rating character varying(256),
  video_url character varying(64) -- identifier for video_url,
  media_url character varying(256),
  quantity character varying(128),
  available character varying(128),
  comment_id text -- reference to comments.message_id,
  FOREIGN KEY (comment_id) REFERENCES comments(message_id)
)

[User] Display all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

[User] How many followers are there per notes?

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


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show me followers with payment_id LIKE 'A%'.

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

[User] Return just 10 rows.

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


[User] Display all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

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

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


[User] Display all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Can you order these by author_id ascending?

[Assistant] SELECT * FROM socialmedia.messages ORDER BY author_id ASC;

[User] Can you order these by author_id descending?

[Assistant] SELECT * FROM socialmedia.messages ORDER BY author_id DESC;


[User] Display all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Retrieve groups where media_url LIKE 'A%'.

[Assistant] SELECT * FROM socialmedia.groups WHERE media_url LIKE 'A%';

[User] Return just 100 rows.

[Assistant] SELECT * FROM socialmedia.groups WHERE media_url LIKE 'A%' LIMIT 100;


[User] Get all groups.

[Assistant] SELECT * FROM socialmedia.groups;

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

[Assistant] SELECT * FROM socialmedia.groups WHERE media_url LIKE 'A%';

[User] Restrict the output to 50 items.

[Assistant] SELECT * FROM socialmedia.groups WHERE media_url LIKE 'A%' LIMIT 50;


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

CREATE TABLE tradingplatform.users (
  id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp,
  created_at date,
  avatar character varying(256),
  last_name character varying(64) NOT NULL,
  birth_date date,
  full_name character varying(64),
  wallet_id text -- reference to wallets.account_id,
  metadat_id integer -- reference to metadata.sku,
  FOREIGN KEY (wallet_id) REFERENCES wallets(account_id),
  FOREIGN KEY (metadat_id) REFERENCES metadata(sku)
)

CREATE TABLE tradingplatform.metadata (
  sku integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  rating char,
  popularity_score char,
  description text,
  discount numeric(38,14),
  price numeric NOT NULL,
  user_id text NOT NULL -- reference to users.id,
  wallet_id text -- reference to wallets.account_id,
  FOREIGN KEY (user_id) REFERENCES users(id),
  FOREIGN KEY (wallet_id) REFERENCES wallets(account_id)
)

[User] List updated_at, price, user_id from metadata.

[Assistant] SELECT updated_at, price, user_id FROM tradingplatform.metadata;

[User] Sort the results by wallet_id descending.

[Assistant] SELECT updated_at, price, user_id FROM tradingplatform.metadata ORDER BY wallet_id DESC;

[User] Can you order these by updated_at ascending?

[Assistant] SELECT updated_at, price, user_id FROM tradingplatform.metadata ORDER BY updated_at ASC;


[User] Retrieve wallet_id, full_name, last_name for every user.

[Assistant] SELECT wallet_id, full_name, last_name FROM tradingplatform.users;

[User] Show the results sorted by avatar descending.

[Assistant] SELECT wallet_id, full_name, last_name FROM tradingplatform.users ORDER BY avatar DESC;

[User] What is the min avatar for each birth_date in users?

[Assistant] SELECT birth_date, MIN(avatar) AS min_avatar FROM tradingplatform.users GROUP BY birth_date;


[User] Retrieve rating, popularity_score, updated_at for every metadata.

[Assistant] SELECT rating, popularity_score, updated_at FROM tradingplatform.metadata;

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

[Assistant] SELECT rating, popularity_score, updated_at FROM tradingplatform.metadata ORDER BY wallet_id ASC;

[User] Order the output by popularity_score descending.

[Assistant] SELECT rating, popularity_score, updated_at FROM tradingplatform.metadata ORDER BY popularity_score DESC;


[User] What are the due_date, metadat_id, status of each wallet?

[Assistant] SELECT due_date, metadat_id, status FROM tradingplatform.wallets;

[User] Order the output by metadat_id ascending.

[Assistant] SELECT due_date, metadat_id, status FROM tradingplatform.wallets ORDER BY metadat_id ASC;

[User] Only show the top 50 results.

[Assistant] SELECT due_date, metadat_id, status FROM tradingplatform.wallets ORDER BY metadat_id ASC LIMIT 50;


[User] Display all users.

[Assistant] SELECT * FROM tradingplatform.users;

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

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

[User] Show only 5 records.

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


[User] What are the description, metadat_id, updated_at of each wallet?

[Assistant] SELECT description, metadat_id, updated_at FROM tradingplatform.wallets;

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

[Assistant] SELECT description, metadat_id, updated_at FROM tradingplatform.wallets WHERE updated_at > '2023-01-01';

[User] Show me max of reconciliation_status grouped by due_date for wallets.

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


[User] Display all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

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

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

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

[Assistant] SELECT * FROM tradingplatform.metadata WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY popularity_score ASC;


[User] List due_date, status, metadat_id from wallets.

[Assistant] SELECT due_date, status, metadat_id FROM tradingplatform.wallets;

[User] Find wallets from 2023.

[Assistant] SELECT due_date, status, metadat_id FROM tradingplatform.wallets WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Get average of description by reconciliation_status from wallets.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.events (
  venue_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  name text,
  geo_point character varying(64) NOT NULL,
  address_line2 character varying(64) NOT NULL,
  message_id text -- reference to messages.content_id,
  FOREIGN KEY (message_id) REFERENCES messages(content_id)
)

CREATE TABLE socialmedia.likes (
  content_id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  created_at timestamp without time zone,
  keywords character varying(64) NOT NULL,
  media_url varchar,
  visibility text NOT NULL,
  message_id text NOT NULL -- reference to messages.content_id,
  FOREIGN KEY (message_id) REFERENCES messages(content_id)
)

CREATE TABLE socialmedia.messages (
  content_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  edited_at timestamp without time zone,
  description character varying(256),
  author_id text -- identifier for author,
  reply_to_id char -- identifier for reply_to,
  keywords char,
  content char
)

CREATE TABLE socialmedia.comments (
  message_id text PRIMARY KEY -- unique identifier,
  created_at date,
  edited_at date,
  subject varchar,
  reply_to_id character varying(64) NOT NULL,
  author_id character varying(64) -- identifier for author,
  thumbnail text
)

[User] Retrieve address_line2, name, updated_at for every event.

[Assistant] SELECT address_line2, name, updated_at FROM socialmedia.events;

[User] Find events where updated_at > '2023-01-01'.

[Assistant] SELECT address_line2, name, updated_at FROM socialmedia.events WHERE updated_at > '2023-01-01';

[User] Count the number of events in each message_id category.

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


[User] Display all events.

[Assistant] SELECT * FROM socialmedia.events;

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

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

[User] Tally up events by updated_at.

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


[User] Get name, address_line2, geo_point from all events.

[Assistant] SELECT name, address_line2, geo_point FROM socialmedia.events;

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

[Assistant] SELECT name, address_line2, geo_point FROM socialmedia.events WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Order the output by updated_at descending.

[Assistant] SELECT name, address_line2, geo_point FROM socialmedia.events WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY updated_at DESC;


[User] Get all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] What geo_point, address_line2, reply_to_id, content do we have for events and their associated messages?

[Assistant] SELECT *, messages.reply_to_id, messages.content FROM socialmedia.events JOIN socialmedia.messages ON events.message_id = messages.content_id;

[User] Tally up events by updated_at.

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


[User] List all likes.

[Assistant] SELECT * FROM socialmedia.likes;

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

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

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

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


[User] What are the name, message_id, address_line2 of each event?

[Assistant] SELECT name, message_id, address_line2 FROM socialmedia.events;

[User] Get all events created yesterday.

[Assistant] SELECT name, message_id, address_line2 FROM socialmedia.events WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Calculate min of name for each name in events.

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


[User] Display all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Show the results sorted by address_line2 ascending.

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

[User] How many events are there per geo_point?

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


[User] List media_url, message_id, visibility from likes.

[Assistant] SELECT media_url, message_id, visibility FROM socialmedia.likes;

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

[Assistant] SELECT media_url, message_id, visibility FROM socialmedia.likes WHERE edited_at > '2023-01-01';

[User] Sort the results by created_at ascending.

[Assistant] SELECT media_url, message_id, visibility FROM socialmedia.likes WHERE edited_at > '2023-01-01' ORDER BY created_at ASC;


[User] Show me message_id, geo_point, updated_at for all events.

[Assistant] SELECT message_id, geo_point, updated_at FROM socialmedia.events;

[User] Order the output by address_line2 ascending.

[Assistant] SELECT message_id, geo_point, updated_at FROM socialmedia.events ORDER BY address_line2 ASC;

[User] Calculate count of geo_point for each updated_at in events.

[Assistant] SELECT updated_at, COUNT(geo_point) AS count_geo_point FROM socialmedia.events GROUP BY updated_at;


[User] Get created_at, keywords, media_url from all likes.

[Assistant] SELECT created_at, keywords, media_url FROM socialmedia.likes;

[User] Retrieve likes where message_id LIKE 'A%'.

[Assistant] SELECT created_at, keywords, media_url FROM socialmedia.likes WHERE message_id LIKE 'A%';

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

[Assistant] SELECT created_at, keywords, media_url FROM socialmedia.likes WHERE message_id LIKE 'A%' ORDER BY media_url ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.shipping (
  sku integer PRIMARY KEY -- unique identifier,
  expires_at date,
  published_at timestamp,
  tax_rate text,
  reserved character varying(128) NOT NULL,
  featured_rank character varying(256),
  categorie_id text NOT NULL -- reference to categories.post_id,
  FOREIGN KEY (categorie_id) REFERENCES categories(post_id)
)

CREATE TABLE e-commerce.inventory (
  item_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  rating text NOT NULL,
  video_url char -- identifier for video_url,
  views character varying(64)
)

CREATE TABLE e-commerce.categories (
  post_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  content character varying(128),
  parent_id character varying(256),
  reply_to_id varchar NOT NULL -- identifier for reply_to,
  shares character varying(256),
  format character varying(256),
  visibility text
)

[User] Get all shipping.

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

[User] Order the output by expires_at ascending.

[Assistant] SELECT * FROM e-commerce.shipping ORDER BY expires_at ASC;

[User] Show the results sorted by categorie_id descending.

[Assistant] SELECT * FROM e-commerce.shipping ORDER BY categorie_id DESC;


[User] Show me tax_rate, featured_rank, published_at for all shipping.

[Assistant] SELECT tax_rate, featured_rank, published_at FROM e-commerce.shipping;

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

[Assistant] SELECT tax_rate, featured_rank, published_at FROM e-commerce.shipping WHERE published_at >= CURRENT_DATE - INTERVAL '30 days';

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

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


[User] List expires_at, published_at, categorie_id from shipping.

[Assistant] SELECT expires_at, published_at, categorie_id FROM e-commerce.shipping;

[User] List shipping that have tax_rate LIKE 'A%'.

[Assistant] SELECT expires_at, published_at, categorie_id FROM e-commerce.shipping WHERE tax_rate LIKE 'A%';

[User] Get sum of published_at by expires_at from shipping.

[Assistant] SELECT expires_at, SUM(published_at) AS sum_published_at FROM e-commerce.shipping GROUP BY expires_at;


[User] List tax_rate, featured_rank, expires_at from shipping.

[Assistant] SELECT tax_rate, featured_rank, expires_at FROM e-commerce.shipping;

[User] Show me expires_at, tax_rate, visibility, shares from shipping and their related categories.

[Assistant] SELECT tax_rate, featured_rank, expires_at, categories.visibility, categories.shares FROM e-commerce.shipping JOIN e-commerce.categories ON shipping.categorie_id = categories.post_id;

[User] Group shipping by reserved and show the sum of expires_at.

[Assistant] SELECT reserved, SUM(expires_at) AS sum_expires_at FROM e-commerce.shipping GROUP BY reserved;


[User] Retrieve all shipping.

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

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

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

[User] Order the output by published_at ascending.

[Assistant] SELECT * FROM e-commerce.shipping WHERE categorie_id LIKE 'A%' ORDER BY published_at ASC;


[User] Display all shipping.

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

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

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

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

[Assistant] SELECT * FROM e-commerce.shipping WHERE published_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY tax_rate DESC;


[User] Retrieve all shipping.

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

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

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

[User] Group shipping by expires_at and show the average of featured_rank.

[Assistant] SELECT expires_at, AVERAGE(featured_rank) AS average_featured_rank FROM e-commerce.shipping GROUP BY expires_at;


[User] Show me featured_rank, reserved, published_at for all shipping.

[Assistant] SELECT featured_rank, reserved, published_at FROM e-commerce.shipping;

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

[Assistant] SELECT featured_rank, reserved, published_at FROM e-commerce.shipping WHERE reserved LIKE 'A%';

[User] Get min of published_at by categorie_id from shipping.

[Assistant] SELECT categorie_id, MIN(published_at) AS min_published_at FROM e-commerce.shipping GROUP BY categorie_id;


[User] Retrieve all shipping.

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

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

[Assistant] SELECT * FROM e-commerce.shipping WHERE expires_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Limit the results to 50 rows.

[Assistant] SELECT * FROM e-commerce.shipping WHERE expires_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 50;


[User] Retrieve reserved, tax_rate, published_at for every shipping.

[Assistant] SELECT reserved, tax_rate, published_at FROM e-commerce.shipping;

[User] Retrieve expires_at, featured_rank, parent_id, shares showing the relationship between shipping and categories.

[Assistant] SELECT reserved, tax_rate, published_at, categories.parent_id, categories.shares FROM e-commerce.shipping JOIN e-commerce.categories ON shipping.categorie_id = categories.post_id;

[User] Only show the top 10 results.

[Assistant] SELECT reserved, tax_rate, published_at, categories.parent_id, categories.shares FROM e-commerce.shipping JOIN e-commerce.categories ON shipping.categorie_id = categories.post_id 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 retail.facilities (
  location_id text PRIMARY KEY -- unique identifier,
  last_inspected timestamp without time zone,
  description character varying(64),
  location_lat character varying(64),
  street varchar,
  latitude varchar NOT NULL,
  postal_code char NOT NULL,
  timezone text NOT NULL,
  longitude character varying(64) NOT NULL,
  sale_id text NOT NULL -- reference to sales.transaction_id,
  FOREIGN KEY (sale_id) REFERENCES sales(transaction_id)
)

CREATE TABLE retail.students (
  customer_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  updated_at timestamp,
  email char,
  gender char,
  membership_level varchar,
  bio character varying(128),
  timezone character varying(64),
  sale_id text NOT NULL -- reference to sales.transaction_id,
  FOREIGN KEY (sale_id) REFERENCES sales(transaction_id)
)

CREATE TABLE retail.sales (
  transaction_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  seller_id character varying(128),
  payment_method character varying(256) NOT NULL,
  fee character varying(64),
  facilitie_id text -- reference to facilities.location_id,
  student_id text NOT NULL -- reference to students.customer_id,
  FOREIGN KEY (facilitie_id) REFERENCES facilities(location_id),
  FOREIGN KEY (student_id) REFERENCES students(customer_id)
)

[User] List all sales.

[Assistant] SELECT * FROM retail.sales;

[User] Get sales that match seller_id LIKE 'A%'.

[Assistant] SELECT * FROM retail.sales WHERE seller_id LIKE 'A%';

[User] Calculate max of seller_id for each student_id in sales.

[Assistant] SELECT student_id, MAX(seller_id) AS max_seller_id FROM retail.sales GROUP BY student_id;


[User] Show me all facilities.

[Assistant] SELECT * FROM retail.facilities;

[User] Sort the results by sale_id descending.

[Assistant] SELECT * FROM retail.facilities ORDER BY sale_id DESC;

[User] Restrict the output to 50 items.

[Assistant] SELECT * FROM retail.facilities ORDER BY sale_id DESC LIMIT 50;


[User] Retrieve all students.

[Assistant] SELECT * FROM retail.students;

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

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

[User] Only show the top 15 results.

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


[User] Display all sales.

[Assistant] SELECT * FROM retail.sales;

[User] Get sales that match facilitie_id LIKE 'A%'.

[Assistant] SELECT * FROM retail.sales WHERE facilitie_id LIKE 'A%';

[User] Calculate count of facilitie_id for each fee in sales.

[Assistant] SELECT fee, COUNT(facilitie_id) AS count_facilitie_id FROM retail.sales GROUP BY fee;


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

[Assistant] SELECT last_inspected, latitude, description FROM retail.facilities;

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

[Assistant] SELECT last_inspected, latitude, description FROM retail.facilities ORDER BY location_lat ASC;

[User] Order the output by description ascending.

[Assistant] SELECT last_inspected, latitude, description FROM retail.facilities ORDER BY description ASC;


[User] Show me all students.

[Assistant] SELECT * FROM retail.students;

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

[Assistant] SELECT * FROM retail.students ORDER BY created_at ASC;

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

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


[User] Get student_id, processed_at, payment_method from all sales.

[Assistant] SELECT student_id, processed_at, payment_method FROM retail.sales;

[User] Sort the results by payment_method ascending.

[Assistant] SELECT student_id, processed_at, payment_method FROM retail.sales ORDER BY payment_method ASC;

[User] How many sales are there per seller_id?

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


[User] List all facilities.

[Assistant] SELECT * FROM retail.facilities;

[User] Show the results sorted by sale_id descending.

[Assistant] SELECT * FROM retail.facilities ORDER BY sale_id DESC;

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

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


[User] List all sales.

[Assistant] SELECT * FROM retail.sales;

[User] Order the output by payment_method descending.

[Assistant] SELECT * FROM retail.sales ORDER BY payment_method DESC;

[User] Show me sum of seller_id grouped by facilitie_id for sales.

[Assistant] SELECT facilitie_id, SUM(seller_id) AS sum_seller_id FROM retail.sales GROUP BY facilitie_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 tradingplatform.orders (
  order_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  subtotal numeric(38,14),
  buyer_id varchar,
  discount integer NOT NULL
)

CREATE TABLE tradingplatform.users (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  first_name char NOT NULL,
  full_name character varying(128),
  state varchar,
  timezone character varying(256) NOT NULL,
  token text NOT NULL,
  order_id text -- reference to orders.order_id,
  FOREIGN KEY (order_id) REFERENCES orders(order_id)
)

[User] Show me id, first_name, token for all users.

[Assistant] SELECT id, first_name, token FROM tradingplatform.users;

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

[Assistant] SELECT id, first_name, token FROM tradingplatform.users ORDER BY full_name DESC;

[User] Show the results sorted by state ascending.

[Assistant] SELECT id, first_name, token FROM tradingplatform.users ORDER BY state ASC;


[User] Retrieve full_name, order_id, state for every user.

[Assistant] SELECT full_name, order_id, state FROM tradingplatform.users;

[User] List id, order_id, discount, subtotal for each user along with their order information.

[Assistant] SELECT full_name, order_id, state, orders.discount, orders.subtotal FROM tradingplatform.users JOIN tradingplatform.orders ON users.order_id = orders.order_id;

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

[Assistant] SELECT timezone, SUM(timezone) AS sum_timezone FROM tradingplatform.users GROUP BY timezone;


[User] Get all users.

[Assistant] SELECT * FROM tradingplatform.users;

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

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

[User] Limit the results to 50 rows.

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


[User] Retrieve all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] What updated_at, order_id, discount, subtotal do we have for users and their associated orders?

[Assistant] SELECT *, orders.discount, orders.subtotal FROM tradingplatform.users JOIN tradingplatform.orders ON users.order_id = orders.order_id;

[User] Can you order these by order_id descending?

[Assistant] SELECT *, orders.discount, orders.subtotal FROM tradingplatform.users JOIN tradingplatform.orders ON users.order_id = orders.order_id ORDER BY order_id DESC;


[User] Retrieve all users.

[Assistant] SELECT * FROM tradingplatform.users;

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

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

[User] Show only 15 records.

[Assistant] SELECT * FROM tradingplatform.users WHERE updated_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 15;


[User] Show me full_name, updated_at, token for all users.

[Assistant] SELECT full_name, updated_at, token FROM tradingplatform.users;

[User] Can you order these by token ascending?

[Assistant] SELECT full_name, updated_at, token FROM tradingplatform.users ORDER BY token ASC;

[User] Show only 5 records.

[Assistant] SELECT full_name, updated_at, token FROM tradingplatform.users ORDER BY token ASC LIMIT 5;


[User] Show me all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] Get all users between January and March.

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

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

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


[User] Get token, order_id, id from all users.

[Assistant] SELECT token, order_id, id FROM tradingplatform.users;

[User] List token, order_id, buyer_id, subtotal for each user along with their order information.

[Assistant] SELECT token, order_id, id, orders.buyer_id, orders.subtotal FROM tradingplatform.users JOIN tradingplatform.orders ON users.order_id = orders.order_id;

[User] Get min of first_name by timezone from users.

[Assistant] SELECT timezone, MIN(first_name) AS min_first_name FROM tradingplatform.users GROUP BY timezone;


[User] Display all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] Show me first_name, token, subtotal, buyer_id from users and their related orders.

[Assistant] SELECT *, orders.subtotal, orders.buyer_id FROM tradingplatform.users JOIN tradingplatform.orders ON users.order_id = orders.order_id;

[User] Group users by order_id and show the min of first_name.

[Assistant] SELECT order_id, MIN(first_name) AS min_first_name FROM tradingplatform.users GROUP BY order_id;


[User] Display all users.

[Assistant] SELECT * FROM tradingplatform.users;

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

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

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE travel.purchases (
  invoice_id text PRIMARY KEY -- unique identifier,
  cancelled_at timestamp without time zone,
  approval_status character varying(64),
  payment_method char,
  status character varying(128),
  subtotal numeric(38,14) NOT NULL,
  product_id character varying(128),
  currency char,
  patient_id text -- reference to patients.person_id,
  FOREIGN KEY (patient_id) REFERENCES patients(person_id)
)

CREATE TABLE travel.stores (
  location_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  last_inspected timestamp without time zone,
  capacity character varying(64) NOT NULL,
  description text,
  name text NOT NULL,
  purchase_id text -- reference to purchases.invoice_id,
  FOREIGN KEY (purchase_id) REFERENCES purchases(invoice_id)
)

CREATE TABLE travel.patients (
  person_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  status text,
  token char NOT NULL,
  last_name character varying(128) NOT NULL,
  country char,
  purchase_id text -- reference to purchases.invoice_id,
  FOREIGN KEY (purchase_id) REFERENCES purchases(invoice_id)
)

[User] Retrieve all patients.

[Assistant] SELECT * FROM travel.patients;

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

[Assistant] SELECT * FROM travel.patients WHERE last_name LIKE 'A%';

[User] How many patients are there per purchase_id?

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


[User] Retrieve all purchases.

[Assistant] SELECT * FROM travel.purchases;

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

[Assistant] SELECT * FROM travel.purchases ORDER BY cancelled_at DESC;

[User] Only show the top 100 results.

[Assistant] SELECT * FROM travel.purchases ORDER BY cancelled_at DESC LIMIT 100;


[User] What are the name, purchase_id, created_at of each store?

[Assistant] SELECT name, purchase_id, created_at FROM travel.stores;

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

[Assistant] SELECT name, purchase_id, created_at FROM travel.stores WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Restrict the output to 25 items.

[Assistant] SELECT name, purchase_id, created_at FROM travel.stores WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 25;


[User] List approval_status, status, cancelled_at from purchases.

[Assistant] SELECT approval_status, status, cancelled_at FROM travel.purchases;

[User] Show me patient_id, cancelled_at, purchase_id, last_name from purchases and their related patients.

[Assistant] SELECT approval_status, status, cancelled_at, patients.purchase_id, patients.last_name FROM travel.purchases JOIN travel.patients ON purchases.patient_id = patients.person_id;

[User] How many purchases are there per subtotal?

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


[User] Retrieve all purchases.

[Assistant] SELECT * FROM travel.purchases;

[User] Show me patient_id, approval_status, updated_at, last_name from purchases and their related patients.

[Assistant] SELECT *, patients.updated_at, patients.last_name FROM travel.purchases JOIN travel.patients ON purchases.patient_id = patients.person_id;

[User] Get the distribution of purchases across different patient_id values.

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


[User] List token, purchase_id, last_name from patients.

[Assistant] SELECT token, purchase_id, last_name FROM travel.patients;

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

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

[User] Limit the results to 100 rows.

[Assistant] SELECT token, purchase_id, last_name FROM travel.patients WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 100;


[User] Get all stores.

[Assistant] SELECT * FROM travel.stores;

[User] Show me purchase_id, location_id, subtotal, approval_status from stores and their related purchases.

[Assistant] SELECT *, purchases.subtotal, purchases.approval_status FROM travel.stores JOIN travel.purchases ON stores.purchase_id = purchases.invoice_id;

[User] Only show the top 100 results.

[Assistant] SELECT *, purchases.subtotal, purchases.approval_status FROM travel.stores JOIN travel.purchases ON stores.purchase_id = purchases.invoice_id LIMIT 100;


[User] Retrieve all purchases.

[Assistant] SELECT * FROM travel.purchases;

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

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

[User] Show only 50 records.

[Assistant] SELECT * FROM travel.purchases WHERE cancelled_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 50;


[User] List payment_method, approval_status, status from purchases.

[Assistant] SELECT payment_method, approval_status, status FROM travel.purchases;

[User] Order the output by patient_id ascending.

[Assistant] SELECT payment_method, approval_status, status FROM travel.purchases ORDER BY patient_id ASC;

[User] Calculate min of approval_status for each currency in purchases.

[Assistant] SELECT currency, MIN(approval_status) AS min_approval_status FROM travel.purchases GROUP BY currency;


[User] Get all patients.

[Assistant] SELECT * FROM travel.patients;

[User] Can you order these by purchase_id ascending?

[Assistant] SELECT * FROM travel.patients ORDER BY purchase_id ASC;

[User] Get count of token by status from patients.

[Assistant] SELECT status, COUNT(token) AS count_token FROM travel.patients GROUP BY status;


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.venues (
  store_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  city character varying(128),
  address_line1 character varying(256),
  coordinates character varying(256),
  address_line2 character varying(64) NOT NULL,
  accessibility character varying(128),
  parking_available char
)

CREATE TABLE travel.purchases (
  order_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  created_at timestamp,
  status character varying(128),
  amount integer,
  card_type character varying(64) NOT NULL
)

CREATE TABLE travel.students (
  customer_id character varying(64) NOT NULL -- unique identifier,
  joined_at date,
  last_active date,
  timezone char,
  password_hash character varying(64) NOT NULL,
  city character varying(64)
)

[User] Display all purchases.

[Assistant] SELECT * FROM travel.purchases;

[User] Order the output by order_id ascending.

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

[User] Sort the results by updated_at descending.

[Assistant] SELECT * FROM travel.purchases ORDER BY updated_at DESC;


[User] Retrieve all venues.

[Assistant] SELECT * FROM travel.venues;

[User] Sort the results by address_line2 ascending.

[Assistant] SELECT * FROM travel.venues ORDER BY address_line2 ASC;

[User] How many venues are there per parking_available?

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


[User] Show me city, password_hash, timezone for all students.

[Assistant] SELECT city, password_hash, timezone FROM travel.students;

[User] List students with dates created yesterday.

[Assistant] SELECT city, password_hash, timezone FROM travel.students WHERE joined_at = CURRENT_DATE - INTERVAL '1 day';

[User] Only show the top 25 results.

[Assistant] SELECT city, password_hash, timezone FROM travel.students WHERE joined_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 25;


[User] List card_type, order_id, status from purchases.

[Assistant] SELECT card_type, order_id, status FROM travel.purchases;

[User] Can you order these by order_id descending?

[Assistant] SELECT card_type, order_id, status FROM travel.purchases ORDER BY order_id DESC;

[User] Group purchases by updated_at and show the average of status.

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


[User] List all venues.

[Assistant] SELECT * FROM travel.venues;

[User] Sort the results by store_id descending.

[Assistant] SELECT * FROM travel.venues ORDER BY store_id DESC;

[User] Group venues by accessibility and show the average of address_line1.

[Assistant] SELECT accessibility, AVERAGE(address_line1) AS average_address_line1 FROM travel.venues GROUP BY accessibility;


[User] List timezone, last_active, password_hash from students.

[Assistant] SELECT timezone, last_active, password_hash FROM travel.students;

[User] List students that have last_active > '2023-01-01'.

[Assistant] SELECT timezone, last_active, password_hash FROM travel.students WHERE last_active > '2023-01-01';

[User] Tally up students by joined_at.

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