[User] Retrieve all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

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

[Assistant] SELECT address, SUM(website) AS sum_website FROM finance.customers GROUP BY address;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.grades (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at timestamp without time zone,
  backorder character varying(64),
  category text NOT NULL,
  image_url character varying(256) NOT NULL,
  stock_level character varying(128)
)

CREATE TABLE education.courses (
  person_id character varying(64) NOT NULL -- unique identifier,
  last_active date,
  bio char,
  is_active bit NOT NULL,
  address character varying(128),
  grade_id text -- reference to grades.id,
  FOREIGN KEY (grade_id) REFERENCES grades(id)
)

[User] Retrieve all courses.

[Assistant] SELECT * FROM education.courses;

[User] List bio, last_active, updated_at, backorder for each course along with their grade information.

[Assistant] SELECT *, grades.updated_at, grades.backorder FROM education.courses JOIN education.grades ON courses.grade_id = grades.id;

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

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


[User] Get all courses.

[Assistant] SELECT * FROM education.courses;

[User] Get courses that match last_active > '2023-01-01'.

[Assistant] SELECT * FROM education.courses WHERE last_active > '2023-01-01';

[User] What is the max person_id for each address in courses?

[Assistant] SELECT address, MAX(person_id) AS max_person_id FROM education.courses GROUP BY address;


[User] Get person_id, is_active, last_active from all courses.

[Assistant] SELECT person_id, is_active, last_active FROM education.courses;

[User] Get person_id, last_active, image_url, updated_at by joining courses with grades.

[Assistant] SELECT person_id, is_active, last_active, grades.image_url, grades.updated_at FROM education.courses JOIN education.grades ON courses.grade_id = grades.id;

[User] Group courses by is_active and show the count of last_active.

[Assistant] SELECT is_active, COUNT(last_active) AS count_last_active FROM education.courses GROUP BY is_active;


[User] Show me is_active, bio, person_id for all courses.

[Assistant] SELECT is_active, bio, person_id FROM education.courses;

[User] List address, person_id, category, stock_level for each course along with their grade information.

[Assistant] SELECT is_active, bio, person_id, grades.category, grades.stock_level FROM education.courses JOIN education.grades ON courses.grade_id = grades.id;

[User] Group courses by person_id and show the sum of last_active.

[Assistant] SELECT person_id, SUM(last_active) AS sum_last_active FROM education.courses GROUP BY person_id;


[User] Show me bio, person_id, last_active for all courses.

[Assistant] SELECT bio, person_id, last_active FROM education.courses;

[User] Get courses that match grade_id LIKE 'A%'.

[Assistant] SELECT bio, person_id, last_active FROM education.courses WHERE grade_id LIKE 'A%';

[User] Only show the top 15 results.

[Assistant] SELECT bio, person_id, last_active FROM education.courses WHERE grade_id LIKE 'A%' LIMIT 15;


[User] Display all courses.

[Assistant] SELECT * FROM education.courses;

[User] Get courses that match is_active = TRUE.

[Assistant] SELECT * FROM education.courses WHERE is_active = TRUE;

[User] Order the output by grade_id descending.

[Assistant] SELECT * FROM education.courses WHERE is_active = TRUE ORDER BY grade_id DESC;


[User] What are the is_active, address, person_id of each course?

[Assistant] SELECT is_active, address, person_id FROM education.courses;

[User] Can you order these by grade_id ascending?

[Assistant] SELECT is_active, address, person_id FROM education.courses ORDER BY grade_id ASC;

[User] Order the output by bio descending.

[Assistant] SELECT is_active, address, person_id FROM education.courses ORDER BY bio DESC;


[User] List address, last_active, grade_id from courses.

[Assistant] SELECT address, last_active, grade_id FROM education.courses;

[User] Get courses that match person_id LIKE 'A%'.

[Assistant] SELECT address, last_active, grade_id FROM education.courses WHERE person_id LIKE 'A%';

[User] Only show the top 25 results.

[Assistant] SELECT address, last_active, grade_id FROM education.courses WHERE person_id LIKE 'A%' LIMIT 25;


[User] Show me grade_id, last_active, bio for all courses.

[Assistant] SELECT grade_id, last_active, bio FROM education.courses;

[User] Get address, last_active, created_at, image_url by joining courses with grades.

[Assistant] SELECT grade_id, last_active, bio, grades.created_at, grades.image_url FROM education.courses JOIN education.grades ON courses.grade_id = grades.id;

[User] Tally up courses by last_active.

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


[User] Display all courses.

[Assistant] SELECT * FROM education.courses;

[User] Order the output by last_active descending.

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

[User] Only show the top 15 results.

[Assistant] SELECT * FROM education.courses ORDER BY last_active DESC LIMIT 15;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.reviews (
  content_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  published_at timestamp without time zone,
  author_id char,
  body character varying(128),
  format character varying(128),
  shippin_id text NOT NULL -- reference to shipping.message_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(message_id)
)

CREATE TABLE e-commerce.shipping (
  message_id text PRIMARY KEY -- unique identifier,
  edited_at date,
  reply_to_id character varying(64),
  keywords char,
  format character varying(128)
)

[User] Show me published_at, created_at, author_id for all reviews.

[Assistant] SELECT published_at, created_at, author_id FROM e-commerce.reviews;

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

[Assistant] SELECT published_at, created_at, author_id FROM e-commerce.reviews WHERE body LIKE 'A%';

[User] Get average of body by author_id from reviews.

[Assistant] SELECT author_id, AVERAGE(body) AS average_body FROM e-commerce.reviews GROUP BY author_id;


[User] Get all reviews.

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

[User] Can you order these by format descending?

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

[User] Order the output by format ascending.

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


[User] List format, author_id, created_at from reviews.

[Assistant] SELECT format, author_id, created_at FROM e-commerce.reviews;

[User] List format, shippin_id, reply_to_id, keywords for each review along with their shipping information.

[Assistant] SELECT format, author_id, created_at, shipping.reply_to_id, shipping.keywords FROM e-commerce.reviews JOIN e-commerce.shipping ON reviews.shippin_id = shipping.message_id;

[User] Count the number of reviews in each author_id category.

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


[User] List format, author_id, created_at from reviews.

[Assistant] SELECT format, author_id, created_at FROM e-commerce.reviews;

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

[Assistant] SELECT format, author_id, created_at FROM e-commerce.reviews WHERE published_at > '2023-12-01';

[User] Tally up reviews by shippin_id.

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


[User] List published_at, author_id, shippin_id from reviews.

[Assistant] SELECT published_at, author_id, shippin_id FROM e-commerce.reviews;

[User] List reviews that have shippin_id LIKE 'A%'.

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

[User] Limit the results to 20 rows.

[Assistant] SELECT published_at, author_id, shippin_id FROM e-commerce.reviews WHERE shippin_id LIKE 'A%' LIMIT 20;


[User] Display all reviews.

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

[User] List reviews that have published_at > '2023-01-01'.

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

[User] Show only 10 records.

[Assistant] SELECT * FROM e-commerce.reviews WHERE published_at > '2023-01-01' LIMIT 10;


[User] List all reviews.

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

[User] List format, author_id, format, reply_to_id for each review along with their shipping information.

[Assistant] SELECT *, shipping.format, shipping.reply_to_id FROM e-commerce.reviews JOIN e-commerce.shipping ON reviews.shippin_id = shipping.message_id;

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

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


[User] Show me all reviews.

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

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

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

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

[Assistant] SELECT * FROM e-commerce.reviews WHERE published_at > '2023-12-01' ORDER BY author_id ASC;


[User] Retrieve all reviews.

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

[User] Get reviews that match published_at > '2023-01-01'.

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

[User] Calculate max of body for each shippin_id in reviews.

[Assistant] SELECT shippin_id, MAX(body) AS max_body FROM e-commerce.reviews GROUP BY shippin_id;


[User] Show me created_at, format, body for all reviews.

[Assistant] SELECT created_at, format, body FROM e-commerce.reviews;

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

[Assistant] SELECT created_at, format, body FROM e-commerce.reviews WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Limit the results to 20 rows.

[Assistant] SELECT created_at, format, body FROM e-commerce.reviews WHERE created_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 20;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.inventory (
  barcode text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  expires_at timestamp,
  currency character varying(256),
  media_url character varying(256) NOT NULL,
  manufacturer char NOT NULL,
  backorder text NOT NULL,
  rating varchar NOT NULL,
  subcategory varchar,
  user_id text -- reference to users.employee_id,
  FOREIGN KEY (user_id) REFERENCES users(employee_id)
)

CREATE TABLE e-commerce.users (
  employee_id text PRIMARY KEY -- unique identifier,
  joined_at date,
  nationality character varying(128),
  membership_level char,
  full_name character varying(64) NOT NULL,
  language text,
  is_active bit -- indicates if active is true,
  salt character varying(64)
)

CREATE TABLE e-commerce.products (
  item_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp without time zone,
  expires_at date,
  popularity_score char,
  video_url character varying(64),
  category char,
  tax_rate char,
  title varchar,
  stock_level char,
  cost bigint NOT NULL,
  inventor_id text NOT NULL -- reference to inventory.barcode,
  shippin_id text -- reference to shipping.barcode,
  FOREIGN KEY (inventor_id) REFERENCES inventory(barcode),
  FOREIGN KEY (shippin_id) REFERENCES shipping(barcode)
)

CREATE TABLE e-commerce.shipping (
  barcode text PRIMARY KEY -- unique identifier,
  published_at timestamp,
  updated_at date,
  image_url character varying(128),
  brand varchar,
  featured_rank varchar NOT NULL,
  reserved char
)

[User] List all inventory.

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

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

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

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM e-commerce.inventory ORDER BY subcategory DESC LIMIT 10;


[User] Display all inventory.

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

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

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

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.loans (
  address_id character varying(64) NOT NULL -- unique identifier,
  last_inspected timestamp without time zone,
  created_at date,
  street character varying(256) NOT NULL,
  geo_point character varying(128),
  capacity character varying(64),
  country character varying(64),
  operating_hours varchar
)

CREATE TABLE finance.customers (
  customer_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  account_status character varying(128),
  zip_code character varying(256)
)

[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Get min of account_status by account_status from customers.

[Assistant] SELECT account_status, MIN(account_status) AS min_account_status FROM finance.customers GROUP BY account_status;


[User] List all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Show me max of created_at grouped by customer_id for customers.

[Assistant] SELECT customer_id, MAX(created_at) AS max_created_at FROM finance.customers GROUP BY customer_id;


[User] List all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Can you order these by address_id descending?

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

[User] Show only 15 records.

[Assistant] SELECT * FROM finance.loans ORDER BY address_id DESC LIMIT 15;


[User] Retrieve last_inspected, created_at, capacity for every loan.

[Assistant] SELECT last_inspected, created_at, capacity FROM finance.loans;

[User] Can you order these by last_inspected ascending?

[Assistant] SELECT last_inspected, created_at, capacity FROM finance.loans ORDER BY last_inspected ASC;

[User] Limit the results to 10 rows.

[Assistant] SELECT last_inspected, created_at, capacity FROM finance.loans ORDER BY last_inspected ASC LIMIT 10;


[User] Show me zip_code, customer_id, account_status for all customers.

[Assistant] SELECT zip_code, customer_id, account_status FROM finance.customers;

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

[Assistant] SELECT zip_code, customer_id, account_status FROM finance.customers WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

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

[Assistant] SELECT zip_code, customer_id, account_status FROM finance.customers WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY account_status ASC;


[User] Show me all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Only show the top 25 results.

[Assistant] SELECT * FROM finance.customers WHERE customer_id LIKE 'A%' LIMIT 25;


[User] Get created_at, customer_id, zip_code from all customers.

[Assistant] SELECT created_at, customer_id, zip_code FROM finance.customers;

[User] Sort the results by account_status ascending.

[Assistant] SELECT created_at, customer_id, zip_code FROM finance.customers ORDER BY account_status ASC;

[User] Get the distribution of customers across different account_status values.

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


[User] List created_at, customer_id, zip_code from customers.

[Assistant] SELECT created_at, customer_id, zip_code FROM finance.customers;

[User] Get all customers created yesterday.

[Assistant] SELECT created_at, customer_id, zip_code FROM finance.customers WHERE created_at = CURRENT_DATE - INTERVAL '1 day';

[User] Show only 10 records.

[Assistant] SELECT created_at, customer_id, zip_code FROM finance.customers WHERE created_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 10;


[User] List all loans.

[Assistant] SELECT * FROM finance.loans;

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

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

[User] Sort the results by last_inspected ascending.

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


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Calculate max of created_at for each zip_code in customers.

[Assistant] SELECT zip_code, MAX(created_at) AS max_created_at FROM finance.customers GROUP BY zip_code;


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 (
  product_id integer PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  created_at date,
  reserved character varying(256),
  price decimal,
  quantity varchar,
  title character varying(256)
)

CREATE TABLE socialmedia.likes (
  item_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  discount numeric(38,14),
  tax_rate character varying(256),
  featured_rank char NOT NULL,
  follower_id text NOT NULL -- reference to followers.venue_id,
  event_id integer -- reference to events.product_id,
  FOREIGN KEY (follower_id) REFERENCES followers(venue_id),
  FOREIGN KEY (event_id) REFERENCES events(product_id)
)

CREATE TABLE socialmedia.followers (
  venue_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  capacity character varying(256),
  address_line1 text NOT NULL,
  location_lon text,
  operating_hours character varying(128) NOT NULL,
  event_id integer -- reference to events.product_id,
  FOREIGN KEY (event_id) REFERENCES events(product_id)
)

[User] Show me operating_hours, event_id, capacity for all followers.

[Assistant] SELECT operating_hours, event_id, capacity FROM socialmedia.followers;

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

[Assistant] SELECT operating_hours, event_id, capacity FROM socialmedia.followers WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Only show the top 25 results.

[Assistant] SELECT operating_hours, event_id, capacity FROM socialmedia.followers WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 25;


[User] List event_id, updated_at, address_line1 from followers.

[Assistant] SELECT event_id, updated_at, address_line1 FROM socialmedia.followers;

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

[Assistant] SELECT event_id, updated_at, address_line1 FROM socialmedia.followers WHERE address_line1 LIKE 'A%';

[User] Show the results sorted by location_lon descending.

[Assistant] SELECT event_id, updated_at, address_line1 FROM socialmedia.followers WHERE address_line1 LIKE 'A%' ORDER BY location_lon DESC;


[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Show me followers with event_id > 90.

[Assistant] SELECT * FROM socialmedia.followers WHERE event_id > 90;

[User] Limit the results to 15 rows.

[Assistant] SELECT * FROM socialmedia.followers WHERE event_id > 90 LIMIT 15;


[User] Retrieve location_lon, updated_at, event_id for every follower.

[Assistant] SELECT location_lon, updated_at, event_id FROM socialmedia.followers;

[User] List followers with dates from last week.

[Assistant] SELECT location_lon, updated_at, event_id FROM socialmedia.followers WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

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

[Assistant] SELECT location_lon, updated_at, event_id FROM socialmedia.followers WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY operating_hours DESC;


[User] Display all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Show the results sorted by discount descending.

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

[User] Show the results sorted by updated_at ascending.

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


[User] Get address_line1, location_lon, updated_at from all followers.

[Assistant] SELECT address_line1, location_lon, updated_at FROM socialmedia.followers;

[User] Get followers that match location_lon LIKE 'A%'.

[Assistant] SELECT address_line1, location_lon, updated_at FROM socialmedia.followers WHERE location_lon LIKE 'A%';

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

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


[User] Show me tax_rate, updated_at, item_id for all likes.

[Assistant] SELECT tax_rate, updated_at, item_id FROM socialmedia.likes;

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

[Assistant] SELECT tax_rate, updated_at, item_id FROM socialmedia.likes WHERE item_id LIKE 'A%';

[User] Limit the results to 5 rows.

[Assistant] SELECT tax_rate, updated_at, item_id FROM socialmedia.likes WHERE item_id LIKE 'A%' LIMIT 5;


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] List location_lon, capacity, quantity, reserved for each follower along with their event information.

[Assistant] SELECT *, events.quantity, events.reserved FROM socialmedia.followers JOIN socialmedia.events ON followers.event_id = events.product_id;

[User] Only show the top 5 results.

[Assistant] SELECT *, events.quantity, events.reserved FROM socialmedia.followers JOIN socialmedia.events ON followers.event_id = events.product_id LIMIT 5;


[User] List updated_at, location_lon, operating_hours from followers.

[Assistant] SELECT updated_at, location_lon, operating_hours FROM socialmedia.followers;

[User] Get followers that match event_id > 78.

[Assistant] SELECT updated_at, location_lon, operating_hours FROM socialmedia.followers WHERE event_id > 78;

[User] Order the output by capacity ascending.

[Assistant] SELECT updated_at, location_lon, operating_hours FROM socialmedia.followers WHERE event_id > 78 ORDER BY capacity ASC;


[User] What are the event_id, updated_at, featured_rank of each like?

[Assistant] SELECT event_id, updated_at, featured_rank FROM socialmedia.likes;

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

[Assistant] SELECT event_id, updated_at, featured_rank FROM socialmedia.likes WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Can you order these by updated_at descending?

[Assistant] SELECT event_id, updated_at, featured_rank FROM socialmedia.likes WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY updated_at DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.grades (
  product_id varchar PRIMARY KEY -- unique identifier,
  expires_at timestamp,
  created_at timestamp,
  rating char,
  backorder character varying(64),
  featured_rank character varying(128),
  teacher_id text -- reference to teachers.venue_id,
  FOREIGN KEY (teacher_id) REFERENCES teachers(venue_id)
)

CREATE TABLE education.teachers (
  venue_id text PRIMARY KEY -- unique identifier,
  last_inspected timestamp without time zone,
  timezone char,
  description varchar
)

[User] What are the backorder, created_at, teacher_id of each grade?

[Assistant] SELECT backorder, created_at, teacher_id FROM education.grades;

[User] Order the output by rating descending.

[Assistant] SELECT backorder, created_at, teacher_id FROM education.grades ORDER BY rating DESC;

[User] Group grades by featured_rank and show the count of backorder.

[Assistant] SELECT featured_rank, COUNT(backorder) AS count_backorder FROM education.grades GROUP BY featured_rank;


[User] What are the backorder, expires_at, teacher_id of each grade?

[Assistant] SELECT backorder, expires_at, teacher_id FROM education.grades;

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

[Assistant] SELECT backorder, expires_at, teacher_id FROM education.grades WHERE expires_at > '2023-12-01';

[User] Tally up grades by expires_at.

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


[User] Get all grades.

[Assistant] SELECT * FROM education.grades;

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

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

[User] Show me min of featured_rank grouped by backorder for grades.

[Assistant] SELECT backorder, MIN(featured_rank) AS min_featured_rank FROM education.grades GROUP BY backorder;


[User] Display all grades.

[Assistant] SELECT * FROM education.grades;

[User] Retrieve backorder, created_at, description, timezone showing the relationship between grades and teachers.

[Assistant] SELECT *, teachers.description, teachers.timezone FROM education.grades JOIN education.teachers ON grades.teacher_id = teachers.venue_id;

[User] Get min of created_at by expires_at from grades.

[Assistant] SELECT expires_at, MIN(created_at) AS min_created_at FROM education.grades GROUP BY expires_at;


[User] What are the expires_at, backorder, rating of each grade?

[Assistant] SELECT expires_at, backorder, rating FROM education.grades;

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

[Assistant] SELECT expires_at, backorder, rating FROM education.grades WHERE backorder LIKE 'A%';

[User] Only show the top 25 results.

[Assistant] SELECT expires_at, backorder, rating FROM education.grades WHERE backorder LIKE 'A%' LIMIT 25;


[User] Get all grades.

[Assistant] SELECT * FROM education.grades;

[User] Retrieve rating, expires_at, description, timezone showing the relationship between grades and teachers.

[Assistant] SELECT *, teachers.description, teachers.timezone FROM education.grades JOIN education.teachers ON grades.teacher_id = teachers.venue_id;

[User] Show only 15 records.

[Assistant] SELECT *, teachers.description, teachers.timezone FROM education.grades JOIN education.teachers ON grades.teacher_id = teachers.venue_id LIMIT 15;


[User] What are the teacher_id, rating, featured_rank of each grade?

[Assistant] SELECT teacher_id, rating, featured_rank FROM education.grades;

[User] Get rating, featured_rank, description, timezone by joining grades with teachers.

[Assistant] SELECT teacher_id, rating, featured_rank, teachers.description, teachers.timezone FROM education.grades JOIN education.teachers ON grades.teacher_id = teachers.venue_id;

[User] Tally up grades by created_at.

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


[User] Retrieve all grades.

[Assistant] SELECT * FROM education.grades;

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

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

[User] Order the output by created_at ascending.

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


[User] List all grades.

[Assistant] SELECT * FROM education.grades;

[User] Order the output by backorder descending.

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

[User] Show me sum of rating grouped by teacher_id for grades.

[Assistant] SELECT teacher_id, SUM(rating) AS sum_rating FROM education.grades GROUP BY teacher_id;


[User] List backorder, created_at, featured_rank from grades.

[Assistant] SELECT backorder, created_at, featured_rank FROM education.grades;

[User] Show me created_at, expires_at, last_inspected, timezone from grades and their related teachers.

[Assistant] SELECT backorder, created_at, featured_rank, teachers.last_inspected, teachers.timezone FROM education.grades JOIN education.teachers ON grades.teacher_id = teachers.venue_id;

[User] Can you order these by featured_rank descending?

[Assistant] SELECT backorder, created_at, featured_rank, teachers.last_inspected, teachers.timezone FROM education.grades JOIN education.teachers ON grades.teacher_id = teachers.venue_id ORDER BY featured_rank DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE transportation.billing (
  invoice_id integer PRIMARY KEY -- unique identifier,
  due_date date,
  vendor_id character varying(256) -- identifier for vendor,
  currency character varying(256) NOT NULL,
  payee_id char -- identifier for payee,
  verification_status character varying(256) NOT NULL,
  booking_id integer NOT NULL -- reference to bookings.payment_id,
  FOREIGN KEY (booking_id) REFERENCES bookings(payment_id)
)

CREATE TABLE transportation.members (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  joined_at date,
  membership_level character varying(64) NOT NULL,
  account_status char,
  last_login timestamp without time zone,
  state character varying(64) NOT NULL,
  website character varying(128),
  country character varying(256),
  username varchar
)

CREATE TABLE transportation.comments (
  id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  categories text,
  message varchar,
  keywords character varying(128) NOT NULL,
  booking_id integer NOT NULL -- reference to bookings.payment_id,
  member_id text -- reference to members.id,
  FOREIGN KEY (booking_id) REFERENCES bookings(payment_id),
  FOREIGN KEY (member_id) REFERENCES members(id)
)

CREATE TABLE transportation.bookings (
  payment_id integer PRIMARY KEY -- unique identifier,
  cancelled_at date,
  processed_at timestamp,
  card_type varchar NOT NULL,
  tax numeric(38,14),
  payment_method varchar,
  status text,
  account_id text NOT NULL
)

[User] Get all comments.

[Assistant] SELECT * FROM transportation.comments;

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

[Assistant] SELECT * FROM transportation.comments WHERE member_id LIKE 'A%';

[User] Get average of message by message from comments.

[Assistant] SELECT message, AVERAGE(message) AS average_message FROM transportation.comments GROUP BY message;


[User] Display all billing.

[Assistant] SELECT * FROM transportation.billing;

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

[Assistant] SELECT * FROM transportation.billing WHERE currency LIKE 'A%';

[User] Limit the results to 10 rows.

[Assistant] SELECT * FROM transportation.billing WHERE currency LIKE 'A%' LIMIT 10;


[User] List all billing.

[Assistant] SELECT * FROM transportation.billing;

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

[Assistant] SELECT * FROM transportation.billing WHERE currency LIKE 'A%';

[User] Show only 15 records.

[Assistant] SELECT * FROM transportation.billing WHERE currency LIKE 'A%' LIMIT 15;


[User] List all comments.

[Assistant] SELECT * FROM transportation.comments;

[User] Retrieve comments where booking_id > 30.

[Assistant] SELECT * FROM transportation.comments WHERE booking_id > 30;

[User] Group comments by categories and show the count of member_id.

[Assistant] SELECT categories, COUNT(member_id) AS count_member_id FROM transportation.comments 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 healthcare.medical_records (
  sku text PRIMARY KEY -- unique identifier,
  published_at date,
  image_url character varying(256) NOT NULL,
  backorder varchar NOT NULL,
  stock_level character varying(256),
  rating text
)

CREATE TABLE healthcare.departments (
  message_id text PRIMARY KEY -- unique identifier,
  edited_at timestamp without time zone,
  reply_to_id varchar,
  image_url character varying(64),
  author_id character varying(256) -- identifier for author,
  keywords varchar,
  body character varying(64),
  attachment_url text,
  patient_id integer NOT NULL -- reference to patients.user_id,
  medical_record_id text -- reference to medical_records.sku,
  FOREIGN KEY (patient_id) REFERENCES patients(user_id),
  FOREIGN KEY (medical_record_id) REFERENCES medical_records(sku)
)

CREATE TABLE healthcare.appointments (
  id character varying(64) NOT NULL -- unique identifier,
  edited_at timestamp without time zone,
  published_at timestamp,
  thumbnail varchar,
  score character varying(64) NOT NULL,
  content text NOT NULL,
  reply_to_id character varying(128) -- identifier for reply_to,
  shares character varying(256),
  media_url char NOT NULL,
  patient_id integer -- reference to patients.user_id,
  FOREIGN KEY (patient_id) REFERENCES patients(user_id)
)

CREATE TABLE healthcare.patients (
  user_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  gender character varying(128),
  country character varying(256) NOT NULL,
  nationality character varying(64)
)

[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

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

[Assistant] SELECT * FROM healthcare.appointments WHERE id LIKE 'A%';

[User] Order the output by id ascending.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.reviews (
  id integer PRIMARY KEY -- unique identifier,
  created_at date,
  updated_at timestamp,
  shares text NOT NULL,
  author_id char -- identifier for author,
  media_url character varying(256),
  categories char,
  rating char,
  shippin_id text -- reference to shipping.account_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(account_id)
)

CREATE TABLE e-commerce.shipping (
  account_id varchar PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  notes character varying(64),
  payer_id varchar NOT NULL -- identifier for payer,
  reference_number char NOT NULL
)

[User] Retrieve all reviews.

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

[User] Retrieve created_at, author_id, payer_id, notes showing the relationship between reviews and shipping.

[Assistant] SELECT *, shipping.payer_id, shipping.notes FROM e-commerce.reviews JOIN e-commerce.shipping ON reviews.shippin_id = shipping.account_id;

[User] Can you order these by author_id ascending?

[Assistant] SELECT *, shipping.payer_id, shipping.notes FROM e-commerce.reviews JOIN e-commerce.shipping ON reviews.shippin_id = shipping.account_id ORDER BY author_id ASC;


[User] What are the shippin_id, rating, categories of each review?

[Assistant] SELECT shippin_id, rating, categories FROM e-commerce.reviews;

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

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

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

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


[User] Get rating, author_id, updated_at from all reviews.

[Assistant] SELECT rating, author_id, updated_at FROM e-commerce.reviews;

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

[Assistant] SELECT rating, author_id, updated_at FROM e-commerce.reviews WHERE author_id LIKE 'A%';

[User] Restrict the output to 50 items.

[Assistant] SELECT rating, author_id, updated_at FROM e-commerce.reviews WHERE author_id LIKE 'A%' LIMIT 50;


[User] Show me all reviews.

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

[User] Order the output by media_url descending.

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

[User] Count the number of reviews in each shippin_id category.

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


[User] List all reviews.

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

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

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

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

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


[User] Display all reviews.

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

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

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

[User] Can you order these by created_at ascending?

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


[User] Show me all reviews.

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

[User] Find reviews between January and March.

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

[User] Return just 25 rows.

[Assistant] SELECT * FROM e-commerce.reviews WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 25;


[User] Get updated_at, author_id, created_at from all reviews.

[Assistant] SELECT updated_at, author_id, created_at FROM e-commerce.reviews;

[User] List reviews with dates created yesterday.

[Assistant] SELECT updated_at, author_id, created_at FROM e-commerce.reviews WHERE created_at = CURRENT_DATE - INTERVAL '1 day';

[User] Show only 15 records.

[Assistant] SELECT updated_at, author_id, created_at FROM e-commerce.reviews WHERE created_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 15;


[User] Retrieve all reviews.

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

[User] Get all reviews created yesterday.

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

[User] Tally up reviews by shippin_id.

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


[User] List author_id, media_url, categories from reviews.

[Assistant] SELECT author_id, media_url, categories FROM e-commerce.reviews;

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

[Assistant] SELECT author_id, media_url, categories FROM e-commerce.reviews WHERE rating LIKE 'A%';

[User] Count the number of reviews in each shares category.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.events (
  sku varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  thumbnail_url character varying(64),
  rating character varying(128),
  title character varying(128),
  comment_id text NOT NULL -- reference to comments.comment_id,
  FOREIGN KEY (comment_id) REFERENCES comments(comment_id)
)

CREATE TABLE socialmedia.messages (
  message_id varchar PRIMARY KEY -- unique identifier,
  published_at date,
  user_id char -- identifier for user,
  subject character varying(256) NOT NULL,
  description char,
  attachment_url char,
  message char,
  format varchar,
  event_id text NOT NULL -- reference to events.sku,
  FOREIGN KEY (event_id) REFERENCES events(sku)
)

CREATE TABLE socialmedia.comments (
  comment_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at date,
  rating char NOT NULL,
  image_url varchar NOT NULL,
  views varchar,
  event_id text -- reference to events.sku,
  message_id text NOT NULL -- reference to messages.message_id,
  FOREIGN KEY (event_id) REFERENCES events(sku),
  FOREIGN KEY (message_id) REFERENCES messages(message_id)
)

[User] Retrieve all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] What description, subject, title, updated_at do we have for messages and their associated events?

[Assistant] SELECT *, events.title, events.updated_at FROM socialmedia.messages JOIN socialmedia.events ON messages.event_id = events.sku;

[User] Return just 10 rows.

[Assistant] SELECT *, events.title, events.updated_at FROM socialmedia.messages JOIN socialmedia.events ON messages.event_id = events.sku LIMIT 10;


[User] What are the created_at, updated_at, rating of each comment?

[Assistant] SELECT created_at, updated_at, rating FROM socialmedia.comments;

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

[Assistant] SELECT created_at, updated_at, rating FROM socialmedia.comments WHERE rating LIKE 'A%';

[User] Get average of rating by rating from comments.

[Assistant] SELECT rating, AVERAGE(rating) AS average_rating FROM socialmedia.comments GROUP BY rating;


[User] Retrieve all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] What image_url, event_id, updated_at, rating do we have for comments and their associated events?

[Assistant] SELECT *, events.updated_at, events.rating FROM socialmedia.comments JOIN socialmedia.events ON comments.event_id = events.sku;

[User] Show the results sorted by updated_at ascending.

[Assistant] SELECT *, events.updated_at, events.rating FROM socialmedia.comments JOIN socialmedia.events ON comments.event_id = events.sku ORDER BY updated_at ASC;


[User] Retrieve thumbnail_url, updated_at, comment_id for every event.

[Assistant] SELECT thumbnail_url, updated_at, comment_id FROM socialmedia.events;

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

[Assistant] SELECT thumbnail_url, updated_at, comment_id FROM socialmedia.events WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Get sum of title by thumbnail_url from events.

[Assistant] SELECT thumbnail_url, SUM(title) AS sum_title FROM socialmedia.events GROUP BY thumbnail_url;


[User] Get title, thumbnail_url, updated_at from all events.

[Assistant] SELECT title, thumbnail_url, updated_at FROM socialmedia.events;

[User] Order the output by thumbnail_url descending.

[Assistant] SELECT title, thumbnail_url, updated_at FROM socialmedia.events ORDER BY thumbnail_url DESC;

[User] Sort the results by comment_id ascending.

[Assistant] SELECT title, thumbnail_url, updated_at FROM socialmedia.events ORDER BY comment_id ASC;


[User] Display all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Find comments from 2023.

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

[User] Get the distribution of comments across different image_url values.

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


[User] Retrieve all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

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

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

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


[User] What are the views, message_id, event_id of each comment?

[Assistant] SELECT views, message_id, event_id FROM socialmedia.comments;

[User] Order the output by views descending.

[Assistant] SELECT views, message_id, event_id FROM socialmedia.comments ORDER BY views DESC;

[User] Order the output by views descending.

[Assistant] SELECT views, message_id, event_id FROM socialmedia.comments ORDER BY views DESC;


[User] Get user_id, format, event_id from all messages.

[Assistant] SELECT user_id, format, event_id FROM socialmedia.messages;

[User] Show the results sorted by user_id ascending.

[Assistant] SELECT user_id, format, event_id FROM socialmedia.messages ORDER BY user_id ASC;

[User] Calculate max of user_id for each description in messages.

[Assistant] SELECT description, MAX(user_id) AS max_user_id FROM socialmedia.messages GROUP BY description;


[User] What are the updated_at, rating, thumbnail_url of each event?

[Assistant] SELECT updated_at, rating, thumbnail_url FROM socialmedia.events;

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

[Assistant] SELECT updated_at, rating, thumbnail_url FROM socialmedia.events WHERE title LIKE 'A%';

[User] Order the output by updated_at ascending.

[Assistant] SELECT updated_at, rating, thumbnail_url FROM socialmedia.events WHERE title LIKE 'A%' ORDER BY updated_at ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.billing (
  product_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  category character varying(64),
  reserved character varying(64) NOT NULL,
  quantity character varying(256) NOT NULL,
  media_url varchar,
  msrp char,
  name text NOT NULL,
  medical_record_id text NOT NULL -- reference to medical_records.transaction_id,
  FOREIGN KEY (medical_record_id) REFERENCES medical_records(transaction_id)
)

CREATE TABLE healthcare.prescriptions (
  id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  traded_at timestamp,
  delivery_status character varying(256),
  payment_method character varying(64),
  status varchar,
  currency text,
  exchange_rate character varying(256),
  approval_status character varying(256),
  billin_id integer NOT NULL -- reference to billing.product_id,
  FOREIGN KEY (billin_id) REFERENCES billing(product_id)
)

CREATE TABLE healthcare.medical_records (
  transaction_id text PRIMARY KEY -- unique identifier,
  payment_date date,
  due_date timestamp without time zone,
  payer_id varchar -- identifier for payer,
  verification_status character varying(256),
  balance decimal,
  reference_number character varying(64),
  prescription_id integer NOT NULL -- reference to prescriptions.id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(id)
)

[User] Get all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

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

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

[User] Calculate min of currency for each currency in prescriptions.

[Assistant] SELECT currency, MIN(currency) AS min_currency FROM healthcare.prescriptions GROUP BY currency;


[User] Show me all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Show me prescriptions with delivery_status LIKE 'A%'.

[Assistant] SELECT * FROM healthcare.prescriptions WHERE delivery_status LIKE 'A%';

[User] Show only 25 records.

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


[User] Get all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] Find medical_records created yesterday.

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

[User] Show the results sorted by due_date descending.

[Assistant] SELECT * FROM healthcare.medical_records WHERE payment_date = CURRENT_DATE - INTERVAL '1 day' ORDER BY due_date DESC;


[User] Display all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Order the output by billin_id ascending.

[Assistant] SELECT * FROM healthcare.prescriptions ORDER BY billin_id ASC;

[User] Group prescriptions by billin_id and show the max of status.

[Assistant] SELECT billin_id, MAX(status) AS max_status FROM healthcare.prescriptions GROUP BY billin_id;


[User] List all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Show the results sorted by msrp descending.

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

[User] Show the results sorted by media_url descending.

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


[User] Display all billing.

[Assistant] SELECT * FROM healthcare.billing;

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

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

[User] Restrict the output to 100 items.

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


[User] List all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Show me billing that were from 2023.

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

[User] Get sum of media_url by updated_at from billing.

[Assistant] SELECT updated_at, SUM(media_url) AS sum_media_url FROM healthcare.billing GROUP BY updated_at;


[User] Show me all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Sort the results by name descending.

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

[User] Group billing by updated_at and show the sum of reserved.

[Assistant] SELECT updated_at, SUM(reserved) AS sum_reserved FROM healthcare.billing GROUP BY updated_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 tradingplatform.trades (
  payment_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  currency varchar,
  delivery_status character varying(256),
  price bigint,
  quantity text,
  card_type text NOT NULL,
  subtotal integer NOT NULL,
  metadat_id text -- reference to metadata.post_id,
  FOREIGN KEY (metadat_id) REFERENCES metadata(post_id)
)

CREATE TABLE tradingplatform.metadata (
  post_id varchar PRIMARY KEY -- unique identifier,
  edited_at date,
  published_at timestamp without time zone,
  author_id character varying(64) -- identifier for author,
  format char,
  media_url character varying(256)
)

CREATE TABLE tradingplatform.orders (
  payment_id character varying(64) NOT NULL -- unique identifier,
  cancelled_at date,
  seller_id text,
  account_id character varying(128),
  metadat_id text NOT NULL -- reference to metadata.post_id,
  FOREIGN KEY (metadat_id) REFERENCES metadata(post_id)
)

[User] Display all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Get all orders created yesterday.

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

[User] Calculate max of metadat_id for each cancelled_at in orders.

[Assistant] SELECT cancelled_at, MAX(metadat_id) AS max_metadat_id FROM tradingplatform.orders GROUP BY cancelled_at;


[User] List all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Sort the results by payment_id ascending.

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY payment_id ASC;

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

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


[User] Show me all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

[User] Get metadat_id, currency, author_id, edited_at by joining trades with metadata.

[Assistant] SELECT *, metadata.author_id, metadata.edited_at FROM tradingplatform.trades JOIN tradingplatform.metadata ON trades.metadat_id = metadata.post_id;

[User] Limit the results to 5 rows.

[Assistant] SELECT *, metadata.author_id, metadata.edited_at FROM tradingplatform.trades JOIN tradingplatform.metadata ON trades.metadat_id = metadata.post_id LIMIT 5;


[User] Show me all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] What cancelled_at, account_id, format, author_id do we have for orders and their associated metadata?

[Assistant] SELECT *, metadata.format, metadata.author_id FROM tradingplatform.orders JOIN tradingplatform.metadata ON orders.metadat_id = metadata.post_id;

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

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


[User] List all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

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

[User] Return just 25 rows.

[Assistant] SELECT * FROM tradingplatform.orders WHERE cancelled_at > '2023-12-01' LIMIT 25;


[User] Retrieve all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Get all orders from last week.

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

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

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


[User] Show me all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

[User] Sort the results by subtotal descending.

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

[User] Restrict the output to 25 items.

[Assistant] SELECT * FROM tradingplatform.trades ORDER BY subtotal DESC LIMIT 25;


[User] Retrieve cancelled_at, payment_id, account_id for every order.

[Assistant] SELECT cancelled_at, payment_id, account_id FROM tradingplatform.orders;

[User] What seller_id, account_id, published_at, edited_at do we have for orders and their associated metadata?

[Assistant] SELECT cancelled_at, payment_id, account_id, metadata.published_at, metadata.edited_at FROM tradingplatform.orders JOIN tradingplatform.metadata ON orders.metadat_id = metadata.post_id;

[User] Tally up orders by cancelled_at.

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


[User] Show me all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

[User] What delivery_status, card_type, media_url, edited_at do we have for trades and their associated metadata?

[Assistant] SELECT *, metadata.media_url, metadata.edited_at FROM tradingplatform.trades JOIN tradingplatform.metadata ON trades.metadat_id = metadata.post_id;

[User] Group trades by currency and show the max of currency.

[Assistant] SELECT currency, MAX(currency) AS max_currency FROM tradingplatform.trades GROUP BY currency;


[User] Retrieve currency, card_type, delivery_status for every trade.

[Assistant] SELECT currency, card_type, delivery_status FROM tradingplatform.trades;

[User] Show me currency, updated_at, published_at, edited_at from trades and their related metadata.

[Assistant] SELECT currency, card_type, delivery_status, metadata.published_at, metadata.edited_at FROM tradingplatform.trades JOIN tradingplatform.metadata ON trades.metadat_id = metadata.post_id;

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

[Assistant] SELECT currency, card_type, delivery_status, metadata.published_at, metadata.edited_at FROM tradingplatform.trades JOIN tradingplatform.metadata ON trades.metadat_id = metadata.post_id ORDER BY subtotal DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.users (
  employee_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  membership_level character varying(64) NOT NULL,
  is_verified bit NOT NULL,
  last_name text,
  username char,
  trade_id text NOT NULL -- reference to trades.transaction_id,
  wallet_id integer -- reference to wallets.invoice_id,
  FOREIGN KEY (trade_id) REFERENCES trades(transaction_id),
  FOREIGN KEY (wallet_id) REFERENCES wallets(invoice_id)
)

CREATE TABLE tradingplatform.wallets (
  invoice_id integer PRIMARY KEY -- unique identifier,
  due_date timestamp,
  updated_at date,
  payee_id character varying(256) -- identifier for payee,
  invoice_number character varying(64),
  approval_status character varying(64),
  user_id text -- reference to users.employee_id,
  FOREIGN KEY (user_id) REFERENCES users(employee_id)
)

CREATE TABLE tradingplatform.trades (
  transaction_id text PRIMARY KEY -- unique identifier,
  completed_at timestamp without time zone,
  buyer_id char -- identifier for buyer,
  approval_status text,
  payment_method character varying(64),
  user_id text NOT NULL -- reference to users.employee_id,
  wallet_id integer -- reference to wallets.invoice_id,
  FOREIGN KEY (user_id) REFERENCES users(employee_id),
  FOREIGN KEY (wallet_id) REFERENCES wallets(invoice_id)
)

[User] Retrieve all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

[User] Show the results sorted by completed_at descending.

[Assistant] SELECT * FROM tradingplatform.trades ORDER BY completed_at DESC;

[User] Restrict the output to 50 items.

[Assistant] SELECT * FROM tradingplatform.trades ORDER BY completed_at DESC LIMIT 50;


[User] Display all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

[User] Find wallets where due_date > '2023-01-01'.

[Assistant] SELECT * FROM tradingplatform.wallets WHERE due_date > '2023-01-01';

[User] Restrict the output to 20 items.

[Assistant] SELECT * FROM tradingplatform.wallets WHERE due_date > '2023-01-01' LIMIT 20;


[User] Retrieve completed_at, approval_status, buyer_id for every trade.

[Assistant] SELECT completed_at, approval_status, buyer_id FROM tradingplatform.trades;

[User] Find trades from 2023.

[Assistant] SELECT completed_at, approval_status, buyer_id FROM tradingplatform.trades WHERE completed_at BETWEEN '2023-01-01' AND '2023-12-31';

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

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


[User] List all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] Sort the results by is_verified ascending.

[Assistant] SELECT * FROM tradingplatform.users ORDER BY is_verified ASC;

[User] Only show the top 20 results.

[Assistant] SELECT * FROM tradingplatform.users ORDER BY is_verified ASC LIMIT 20;


[User] Display all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

[User] List wallet_id, buyer_id, trade_id, created_at for each trade along with their user information.

[Assistant] SELECT *, users.trade_id, users.created_at FROM tradingplatform.trades JOIN tradingplatform.users ON trades.user_id = users.employee_id;

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

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


[User] Retrieve all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

[User] Order the output by completed_at ascending.

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

[User] How many trades are there per payment_method?

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


[User] Retrieve all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

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

[Assistant] SELECT * FROM tradingplatform.trades WHERE payment_method LIKE 'A%';

[User] Order the output by completed_at descending.

[Assistant] SELECT * FROM tradingplatform.trades WHERE payment_method LIKE 'A%' ORDER BY completed_at DESC;


[User] Retrieve all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] List users that have is_verified = TRUE.

[Assistant] SELECT * FROM tradingplatform.users WHERE is_verified = TRUE;

[User] Tally up users by is_verified.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.notifications (
  store_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at timestamp without time zone,
  operating_hours text,
  latitude char,
  type character varying(256)
)

CREATE TABLE tradingplatform.orders (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  traded_at date,
  processed_at timestamp,
  quantity text NOT NULL,
  approval_status text,
  user_id character varying(64) NOT NULL,
  notification_id text -- reference to notifications.store_id,
  FOREIGN KEY (notification_id) REFERENCES notifications(store_id)
)

[User] List user_id, traded_at, transaction_id from orders.

[Assistant] SELECT user_id, traded_at, transaction_id FROM tradingplatform.orders;

[User] Get all orders between January and March.

[Assistant] SELECT user_id, traded_at, transaction_id FROM tradingplatform.orders WHERE traded_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] What is the max approval_status for each quantity in orders?

[Assistant] SELECT quantity, MAX(approval_status) AS max_approval_status FROM tradingplatform.orders GROUP BY quantity;


[User] Display all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Can you order these by traded_at descending?

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY traded_at DESC;

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

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


[User] Retrieve quantity, transaction_id, traded_at for every order.

[Assistant] SELECT quantity, transaction_id, traded_at FROM tradingplatform.orders;

[User] What processed_at, traded_at, updated_at, latitude do we have for orders and their associated notifications?

[Assistant] SELECT quantity, transaction_id, traded_at, notifications.updated_at, notifications.latitude FROM tradingplatform.orders JOIN tradingplatform.notifications ON orders.notification_id = notifications.store_id;

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

[Assistant] SELECT processed_at, AVERAGE(processed_at) AS average_processed_at FROM tradingplatform.orders GROUP BY processed_at;


[User] Display all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

[Assistant] SELECT * FROM tradingplatform.orders WHERE notification_id LIKE 'A%';

[User] Can you order these by approval_status ascending?

[Assistant] SELECT * FROM tradingplatform.orders WHERE notification_id LIKE 'A%' ORDER BY approval_status ASC;


[User] Get transaction_id, processed_at, user_id from all orders.

[Assistant] SELECT transaction_id, processed_at, user_id FROM tradingplatform.orders;

[User] Get all orders older than 6 months.

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

[User] Calculate min of processed_at for each approval_status in orders.

[Assistant] SELECT approval_status, MIN(processed_at) AS min_processed_at FROM tradingplatform.orders GROUP BY approval_status;


[User] List approval_status, quantity, traded_at from orders.

[Assistant] SELECT approval_status, quantity, traded_at FROM tradingplatform.orders;

[User] Sort the results by approval_status ascending.

[Assistant] SELECT approval_status, quantity, traded_at FROM tradingplatform.orders ORDER BY approval_status ASC;

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

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


[User] Show me all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY notification_id ASC;

[User] Return just 20 rows.

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY notification_id ASC LIMIT 20;


[User] Show me approval_status, processed_at, notification_id for all orders.

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

[User] Sort the results by approval_status descending.

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

[User] Sort the results by approval_status descending.

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


[User] Show me all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

[Assistant] SELECT * FROM tradingplatform.orders WHERE quantity LIKE 'A%';

[User] Tally up orders by notification_id.

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


[User] Display all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Can you order these by approval_status descending?

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY approval_status DESC;

[User] Can you order these by user_id ascending?

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY user_id ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.accounts (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at timestamp,
  status varchar,
  notes char,
  currency char NOT NULL,
  loan_id text -- reference to loans.employee_id,
  FOREIGN KEY (loan_id) REFERENCES loans(employee_id)
)

CREATE TABLE finance.loans (
  employee_id text PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  created_at timestamp,
  is_active bit NOT NULL,
  language character varying(128),
  bio text NOT NULL,
  account_id text NOT NULL -- reference to accounts.id,
  FOREIGN KEY (account_id) REFERENCES accounts(id)
)

[User] Get all accounts.

[Assistant] SELECT * FROM finance.accounts;

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

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

[User] Get sum of created_at by currency from accounts.

[Assistant] SELECT currency, SUM(created_at) AS sum_created_at FROM finance.accounts GROUP BY currency;


[User] Display all loans.

[Assistant] SELECT * FROM finance.loans;

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

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

[User] Tally up loans by bio.

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


[User] Retrieve bio, created_at, is_active for every loan.

[Assistant] SELECT bio, created_at, is_active FROM finance.loans;

[User] Order the output by account_id descending.

[Assistant] SELECT bio, created_at, is_active FROM finance.loans ORDER BY account_id DESC;

[User] Only show the top 25 results.

[Assistant] SELECT bio, created_at, is_active FROM finance.loans ORDER BY account_id DESC LIMIT 25;


[User] List loan_id, status, created_at from accounts.

[Assistant] SELECT loan_id, status, created_at FROM finance.accounts;

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

[Assistant] SELECT loan_id, status, created_at FROM finance.accounts WHERE updated_at > '2023-01-01';

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

[Assistant] SELECT loan_id, status, created_at FROM finance.accounts WHERE updated_at > '2023-01-01' ORDER BY loan_id DESC;


[User] List created_at, notes, loan_id from accounts.

[Assistant] SELECT created_at, notes, loan_id FROM finance.accounts;

[User] Get currency, loan_id, account_id, joined_at by joining accounts with loans.

[Assistant] SELECT created_at, notes, loan_id, loans.account_id, loans.joined_at FROM finance.accounts JOIN finance.loans ON accounts.loan_id = loans.employee_id;

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

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


[User] Get all loans.

[Assistant] SELECT * FROM finance.loans;

[User] List is_active, created_at, loan_id, currency for each loan along with their account information.

[Assistant] SELECT *, accounts.loan_id, accounts.currency FROM finance.loans JOIN finance.accounts ON loans.account_id = accounts.id;

[User] Can you order these by is_active descending?

[Assistant] SELECT *, accounts.loan_id, accounts.currency FROM finance.loans JOIN finance.accounts ON loans.account_id = accounts.id ORDER BY is_active DESC;


[User] What are the joined_at, language, account_id of each loan?

[Assistant] SELECT joined_at, language, account_id FROM finance.loans;

[User] Can you order these by account_id ascending?

[Assistant] SELECT joined_at, language, account_id FROM finance.loans ORDER BY account_id ASC;

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

[Assistant] SELECT joined_at, language, account_id FROM finance.loans ORDER BY created_at ASC;


[User] Get is_active, account_id, bio from all loans.

[Assistant] SELECT is_active, account_id, bio FROM finance.loans;

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

[Assistant] SELECT is_active, account_id, bio FROM finance.loans WHERE created_at > '2023-01-01';

[User] Sort the results by account_id ascending.

[Assistant] SELECT is_active, account_id, bio FROM finance.loans WHERE created_at > '2023-01-01' ORDER BY account_id ASC;


[User] List language, created_at, is_active from loans.

[Assistant] SELECT language, created_at, is_active FROM finance.loans;

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

[Assistant] SELECT language, created_at, is_active FROM finance.loans ORDER BY bio DESC;

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

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


[User] List status, updated_at, created_at from accounts.

[Assistant] SELECT status, updated_at, created_at FROM finance.accounts;

[User] Show me loan_id, created_at, bio, account_id from accounts and their related loans.

[Assistant] SELECT status, updated_at, created_at, loans.bio, loans.account_id FROM finance.accounts JOIN finance.loans ON accounts.loan_id = loans.employee_id;

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

[Assistant] SELECT status, updated_at, created_at, loans.bio, loans.account_id FROM finance.accounts JOIN finance.loans ON accounts.loan_id = loans.employee_id ORDER BY notes 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 socialmedia.users (
  customer_id text PRIMARY KEY -- unique identifier,
  last_active timestamp,
  address text,
  zip_code character varying(128),
  api_key text,
  message_id text NOT NULL -- reference to messages.id,
  FOREIGN KEY (message_id) REFERENCES messages(id)
)

CREATE TABLE socialmedia.groups (
  transaction_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  balance integer NOT NULL,
  amount numeric NOT NULL,
  approval_status character varying(64),
  user_id varchar -- identifier for user,
  status character varying(64) NOT NULL,
  invoice_number character varying(64)
)

CREATE TABLE socialmedia.messages (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  reply_to_id char,
  parent_id char NOT NULL -- identifier for parent,
  title character varying(128)
)

[User] Retrieve all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Can you order these by address ascending?

[Assistant] SELECT * FROM socialmedia.users ORDER BY address ASC;

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

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


[User] Retrieve all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Find users from last week.

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

[User] Limit the results to 25 rows.

[Assistant] SELECT * FROM socialmedia.users WHERE last_active >= CURRENT_DATE - INTERVAL '7 days' LIMIT 25;


[User] Display all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Retrieve zip_code, last_active, created_at, parent_id showing the relationship between users and messages.

[Assistant] SELECT *, messages.created_at, messages.parent_id FROM socialmedia.users JOIN socialmedia.messages ON users.message_id = messages.id;

[User] Tally up users by address.

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


[User] Show me all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] List users with dates from 2023.

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

[User] How many users are there per api_key?

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


[User] Get last_active, api_key, address from all users.

[Assistant] SELECT last_active, api_key, address FROM socialmedia.users;

[User] Can you order these by message_id ascending?

[Assistant] SELECT last_active, api_key, address FROM socialmedia.users ORDER BY message_id ASC;

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

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


[User] Get last_active, zip_code, message_id from all users.

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

[User] List api_key, message_id, reply_to_id, title for each user along with their message information.

[Assistant] SELECT last_active, zip_code, message_id, messages.reply_to_id, messages.title FROM socialmedia.users JOIN socialmedia.messages ON users.message_id = messages.id;

[User] Limit the results to 10 rows.

[Assistant] SELECT last_active, zip_code, message_id, messages.reply_to_id, messages.title FROM socialmedia.users JOIN socialmedia.messages ON users.message_id = messages.id LIMIT 10;


[User] Retrieve zip_code, last_active, api_key for every user.

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

[User] List message_id, zip_code, reply_to_id, parent_id for each user along with their message information.

[Assistant] SELECT zip_code, last_active, api_key, messages.reply_to_id, messages.parent_id FROM socialmedia.users JOIN socialmedia.messages ON users.message_id = messages.id;

[User] Show only 10 records.

[Assistant] SELECT zip_code, last_active, api_key, messages.reply_to_id, messages.parent_id FROM socialmedia.users JOIN socialmedia.messages ON users.message_id = messages.id LIMIT 10;


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

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

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

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

[User] Sort the results by address ascending.

[Assistant] SELECT api_key, zip_code, last_active FROM socialmedia.users WHERE zip_code LIKE 'A%' ORDER BY address ASC;


[User] What are the api_key, zip_code, address of each user?

[Assistant] SELECT api_key, zip_code, address FROM socialmedia.users;

[User] Show me address, message_id, title, reply_to_id from users and their related messages.

[Assistant] SELECT api_key, zip_code, address, messages.title, messages.reply_to_id FROM socialmedia.users JOIN socialmedia.messages ON users.message_id = messages.id;

[User] Only show the top 5 results.

[Assistant] SELECT api_key, zip_code, address, messages.title, messages.reply_to_id FROM socialmedia.users JOIN socialmedia.messages ON users.message_id = messages.id LIMIT 5;


[User] Display all users.

[Assistant] SELECT * FROM socialmedia.users;

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

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

[User] Can you order these by api_key descending?

[Assistant] SELECT * FROM socialmedia.users WHERE last_active BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY api_key DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.medical_records (
  location_id text PRIMARY KEY -- unique identifier,
  created_at date,
  last_inspected timestamp,
  zip_code varchar,
  type text,
  operating_hours character varying(64) NOT NULL,
  prescription_id integer NOT NULL -- reference to prescriptions.id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(id)
)

CREATE TABLE healthcare.prescriptions (
  id integer PRIMARY KEY -- unique identifier,
  edited_at date,
  published_at timestamp,
  visibility character varying(256),
  reply_to_id character varying(128) NOT NULL,
  categories char NOT NULL,
  thumbnail char,
  user_id character varying(256) -- identifier for user,
  tags text NOT NULL,
  shares char,
  medical_record_id text -- reference to medical_records.location_id,
  FOREIGN KEY (medical_record_id) REFERENCES medical_records(location_id)
)

[User] Retrieve operating_hours, type, prescription_id for every medical_record.

[Assistant] SELECT operating_hours, type, prescription_id FROM healthcare.medical_records;

[User] Get last_inspected, created_at, edited_at, reply_to_id by joining medical_records with prescriptions.

[Assistant] SELECT operating_hours, type, prescription_id, prescriptions.edited_at, prescriptions.reply_to_id FROM healthcare.medical_records JOIN healthcare.prescriptions ON medical_records.prescription_id = prescriptions.id;

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

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


[User] Get all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

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

[Assistant] SELECT * FROM healthcare.prescriptions ORDER BY reply_to_id DESC;

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

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


[User] Show me all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] Get medical_records that match prescription_id > 11.

[Assistant] SELECT * FROM healthcare.medical_records WHERE prescription_id > 11;

[User] Return just 10 rows.

[Assistant] SELECT * FROM healthcare.medical_records WHERE prescription_id > 11 LIMIT 10;


[User] Retrieve visibility, tags, medical_record_id for every prescription.

[Assistant] SELECT visibility, tags, medical_record_id FROM healthcare.prescriptions;

[User] Get reply_to_id, tags, zip_code, prescription_id by joining prescriptions with medical_records.

[Assistant] SELECT visibility, tags, medical_record_id, medical_records.zip_code, medical_records.prescription_id FROM healthcare.prescriptions JOIN healthcare.medical_records ON prescriptions.medical_record_id = medical_records.location_id;

[User] Show only 5 records.

[Assistant] SELECT visibility, tags, medical_record_id, medical_records.zip_code, medical_records.prescription_id FROM healthcare.prescriptions JOIN healthcare.medical_records ON prescriptions.medical_record_id = medical_records.location_id LIMIT 5;


[User] Get created_at, last_inspected, zip_code from all medical_records.

[Assistant] SELECT created_at, last_inspected, zip_code FROM healthcare.medical_records;

[User] List zip_code, operating_hours, categories, medical_record_id for each medical_record along with their prescription information.

[Assistant] SELECT created_at, last_inspected, zip_code, prescriptions.categories, prescriptions.medical_record_id FROM healthcare.medical_records JOIN healthcare.prescriptions ON medical_records.prescription_id = prescriptions.id;

[User] Calculate sum of created_at for each created_at in medical_records.

[Assistant] SELECT created_at, SUM(created_at) AS sum_created_at FROM healthcare.medical_records GROUP BY created_at;


[User] Get operating_hours, last_inspected, zip_code from all medical_records.

[Assistant] SELECT operating_hours, last_inspected, zip_code FROM healthcare.medical_records;

[User] Can you order these by operating_hours ascending?

[Assistant] SELECT operating_hours, last_inspected, zip_code FROM healthcare.medical_records ORDER BY operating_hours ASC;

[User] Get the distribution of medical_records across different type values.

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


[User] List created_at, prescription_id, last_inspected from medical_records.

[Assistant] SELECT created_at, prescription_id, last_inspected FROM healthcare.medical_records;

[User] What operating_hours, type, medical_record_id, tags do we have for medical_records and their associated prescriptions?

[Assistant] SELECT created_at, prescription_id, last_inspected, prescriptions.medical_record_id, prescriptions.tags FROM healthcare.medical_records JOIN healthcare.prescriptions ON medical_records.prescription_id = prescriptions.id;

[User] Tally up medical_records by created_at.

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


[User] Retrieve all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Can you order these by shares ascending?

[Assistant] SELECT * FROM healthcare.prescriptions ORDER BY shares ASC;

[User] Show the results sorted by user_id ascending.

[Assistant] SELECT * FROM healthcare.prescriptions ORDER BY user_id ASC;


[User] Get all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

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

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

[User] Order the output by type descending.

[Assistant] SELECT * FROM healthcare.medical_records WHERE last_inspected BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY type DESC;


[User] List zip_code, created_at, prescription_id from medical_records.

[Assistant] SELECT zip_code, created_at, prescription_id FROM healthcare.medical_records;

[User] List medical_records with dates created yesterday.

[Assistant] SELECT zip_code, created_at, prescription_id FROM healthcare.medical_records WHERE last_inspected = CURRENT_DATE - INTERVAL '1 day';

[User] Show the results sorted by created_at ascending.

[Assistant] SELECT zip_code, created_at, prescription_id FROM healthcare.medical_records WHERE last_inspected = CURRENT_DATE - INTERVAL '1 day' ORDER BY created_at ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.reviews (
  message_id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  updated_at date,
  format character varying(64) NOT NULL,
  media_url character varying(128) NOT NULL,
  thumbnail character varying(64),
  parent_id character varying(128) NOT NULL -- identifier for parent,
  message character varying(256),
  keywords varchar,
  categorie_id integer NOT NULL -- reference to categories.store_id,
  FOREIGN KEY (categorie_id) REFERENCES categories(store_id)
)

CREATE TABLE e-commerce.categories (
  store_id integer PRIMARY KEY -- unique identifier,
  last_inspected timestamp,
  description character varying(256) NOT NULL,
  location_lon char,
  category character varying(64) NOT NULL,
  operating_hours character varying(256),
  review_id text -- reference to reviews.message_id,
  FOREIGN KEY (review_id) REFERENCES reviews(message_id)
)

[User] Retrieve location_lon, category, last_inspected for every categorie.

[Assistant] SELECT location_lon, category, last_inspected FROM e-commerce.categories;

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

[Assistant] SELECT location_lon, category, last_inspected FROM e-commerce.categories WHERE description LIKE 'A%';

[User] Group categories by review_id and show the average of last_inspected.

[Assistant] SELECT review_id, AVERAGE(last_inspected) AS average_last_inspected FROM e-commerce.categories GROUP BY review_id;


[User] Retrieve updated_at, categorie_id, media_url for every review.

[Assistant] SELECT updated_at, categorie_id, media_url FROM e-commerce.reviews;

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

[Assistant] SELECT updated_at, categorie_id, media_url FROM e-commerce.reviews ORDER BY message ASC;

[User] Sort the results by published_at descending.

[Assistant] SELECT updated_at, categorie_id, media_url FROM e-commerce.reviews ORDER BY published_at DESC;


[User] List last_inspected, category, operating_hours from categories.

[Assistant] SELECT last_inspected, category, operating_hours FROM e-commerce.categories;

[User] Retrieve description, review_id, keywords, format showing the relationship between categories and reviews.

[Assistant] SELECT last_inspected, category, operating_hours, reviews.keywords, reviews.format FROM e-commerce.categories JOIN e-commerce.reviews ON categories.review_id = reviews.message_id;

[User] How many categories are there per category?

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


[User] Show me category, description, last_inspected for all categories.

[Assistant] SELECT category, description, last_inspected FROM e-commerce.categories;

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

[Assistant] SELECT category, description, last_inspected FROM e-commerce.categories WHERE last_inspected >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

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

[Assistant] SELECT category, description, last_inspected FROM e-commerce.categories WHERE last_inspected >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY review_id ASC;


[User] Retrieve all reviews.

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

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

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

[User] Limit the results to 15 rows.

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


[User] What are the updated_at, keywords, thumbnail of each review?

[Assistant] SELECT updated_at, keywords, thumbnail FROM e-commerce.reviews;

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

[Assistant] SELECT updated_at, keywords, thumbnail FROM e-commerce.reviews WHERE format LIKE 'A%';

[User] How many reviews are there per media_url?

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


[User] Show me media_url, parent_id, published_at for all reviews.

[Assistant] SELECT media_url, parent_id, published_at FROM e-commerce.reviews;

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

[Assistant] SELECT media_url, parent_id, published_at FROM e-commerce.reviews WHERE published_at > '2023-12-01';

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

[Assistant] SELECT media_url, parent_id, published_at FROM e-commerce.reviews WHERE published_at > '2023-12-01' ORDER BY message ASC;


[User] Show me media_url, categorie_id, keywords for all reviews.

[Assistant] SELECT media_url, categorie_id, keywords FROM e-commerce.reviews;

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

[Assistant] SELECT media_url, categorie_id, keywords FROM e-commerce.reviews WHERE format LIKE 'A%';

[User] Get sum of parent_id by thumbnail from reviews.

[Assistant] SELECT thumbnail, SUM(parent_id) AS sum_parent_id FROM e-commerce.reviews GROUP BY thumbnail;


[User] Retrieve all reviews.

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

[User] Retrieve reviews where keywords LIKE 'A%'.

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

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

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


[User] List all reviews.

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

[User] Sort the results by message descending.

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

[User] Return just 100 rows.

[Assistant] SELECT * FROM e-commerce.reviews ORDER BY message DESC LIMIT 100;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE marketing.goods (
  barcode text PRIMARY KEY -- unique identifier,
  expires_at timestamp,
  published_at timestamp,
  category character varying(64) NOT NULL,
  backorder char,
  views varchar NOT NULL,
  sale_id integer -- reference to sales.order_id,
  FOREIGN KEY (sale_id) REFERENCES sales(order_id)
)

CREATE TABLE marketing.students (
  person_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  salt text NOT NULL,
  phone character varying(64),
  city varchar NOT NULL,
  status text,
  timezone text,
  first_name text,
  sale_id integer NOT NULL -- reference to sales.order_id,
  good_id text NOT NULL -- reference to goods.barcode,
  FOREIGN KEY (sale_id) REFERENCES sales(order_id),
  FOREIGN KEY (good_id) REFERENCES goods(barcode)
)

CREATE TABLE marketing.facilities (
  venue_id character varying(64) NOT NULL -- unique identifier,
  last_inspected timestamp without time zone,
  updated_at timestamp,
  description character varying(128),
  zip_code character varying(128),
  location_lat text NOT NULL,
  location_lon text
)

CREATE TABLE marketing.sales (
  order_id integer PRIMARY KEY -- unique identifier,
  cancelled_at timestamp without time zone,
  payment_status character varying(256) NOT NULL,
  card_type text,
  seller_id character varying(256)
)

[User] Display all students.

[Assistant] SELECT * FROM marketing.students;

[User] Can you order these by person_id ascending?

[Assistant] SELECT * FROM marketing.students ORDER BY person_id ASC;

[User] Only show the top 10 results.

[Assistant] SELECT * FROM marketing.students ORDER BY person_id ASC LIMIT 10;


[User] Display all students.

[Assistant] SELECT * FROM marketing.students;

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

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

[User] Order the output by timezone descending.

[Assistant] SELECT * FROM marketing.students WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY timezone DESC;


[User] Get salt, first_name, person_id from all students.

[Assistant] SELECT salt, first_name, person_id FROM marketing.students;

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

[Assistant] SELECT salt, first_name, person_id FROM marketing.students WHERE salt LIKE 'A%';

[User] Show only 20 records.

[Assistant] SELECT salt, first_name, person_id FROM marketing.students WHERE salt LIKE 'A%' LIMIT 20;


[User] List status, sale_id, good_id from students.

[Assistant] SELECT status, sale_id, good_id FROM marketing.students;

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

[Assistant] SELECT status, sale_id, good_id FROM marketing.students WHERE timezone LIKE 'A%';

[User] Show me max of city grouped by timezone for students.

[Assistant] SELECT timezone, MAX(city) AS max_city FROM marketing.students GROUP BY timezone;


[User] Show me published_at, expires_at, category for all goods.

[Assistant] SELECT published_at, expires_at, category FROM marketing.goods;

[User] Show the results sorted by expires_at ascending.

[Assistant] SELECT published_at, expires_at, category FROM marketing.goods ORDER BY expires_at ASC;

[User] Show the results sorted by published_at descending.

[Assistant] SELECT published_at, expires_at, category FROM marketing.goods ORDER BY published_at DESC;


[User] Retrieve timezone, status, city for every student.

[Assistant] SELECT timezone, status, city FROM marketing.students;

[User] List good_id, salt, payment_status, card_type for each student along with their sale information.

[Assistant] SELECT timezone, status, city, sales.payment_status, sales.card_type FROM marketing.students JOIN marketing.sales ON students.sale_id = sales.order_id;

[User] Show me the count of students grouped by person_id.

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


[User] Retrieve city, good_id, person_id for every student.

[Assistant] SELECT city, good_id, person_id FROM marketing.students;

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

[Assistant] SELECT city, good_id, person_id FROM marketing.students WHERE salt LIKE 'A%';

[User] How many students are there per phone?

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


[User] List person_id, status, phone from students.

[Assistant] SELECT person_id, status, phone FROM marketing.students;

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

[Assistant] SELECT person_id, status, phone FROM marketing.students WHERE updated_at > '2023-01-01';

[User] Show me min of salt grouped by status for students.

[Assistant] SELECT status, MIN(salt) AS min_salt FROM marketing.students GROUP BY status;


[User] Display all goods.

[Assistant] SELECT * FROM marketing.goods;

[User] Show me goods that were created yesterday.

[Assistant] SELECT * FROM marketing.goods WHERE published_at = CURRENT_DATE - INTERVAL '1 day';

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

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


[User] List all goods.

[Assistant] SELECT * FROM marketing.goods;

[User] Order the output by expires_at descending.

[Assistant] SELECT * FROM marketing.goods ORDER BY expires_at DESC;

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.metadata (
  location_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  coordinates varchar,
  parking_available text NOT NULL,
  location_lon character varying(256),
  category char,
  timezone char 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)
)

CREATE TABLE tradingplatform.wallets (
  account_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  updated_at timestamp,
  payer_id varchar -- identifier for payer,
  user_id character varying(256),
  reconciliation_status character varying(128),
  category text,
  currency character varying(256)
)

CREATE TABLE tradingplatform.users (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  last_active timestamp,
  email character varying(64),
  token text NOT NULL,
  language text,
  city character varying(256),
  membership_level text,
  wallet_id text NOT NULL -- reference to wallets.account_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(account_id)
)

[User] List all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

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

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

[User] Show me max of location_lon grouped by category for metadata.

[Assistant] SELECT category, MAX(location_lon) AS max_location_lon FROM tradingplatform.metadata GROUP BY category;


[User] Get language, email, membership_level from all users.

[Assistant] SELECT language, email, membership_level FROM tradingplatform.users;

[User] Find users where last_active > '2023-01-01'.

[Assistant] SELECT language, email, membership_level FROM tradingplatform.users WHERE last_active > '2023-01-01';

[User] Show the results sorted by membership_level ascending.

[Assistant] SELECT language, email, membership_level FROM tradingplatform.users WHERE last_active > '2023-01-01' ORDER BY membership_level ASC;


[User] List all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Show me metadata with timezone LIKE 'A%'.

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

[User] Restrict the output to 50 items.

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