[User] Get all venues.

[Assistant] SELECT * FROM travel.venues;

[User] Get venues that match address_line2 LIKE 'A%'.

[Assistant] SELECT * FROM travel.venues WHERE address_line2 LIKE 'A%';

[User] Restrict the output to 15 items.

[Assistant] SELECT * FROM travel.venues WHERE address_line2 LIKE 'A%' 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 travel.venues (
  store_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  city character varying(128),
  address_line1 character varying(256),
  coordinates character varying(256),
  address_line2 character varying(64) NOT NULL,
  accessibility character varying(128),
  parking_available char
)

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

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

[User] Show me city, parking_available, store_id for all venues.

[Assistant] SELECT city, parking_available, store_id FROM travel.venues;

[User] Find venues between January and March.

[Assistant] SELECT city, parking_available, store_id FROM travel.venues WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Show only 20 records.

[Assistant] SELECT city, parking_available, store_id FROM travel.venues WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 20;


[User] Get all students.

[Assistant] SELECT * FROM travel.students;

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

[Assistant] SELECT * FROM travel.students WHERE timezone LIKE 'A%';

[User] Group students by joined_at and show the max of password_hash.

[Assistant] SELECT joined_at, MAX(password_hash) AS max_password_hash FROM travel.students GROUP BY joined_at;


[User] List all students.

[Assistant] SELECT * FROM travel.students;

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

[Assistant] SELECT * FROM travel.students WHERE password_hash LIKE 'A%';

[User] Can you order these by joined_at descending?

[Assistant] SELECT * FROM travel.students WHERE password_hash LIKE 'A%' ORDER BY joined_at DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.customers (
  id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp,
  updated_at timestamp without time zone,
  age character varying(128),
  display_name character varying(128),
  timezone varchar,
  city character varying(64),
  avatar character varying(128) NOT NULL,
  account_id text NOT NULL -- reference to accounts.payment_id,
  FOREIGN KEY (account_id) REFERENCES accounts(payment_id)
)

CREATE TABLE finance.accounts (
  payment_id text PRIMARY KEY -- unique identifier,
  created_at date,
  reconciliation_status character varying(64),
  invoice_number text,
  loan_id integer NOT NULL -- reference to loans.id,
  FOREIGN KEY (loan_id) REFERENCES loans(id)
)

CREATE TABLE finance.audits (
  employee_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  joined_at date,
  bio character varying(256),
  timezone text,
  first_name character varying(64),
  website character varying(128),
  last_login date,
  loan_id integer NOT NULL -- reference to loans.id,
  account_id text NOT NULL -- reference to accounts.payment_id,
  FOREIGN KEY (loan_id) REFERENCES loans(id),
  FOREIGN KEY (account_id) REFERENCES accounts(payment_id)
)

CREATE TABLE finance.loans (
  id integer PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  updated_at timestamp without time zone,
  is_verified bit,
  bio character varying(128),
  last_name char,
  status character varying(128),
  last_login timestamp NOT NULL,
  address character varying(64)
)

[User] List all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Get all audits from last week.

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

[User] Return just 15 rows.

[Assistant] SELECT * FROM finance.audits WHERE last_login >= CURRENT_DATE - INTERVAL '7 days' 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 socialmedia.messages (
  message_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  published_at date,
  media_url character varying(256),
  format character varying(64) NOT NULL,
  title character varying(64)
)

CREATE TABLE socialmedia.comments (
  id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp,
  body char,
  user_id character varying(128),
  attachment_url character varying(256)
)

CREATE TABLE socialmedia.users (
  person_id integer PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  full_name char,
  nationality character varying(256) NOT NULL,
  bio character varying(128),
  is_verified boolean NOT NULL -- indicates if verified is true,
  profile_picture_url varchar NOT NULL,
  age character varying(128) NOT NULL,
  comment_id text NOT NULL -- reference to comments.id,
  FOREIGN KEY (comment_id) REFERENCES comments(id)
)

CREATE TABLE socialmedia.posts (
  message_id character varying(64) NOT NULL -- unique identifier,
  edited_at timestamp without time zone,
  published_at date,
  likes character varying(64),
  thumbnail character varying(128) NOT NULL,
  categories char,
  subject character varying(256) NOT NULL,
  views text,
  comment_id text NOT NULL -- reference to comments.id,
  FOREIGN KEY (comment_id) REFERENCES comments(id)
)

[User] Show me full_name, nationality, is_verified for all users.

[Assistant] SELECT full_name, nationality, is_verified FROM socialmedia.users;

[User] Get users that match full_name LIKE 'A%'.

[Assistant] SELECT full_name, nationality, is_verified FROM socialmedia.users WHERE full_name LIKE 'A%';

[User] Tally up users by comment_id.

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


[User] Show me all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Show the results sorted by last_active descending.

[Assistant] SELECT * FROM socialmedia.users ORDER BY last_active DESC;

[User] Show the results sorted by is_verified descending.

[Assistant] SELECT * FROM socialmedia.users ORDER BY is_verified DESC;


[User] Get all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] What comment_id, last_active, attachment_url, body do we have for users and their associated comments?

[Assistant] SELECT *, comments.attachment_url, comments.body FROM socialmedia.users JOIN socialmedia.comments ON users.comment_id = comments.id;

[User] Only show the top 25 results.

[Assistant] SELECT *, comments.attachment_url, comments.body FROM socialmedia.users JOIN socialmedia.comments ON users.comment_id = comments.id LIMIT 25;


[User] Get comment_id, last_active, profile_picture_url from all users.

[Assistant] SELECT comment_id, last_active, profile_picture_url FROM socialmedia.users;

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

[Assistant] SELECT comment_id, last_active, profile_picture_url FROM socialmedia.users WHERE last_active = CURRENT_DATE - INTERVAL '1 day';

[User] Show me min of profile_picture_url grouped by bio for users.

[Assistant] SELECT bio, MIN(profile_picture_url) AS min_profile_picture_url FROM socialmedia.users GROUP BY bio;


[User] Get comment_id, subject, edited_at from all posts.

[Assistant] SELECT comment_id, subject, edited_at FROM socialmedia.posts;

[User] Retrieve subject, categories, body, user_id showing the relationship between posts and comments.

[Assistant] SELECT comment_id, subject, edited_at, comments.body, comments.user_id FROM socialmedia.posts JOIN socialmedia.comments ON posts.comment_id = comments.id;

[User] Tally up posts by views.

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


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

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

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

[Assistant] SELECT published_at, edited_at, views FROM socialmedia.posts WHERE edited_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Show the results sorted by published_at descending.

[Assistant] SELECT published_at, edited_at, views FROM socialmedia.posts WHERE edited_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY published_at DESC;


[User] Get comment_id, edited_at, categories from all posts.

[Assistant] SELECT comment_id, edited_at, categories FROM socialmedia.posts;

[User] Show the results sorted by categories ascending.

[Assistant] SELECT comment_id, edited_at, categories FROM socialmedia.posts ORDER BY categories ASC;

[User] Tally up posts by comment_id.

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


[User] What are the is_verified, nationality, comment_id of each user?

[Assistant] SELECT is_verified, nationality, comment_id FROM socialmedia.users;

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

[Assistant] SELECT is_verified, nationality, comment_id FROM socialmedia.users WHERE last_active > '2023-01-01';

[User] How many users are there per comment_id?

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


[User] List all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] Sort the results by comment_id descending.

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

[User] Tally up posts by categories.

[Assistant] SELECT categories, COUNT(*) AS count FROM socialmedia.posts GROUP BY categories 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 (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  currency text,
  card_type text,
  seller_id character varying(64) NOT NULL -- identifier for seller,
  approval_status character varying(64) NOT NULL,
  trade_id text NOT NULL -- reference to trades.transaction_id,
  FOREIGN KEY (trade_id) REFERENCES trades(transaction_id)
)

CREATE TABLE tradingplatform.trades (
  transaction_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  processed_at date,
  status character varying(64),
  subtotal numeric(38,14),
  tax integer,
  exchange_rate text,
  payment_status character varying(128) NOT NULL,
  quantity char
)

[User] Show me updated_at, trade_id, card_type for all notifications.

[Assistant] SELECT updated_at, trade_id, card_type FROM tradingplatform.notifications;

[User] Find notifications created yesterday.

[Assistant] SELECT updated_at, trade_id, card_type FROM tradingplatform.notifications WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

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

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


[User] Retrieve all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Get all notifications from last week.

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

[User] Show the results sorted by trade_id descending.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY trade_id DESC;


[User] What are the approval_status, updated_at, currency of each notification?

[Assistant] SELECT approval_status, updated_at, currency FROM tradingplatform.notifications;

[User] Show me notifications with trade_id LIKE 'A%'.

[Assistant] SELECT approval_status, updated_at, currency FROM tradingplatform.notifications WHERE trade_id LIKE 'A%';

[User] Return just 100 rows.

[Assistant] SELECT approval_status, updated_at, currency FROM tradingplatform.notifications WHERE trade_id LIKE 'A%' LIMIT 100;


[User] Retrieve all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Show me notifications with seller_id LIKE 'A%'.

[Assistant] SELECT * FROM tradingplatform.notifications WHERE seller_id LIKE 'A%';

[User] Restrict the output to 50 items.

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


[User] List approval_status, card_type, seller_id from notifications.

[Assistant] SELECT approval_status, card_type, seller_id FROM tradingplatform.notifications;

[User] Retrieve notifications where card_type LIKE 'A%'.

[Assistant] SELECT approval_status, card_type, seller_id FROM tradingplatform.notifications WHERE card_type LIKE 'A%';

[User] Tally up notifications by approval_status.

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


[User] List approval_status, updated_at, card_type from notifications.

[Assistant] SELECT approval_status, updated_at, card_type FROM tradingplatform.notifications;

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

[Assistant] SELECT approval_status, updated_at, card_type FROM tradingplatform.notifications WHERE approval_status LIKE 'A%';

[User] How many notifications are there per approval_status?

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


[User] Get all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Find notifications created yesterday.

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

[User] Restrict the output to 50 items.

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


[User] Get all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

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

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

[User] Calculate sum of approval_status for each approval_status in notifications.

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


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Get all notifications from last week.

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

[User] Only show the top 20 results.

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


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Show me approval_status, seller_id, subtotal, processed_at from notifications and their related trades.

[Assistant] SELECT *, trades.subtotal, trades.processed_at FROM tradingplatform.notifications JOIN tradingplatform.trades ON notifications.trade_id = trades.transaction_id;

[User] Tally up notifications by currency.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.medical_records (
  payment_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  currency varchar,
  payee_id character varying(128),
  exchange_rate character varying(256) NOT NULL,
  verification_status character varying(256) NOT NULL,
  patient_id text NOT NULL -- reference to patients.employee_id,
  FOREIGN KEY (patient_id) REFERENCES patients(employee_id)
)

CREATE TABLE healthcare.patients (
  employee_id varchar PRIMARY KEY -- unique identifier,
  last_active date,
  created_at timestamp,
  status character varying(128) NOT NULL,
  salt text,
  avatar character varying(256),
  full_name text
)

CREATE TABLE healthcare.billing (
  id text PRIMARY KEY -- unique identifier,
  created_at date,
  last_inspected timestamp,
  accessibility char,
  parking_available character varying(64),
  state character varying(256)
)

CREATE TABLE healthcare.departments (
  message_id integer PRIMARY KEY -- unique identifier,
  created_at date,
  image_url character varying(64) NOT NULL,
  score char,
  categories character varying(128),
  tags character varying(256),
  medical_record_id text -- reference to medical_records.payment_id,
  billin_id text -- reference to billing.id,
  FOREIGN KEY (medical_record_id) REFERENCES medical_records(payment_id),
  FOREIGN KEY (billin_id) REFERENCES billing(id)
)

[User] Get all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Get all departments from last week.

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

[User] What is the sum categories for each score in departments?

[Assistant] SELECT score, SUM(categories) AS sum_categories FROM healthcare.departments GROUP BY score;


[User] List all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Find departments where medical_record_id LIKE 'A%'.

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

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

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


[User] List all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] List medical_records with dates from last week.

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

[User] Count the number of medical_records in each patient_id category.

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


[User] Get created_at, image_url, categories from all departments.

[Assistant] SELECT created_at, image_url, categories FROM healthcare.departments;

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

[Assistant] SELECT created_at, image_url, categories FROM healthcare.departments ORDER BY billin_id ASC;

[User] Can you order these by tags ascending?

[Assistant] SELECT created_at, image_url, categories FROM healthcare.departments ORDER BY tags ASC;


[User] Retrieve all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Can you order these by image_url descending?

[Assistant] SELECT * FROM healthcare.departments ORDER BY image_url DESC;

[User] Show me average of medical_record_id grouped by score for departments.

[Assistant] SELECT score, AVERAGE(medical_record_id) AS average_medical_record_id FROM healthcare.departments GROUP BY score;


[User] Show me score, image_url, tags for all departments.

[Assistant] SELECT score, image_url, tags FROM healthcare.departments;

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

[Assistant] SELECT score, image_url, tags FROM healthcare.departments WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Calculate min of categories for each tags in departments.

[Assistant] SELECT tags, MIN(categories) AS min_categories FROM healthcare.departments GROUP BY tags;


[User] Get all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Get all departments created yesterday.

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

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

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


[User] List payee_id, currency, patient_id from medical_records.

[Assistant] SELECT payee_id, currency, patient_id FROM healthcare.medical_records;

[User] Show me medical_records with exchange_rate LIKE 'A%'.

[Assistant] SELECT payee_id, currency, patient_id FROM healthcare.medical_records WHERE exchange_rate LIKE 'A%';

[User] Show only 100 records.

[Assistant] SELECT payee_id, currency, patient_id FROM healthcare.medical_records WHERE exchange_rate LIKE 'A%' LIMIT 100;


[User] Show me all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

[User] Sort the results by exchange_rate descending.

[Assistant] SELECT * FROM healthcare.medical_records ORDER BY exchange_rate DESC;

[User] Show the results sorted by processed_at ascending.

[Assistant] SELECT * FROM healthcare.medical_records ORDER BY processed_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 transportation.reviews (
  comment_id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp without time zone,
  parent_id varchar,
  media_url char,
  subject char NOT NULL,
  views character varying(256) NOT NULL,
  tags character varying(128),
  product_id text -- reference to products.sku,
  FOREIGN KEY (product_id) REFERENCES products(sku)
)

CREATE TABLE transportation.products (
  sku text PRIMARY KEY -- unique identifier,
  published_at date,
  popularity_score character varying(128),
  views character varying(64) NOT NULL,
  description character varying(256),
  currency varchar NOT NULL,
  tax_rate varchar NOT NULL
)

CREATE TABLE transportation.stores (
  location_id integer PRIMARY KEY -- unique identifier,
  last_inspected timestamp without time zone,
  geo_point character varying(128),
  street varchar,
  longitude char NOT NULL,
  coordinates character varying(64),
  capacity character varying(256)
)

[User] List media_url, views, parent_id from reviews.

[Assistant] SELECT media_url, views, parent_id FROM transportation.reviews;

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

[Assistant] SELECT media_url, views, parent_id FROM transportation.reviews ORDER BY media_url ASC;

[User] Group reviews by product_id and show the count of parent_id.

[Assistant] SELECT product_id, COUNT(parent_id) AS count_parent_id FROM transportation.reviews GROUP BY product_id;


[User] Retrieve all reviews.

[Assistant] SELECT * FROM transportation.reviews;

[User] Find reviews where edited_at > '2023-01-01'.

[Assistant] SELECT * FROM transportation.reviews WHERE edited_at > '2023-01-01';

[User] Get count of edited_at by media_url from reviews.

[Assistant] SELECT media_url, COUNT(edited_at) AS count_edited_at FROM transportation.reviews GROUP BY media_url;


[User] Show me edited_at, product_id, tags for all reviews.

[Assistant] SELECT edited_at, product_id, tags FROM transportation.reviews;

[User] Show me parent_id, edited_at, description, published_at from reviews and their related products.

[Assistant] SELECT edited_at, product_id, tags, products.description, products.published_at FROM transportation.reviews JOIN transportation.products ON reviews.product_id = products.sku;

[User] Can you order these by parent_id descending?

[Assistant] SELECT edited_at, product_id, tags, products.description, products.published_at FROM transportation.reviews JOIN transportation.products ON reviews.product_id = products.sku ORDER BY parent_id DESC;


[User] Get views, product_id, edited_at from all reviews.

[Assistant] SELECT views, product_id, edited_at FROM transportation.reviews;

[User] List tags, product_id, tax_rate, views for each review along with their product information.

[Assistant] SELECT views, product_id, edited_at, products.tax_rate, products.views FROM transportation.reviews JOIN transportation.products ON reviews.product_id = products.sku;

[User] Calculate max of product_id for each media_url in reviews.

[Assistant] SELECT media_url, MAX(product_id) AS max_product_id FROM transportation.reviews GROUP BY media_url;


[User] List views, product_id, edited_at from reviews.

[Assistant] SELECT views, product_id, edited_at FROM transportation.reviews;

[User] Get parent_id, views, currency, published_at by joining reviews with products.

[Assistant] SELECT views, product_id, edited_at, products.currency, products.published_at FROM transportation.reviews JOIN transportation.products ON reviews.product_id = products.sku;

[User] Tally up reviews by views.

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


[User] List media_url, edited_at, views from reviews.

[Assistant] SELECT media_url, edited_at, views FROM transportation.reviews;

[User] What product_id, tags, published_at, popularity_score do we have for reviews and their associated products?

[Assistant] SELECT media_url, edited_at, views, products.published_at, products.popularity_score FROM transportation.reviews JOIN transportation.products ON reviews.product_id = products.sku;

[User] Order the output by views ascending.

[Assistant] SELECT media_url, edited_at, views, products.published_at, products.popularity_score FROM transportation.reviews JOIN transportation.products ON reviews.product_id = products.sku ORDER BY views ASC;


[User] List tags, subject, parent_id from reviews.

[Assistant] SELECT tags, subject, parent_id FROM transportation.reviews;

[User] Show the results sorted by views descending.

[Assistant] SELECT tags, subject, parent_id FROM transportation.reviews ORDER BY views DESC;

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

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


[User] Display all reviews.

[Assistant] SELECT * FROM transportation.reviews;

[User] Find reviews from last week.

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

[User] Sort the results by edited_at ascending.

[Assistant] SELECT * FROM transportation.reviews WHERE edited_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY edited_at ASC;


[User] Retrieve all reviews.

[Assistant] SELECT * FROM transportation.reviews;

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

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

[User] Limit the results to 50 rows.

[Assistant] SELECT * FROM transportation.reviews WHERE edited_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 50;


[User] Retrieve edited_at, subject, media_url for every review.

[Assistant] SELECT edited_at, subject, media_url FROM transportation.reviews;

[User] Show the results sorted by tags ascending.

[Assistant] SELECT edited_at, subject, media_url FROM transportation.reviews ORDER BY tags ASC;

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

[Assistant] SELECT parent_id, COUNT(*) AS count FROM transportation.reviews GROUP BY parent_id 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 retail.goods (
  product_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  updated_at date,
  media_url text NOT NULL,
  price numeric(38,14),
  image_url character varying(256),
  patient_id integer NOT NULL -- reference to patients.employee_id,
  FOREIGN KEY (patient_id) REFERENCES patients(employee_id)
)

CREATE TABLE retail.bookings (
  invoice_id integer PRIMARY KEY -- unique identifier,
  completed_at timestamp without time zone,
  payment_status text NOT NULL,
  delivery_status varchar,
  status text
)

CREATE TABLE retail.addresses (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  created_at timestamp,
  location_lat character varying(256) NOT NULL,
  accessibility character varying(256),
  operating_hours varchar,
  parking_available char,
  postal_code varchar
)

CREATE TABLE retail.patients (
  employee_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at timestamp without time zone,
  address character varying(64),
  age varchar,
  zip_code character varying(128),
  website character varying(256),
  city char
)

[User] Retrieve media_url, price, image_url for every good.

[Assistant] SELECT media_url, price, image_url FROM retail.goods;

[User] List media_url, created_at, zip_code, updated_at for each good along with their patient information.

[Assistant] SELECT media_url, price, image_url, patients.zip_code, patients.updated_at FROM retail.goods JOIN retail.patients ON goods.patient_id = patients.employee_id;

[User] Get max of created_at by patient_id from goods.

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


[User] What are the image_url, patient_id, media_url of each good?

[Assistant] SELECT image_url, patient_id, media_url FROM retail.goods;

[User] Show me created_at, media_url, city, age from goods and their related patients.

[Assistant] SELECT image_url, patient_id, media_url, patients.city, patients.age FROM retail.goods JOIN retail.patients ON goods.patient_id = patients.employee_id;

[User] Show the results sorted by updated_at descending.

[Assistant] SELECT image_url, patient_id, media_url, patients.city, patients.age FROM retail.goods JOIN retail.patients ON goods.patient_id = patients.employee_id ORDER BY updated_at DESC;


[User] Display all goods.

[Assistant] SELECT * FROM retail.goods;

[User] Show me created_at, media_url, website, age from goods and their related patients.

[Assistant] SELECT *, patients.website, patients.age FROM retail.goods JOIN retail.patients ON goods.patient_id = patients.employee_id;

[User] Only show the top 5 results.

[Assistant] SELECT *, patients.website, patients.age FROM retail.goods JOIN retail.patients ON goods.patient_id = patients.employee_id LIMIT 5;


[User] Get all goods.

[Assistant] SELECT * FROM retail.goods;

[User] Find goods from last week.

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

[User] Show me min of created_at grouped by updated_at for goods.

[Assistant] SELECT updated_at, MIN(created_at) AS min_created_at FROM retail.goods GROUP BY updated_at;


[User] Retrieve all goods.

[Assistant] SELECT * FROM retail.goods;

[User] Get all goods from last week.

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

[User] What is the average image_url for each patient_id in goods?

[Assistant] SELECT patient_id, AVERAGE(image_url) AS average_image_url FROM retail.goods GROUP BY patient_id;


[User] List all goods.

[Assistant] SELECT * FROM retail.goods;

[User] List goods that have price > 21.

[Assistant] SELECT * FROM retail.goods WHERE price > 21;

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

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


[User] Retrieve all goods.

[Assistant] SELECT * FROM retail.goods;

[User] Retrieve goods where price > 58.

[Assistant] SELECT * FROM retail.goods WHERE price > 58;

[User] Show only 10 records.

[Assistant] SELECT * FROM retail.goods WHERE price > 58 LIMIT 10;


[User] What are the media_url, image_url, patient_id of each good?

[Assistant] SELECT media_url, image_url, patient_id FROM retail.goods;

[User] Find goods where product_id LIKE 'A%'.

[Assistant] SELECT media_url, image_url, patient_id FROM retail.goods WHERE product_id LIKE 'A%';

[User] Tally up goods by image_url.

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


[User] Show me all goods.

[Assistant] SELECT * FROM retail.goods;

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

[Assistant] SELECT * FROM retail.goods WHERE media_url LIKE 'A%';

[User] Calculate min of patient_id for each media_url in goods.

[Assistant] SELECT media_url, MIN(patient_id) AS min_patient_id FROM retail.goods GROUP BY media_url;


[User] List patient_id, product_id, image_url from goods.

[Assistant] SELECT patient_id, product_id, image_url FROM retail.goods;

[User] Show me patient_id, media_url, city, address from goods and their related patients.

[Assistant] SELECT patient_id, product_id, image_url, patients.city, patients.address FROM retail.goods JOIN retail.patients ON goods.patient_id = patients.employee_id;

[User] How many goods are there per created_at?

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE marketing.reviews (
  comment_id varchar PRIMARY KEY -- unique identifier,
  edited_at timestamp without time zone,
  created_at date,
  message character varying(128),
  shares character varying(256) NOT NULL,
  visibility character varying(64),
  score character varying(128),
  thumbnail character varying(256) NOT NULL,
  image_url character varying(128),
  facilitie_id integer NOT NULL -- reference to facilities.address_id,
  FOREIGN KEY (facilitie_id) REFERENCES facilities(address_id)
)

CREATE TABLE marketing.facilities (
  address_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  type varchar,
  operating_hours character varying(64),
  accessibility character varying(64),
  location_lat character varying(64)
)

CREATE TABLE marketing.students (
  customer_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  website text NOT NULL,
  account_status varchar,
  api_key character varying(256) NOT NULL,
  facilitie_id integer -- reference to facilities.address_id,
  FOREIGN KEY (facilitie_id) REFERENCES facilities(address_id)
)

CREATE TABLE marketing.catalog (
  item_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  stock_level varchar,
  currency char NOT NULL,
  available char,
  thumbnail_url character varying(256),
  msrp text,
  featured_rank character varying(256) NOT NULL,
  review_id text -- reference to reviews.comment_id,
  FOREIGN KEY (review_id) REFERENCES reviews(comment_id)
)

[User] Get all students.

[Assistant] SELECT * FROM marketing.students;

[User] Sort the results by website ascending.

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

[User] Sort the results by facilitie_id descending.

[Assistant] SELECT * FROM marketing.students ORDER BY facilitie_id DESC;


[User] Get all students.

[Assistant] SELECT * FROM marketing.students;

[User] Show me students with api_key LIKE 'A%'.

[Assistant] SELECT * FROM marketing.students WHERE api_key LIKE 'A%';

[User] Restrict the output to 100 items.

[Assistant] SELECT * FROM marketing.students WHERE api_key LIKE 'A%' LIMIT 100;


[User] Retrieve all reviews.

[Assistant] SELECT * FROM marketing.reviews;

[User] Show me reviews with facilitie_id > 62.

[Assistant] SELECT * FROM marketing.reviews WHERE facilitie_id > 62;

[User] Sort the results by shares ascending.

[Assistant] SELECT * FROM marketing.reviews WHERE facilitie_id > 62 ORDER BY shares ASC;


[User] Retrieve all students.

[Assistant] SELECT * FROM marketing.students;

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

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

[User] Show the results sorted by website ascending.

[Assistant] SELECT * FROM marketing.students ORDER BY website 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 manufacturing.members (
  employee_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  is_active bit -- indicates if active is true,
  status character varying(64),
  profile_picture_url character varying(256),
  state character varying(128) NOT NULL,
  avatar character varying(128) NOT NULL,
  conten_id text NOT NULL -- reference to content.content_id,
  FOREIGN KEY (conten_id) REFERENCES content(content_id)
)

CREATE TABLE manufacturing.content (
  content_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  edited_at timestamp without time zone,
  reply_to_id text,
  likes text
)

CREATE TABLE manufacturing.facilities (
  id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  city varchar NOT NULL,
  timezone character varying(128) NOT NULL,
  postal_code char,
  zip_code char,
  category char NOT NULL,
  longitude char,
  location_lon varchar
)

[User] Display all members.

[Assistant] SELECT * FROM manufacturing.members;

[User] Order the output by profile_picture_url descending.

[Assistant] SELECT * FROM manufacturing.members ORDER BY profile_picture_url DESC;

[User] Group members by avatar and show the min of status.

[Assistant] SELECT avatar, MIN(status) AS min_status FROM manufacturing.members GROUP BY avatar;


[User] List conten_id, avatar, status from members.

[Assistant] SELECT conten_id, avatar, status FROM manufacturing.members;

[User] Retrieve avatar, state, reply_to_id, edited_at showing the relationship between members and content.

[Assistant] SELECT conten_id, avatar, status, content.reply_to_id, content.edited_at FROM manufacturing.members JOIN manufacturing.content ON members.conten_id = content.content_id;

[User] How many members are there per state?

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


[User] Display all members.

[Assistant] SELECT * FROM manufacturing.members;

[User] What conten_id, is_active, updated_at, likes do we have for members and their associated content?

[Assistant] SELECT *, content.updated_at, content.likes FROM manufacturing.members JOIN manufacturing.content ON members.conten_id = content.content_id;

[User] Tally up members by is_active.

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


[User] Retrieve avatar, profile_picture_url, updated_at for every member.

[Assistant] SELECT avatar, profile_picture_url, updated_at FROM manufacturing.members;

[User] Sort the results by conten_id ascending.

[Assistant] SELECT avatar, profile_picture_url, updated_at FROM manufacturing.members ORDER BY conten_id ASC;

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

[Assistant] SELECT avatar, profile_picture_url, updated_at FROM manufacturing.members ORDER BY status DESC;


[User] Show me all members.

[Assistant] SELECT * FROM manufacturing.members;

[User] List profile_picture_url, state, updated_at, edited_at for each member along with their content information.

[Assistant] SELECT *, content.updated_at, content.edited_at FROM manufacturing.members JOIN manufacturing.content ON members.conten_id = content.content_id;

[User] Restrict the output to 100 items.

[Assistant] SELECT *, content.updated_at, content.edited_at FROM manufacturing.members JOIN manufacturing.content ON members.conten_id = content.content_id LIMIT 100;


[User] Get all members.

[Assistant] SELECT * FROM manufacturing.members;

[User] Get status, is_active, reply_to_id, updated_at by joining members with content.

[Assistant] SELECT *, content.reply_to_id, content.updated_at FROM manufacturing.members JOIN manufacturing.content ON members.conten_id = content.content_id;

[User] Return just 5 rows.

[Assistant] SELECT *, content.reply_to_id, content.updated_at FROM manufacturing.members JOIN manufacturing.content ON members.conten_id = content.content_id LIMIT 5;


[User] Display all members.

[Assistant] SELECT * FROM manufacturing.members;

[User] Show the results sorted by avatar descending.

[Assistant] SELECT * FROM manufacturing.members ORDER BY avatar DESC;

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

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


[User] What are the status, avatar, profile_picture_url of each member?

[Assistant] SELECT status, avatar, profile_picture_url FROM manufacturing.members;

[User] Show the results sorted by updated_at descending.

[Assistant] SELECT status, avatar, profile_picture_url FROM manufacturing.members ORDER BY updated_at DESC;

[User] Restrict the output to 100 items.

[Assistant] SELECT status, avatar, profile_picture_url FROM manufacturing.members ORDER BY updated_at DESC LIMIT 100;


[User] Show me all members.

[Assistant] SELECT * FROM manufacturing.members;

[User] Retrieve avatar, conten_id, updated_at, likes showing the relationship between members and content.

[Assistant] SELECT *, content.updated_at, content.likes FROM manufacturing.members JOIN manufacturing.content ON members.conten_id = content.content_id;

[User] Restrict the output to 20 items.

[Assistant] SELECT *, content.updated_at, content.likes FROM manufacturing.members JOIN manufacturing.content ON members.conten_id = content.content_id LIMIT 20;


[User] Show me status, avatar, state for all members.

[Assistant] SELECT status, avatar, state FROM manufacturing.members;

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

[Assistant] SELECT status, avatar, state FROM manufacturing.members WHERE updated_at > '2023-12-01';

[User] Order the output by profile_picture_url descending.

[Assistant] SELECT status, avatar, state FROM manufacturing.members WHERE updated_at > '2023-12-01' ORDER BY profile_picture_url DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.payments (
  order_id integer PRIMARY KEY -- unique identifier,
  completed_at timestamp,
  processed_at timestamp,
  approval_status character varying(64),
  payment_status character varying(256),
  amount integer,
  total numeric(38,14),
  currency varchar,
  audit_id integer -- reference to audits.id,
  FOREIGN KEY (audit_id) REFERENCES audits(id)
)

CREATE TABLE finance.accounts (
  payment_id varchar PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  user_id character varying(256),
  credit character varying(64),
  exchange_rate character varying(256),
  verification_status char
)

CREATE TABLE finance.audits (
  id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp without time zone,
  updated_at date,
  image_url character varying(128),
  parent_id character varying(256) NOT NULL -- identifier for parent,
  keywords varchar,
  rating character varying(64),
  user_id character varying(256) NOT NULL -- identifier for user
)

[User] Show me currency, processed_at, audit_id for all payments.

[Assistant] SELECT currency, processed_at, audit_id FROM finance.payments;

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

[Assistant] SELECT currency, processed_at, audit_id FROM finance.payments WHERE approval_status LIKE 'A%';

[User] Show me count of total grouped by payment_status for payments.

[Assistant] SELECT payment_status, COUNT(total) AS count_total FROM finance.payments GROUP BY payment_status;


[User] Retrieve all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Find payments from last week.

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

[User] Sort the results by processed_at descending.

[Assistant] SELECT * FROM finance.payments WHERE completed_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY processed_at DESC;


[User] What are the currency, payment_status, completed_at of each payment?

[Assistant] SELECT currency, payment_status, completed_at FROM finance.payments;

[User] Get payments that match total > 95.

[Assistant] SELECT currency, payment_status, completed_at FROM finance.payments WHERE total > 95;

[User] How many payments are there per audit_id?

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


[User] Get processed_at, payment_status, currency from all payments.

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

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

[Assistant] SELECT processed_at, payment_status, currency FROM finance.payments WHERE approval_status LIKE 'A%';

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

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


[User] Retrieve all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Retrieve payment_status, audit_id, rating, updated_at showing the relationship between payments and audits.

[Assistant] SELECT *, audits.rating, audits.updated_at FROM finance.payments JOIN finance.audits ON payments.audit_id = audits.id;

[User] Limit the results to 10 rows.

[Assistant] SELECT *, audits.rating, audits.updated_at FROM finance.payments JOIN finance.audits ON payments.audit_id = audits.id LIMIT 10;


[User] Show me all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Find payments where amount > 49.

[Assistant] SELECT * FROM finance.payments WHERE amount > 49;

[User] How many payments are there per currency?

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


[User] What are the approval_status, audit_id, amount of each payment?

[Assistant] SELECT approval_status, audit_id, amount FROM finance.payments;

[User] Get total, currency, parent_id, edited_at by joining payments with audits.

[Assistant] SELECT approval_status, audit_id, amount, audits.parent_id, audits.edited_at FROM finance.payments JOIN finance.audits ON payments.audit_id = audits.id;

[User] What is the min total for each audit_id in payments?

[Assistant] SELECT audit_id, MIN(total) AS min_total FROM finance.payments GROUP BY audit_id;


[User] Show me processed_at, approval_status, completed_at for all payments.

[Assistant] SELECT processed_at, approval_status, completed_at FROM finance.payments;

[User] Get all payments between January and March.

[Assistant] SELECT processed_at, approval_status, completed_at FROM finance.payments WHERE processed_at BETWEEN '2023-01-01' AND '2023-03-31';

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

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


[User] What are the completed_at, audit_id, approval_status of each payment?

[Assistant] SELECT completed_at, audit_id, approval_status FROM finance.payments;

[User] Retrieve payment_status, total, edited_at, rating showing the relationship between payments and audits.

[Assistant] SELECT completed_at, audit_id, approval_status, audits.edited_at, audits.rating FROM finance.payments JOIN finance.audits ON payments.audit_id = audits.id;

[User] How many payments are there per total?

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


[User] Show me all payments.

[Assistant] SELECT * FROM finance.payments;

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

[Assistant] SELECT * FROM finance.payments WHERE currency LIKE 'A%';

[User] What is the average payment_status for each amount in payments?

[Assistant] SELECT amount, AVERAGE(payment_status) AS average_payment_status FROM finance.payments GROUP BY amount;


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.prescriptions (
  store_id text PRIMARY KEY -- unique identifier,
  last_inspected date,
  country varchar,
  timezone varchar,
  state character varying(128) NOT NULL,
  city character varying(256),
  name character varying(64) NOT NULL,
  accessibility varchar,
  doctor_id integer NOT NULL -- reference to doctors.payment_id,
  FOREIGN KEY (doctor_id) REFERENCES doctors(payment_id)
)

CREATE TABLE healthcare.doctors (
  payment_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  approval_status char,
  buyer_id char NOT NULL -- identifier for buyer,
  customer_id character varying(64) NOT NULL -- identifier for customer,
  delivery_status character varying(128),
  card_type text,
  prescription_id text -- reference to prescriptions.store_id,
  FOREIGN KEY (prescription_id) REFERENCES prescriptions(store_id)
)

[User] Show me all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] Get country, state, card_type, delivery_status by joining prescriptions with doctors.

[Assistant] SELECT *, doctors.card_type, doctors.delivery_status FROM healthcare.prescriptions JOIN healthcare.doctors ON prescriptions.doctor_id = doctors.payment_id;

[User] Get the distribution of prescriptions across different timezone values.

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


[User] List all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

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

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

[User] Tally up prescriptions by country.

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


[User] Get all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

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

[User] Can you order these by delivery_status descending?

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


[User] Show me city, accessibility, doctor_id for all prescriptions.

[Assistant] SELECT city, accessibility, doctor_id FROM healthcare.prescriptions;

[User] List prescriptions that have city LIKE 'A%'.

[Assistant] SELECT city, accessibility, doctor_id FROM healthcare.prescriptions WHERE city LIKE 'A%';

[User] Get the distribution of prescriptions across different doctor_id values.

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


[User] Show me accessibility, state, doctor_id for all prescriptions.

[Assistant] SELECT accessibility, state, doctor_id FROM healthcare.prescriptions;

[User] Show the results sorted by state ascending.

[Assistant] SELECT accessibility, state, doctor_id FROM healthcare.prescriptions ORDER BY state ASC;

[User] Get the distribution of prescriptions across different doctor_id values.

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


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

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

[User] Can you order these by card_type descending?

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


[User] Retrieve city, doctor_id, state for every prescription.

[Assistant] SELECT city, doctor_id, state FROM healthcare.prescriptions;

[User] Retrieve name, city, customer_id, prescription_id showing the relationship between prescriptions and doctors.

[Assistant] SELECT city, doctor_id, state, doctors.customer_id, doctors.prescription_id FROM healthcare.prescriptions JOIN healthcare.doctors ON prescriptions.doctor_id = doctors.payment_id;

[User] Group prescriptions by doctor_id and show the min of accessibility.

[Assistant] SELECT doctor_id, MIN(accessibility) AS min_accessibility FROM healthcare.prescriptions GROUP BY doctor_id;


[User] What are the customer_id, created_at, card_type of each doctor?

[Assistant] SELECT customer_id, created_at, card_type FROM healthcare.doctors;

[User] Order the output by approval_status ascending.

[Assistant] SELECT customer_id, created_at, card_type FROM healthcare.doctors ORDER BY approval_status ASC;

[User] Can you order these by customer_id ascending?

[Assistant] SELECT customer_id, created_at, card_type FROM healthcare.doctors ORDER BY customer_id ASC;


[User] Show me all prescriptions.

[Assistant] SELECT * FROM healthcare.prescriptions;

[User] List name, state, customer_id, card_type for each prescription along with their doctor information.

[Assistant] SELECT *, doctors.customer_id, doctors.card_type FROM healthcare.prescriptions JOIN healthcare.doctors ON prescriptions.doctor_id = doctors.payment_id;

[User] Show only 25 records.

[Assistant] SELECT *, doctors.customer_id, doctors.card_type FROM healthcare.prescriptions JOIN healthcare.doctors ON prescriptions.doctor_id = doctors.payment_id LIMIT 25;


[User] List all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Show me prescription_id, delivery_status, city, last_inspected from doctors and their related prescriptions.

[Assistant] SELECT *, prescriptions.city, prescriptions.last_inspected FROM healthcare.doctors JOIN healthcare.prescriptions ON doctors.prescription_id = prescriptions.store_id;

[User] Only show the top 25 results.

[Assistant] SELECT *, prescriptions.city, prescriptions.last_inspected FROM healthcare.doctors JOIN healthcare.prescriptions ON doctors.prescription_id = prescriptions.store_id LIMIT 25;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.departments (
  post_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  created_at timestamp without time zone,
  shares character varying(128),
  views varchar,
  description text NOT NULL,
  message char,
  subject character varying(128) NOT NULL,
  grade_id text -- reference to grades.transaction_id,
  FOREIGN KEY (grade_id) REFERENCES grades(transaction_id)
)

CREATE TABLE education.grades (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  user_id character varying(128),
  category character varying(128),
  notes character varying(128),
  status character varying(256),
  balance decimal,
  customer_id character varying(128) -- identifier for customer
)

CREATE TABLE education.enrollments (
  id text PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at date,
  vendor_id char -- identifier for vendor,
  approval_status varchar NOT NULL,
  verification_status character varying(128),
  payee_id character varying(128) -- identifier for payee,
  reconciliation_status char
)

CREATE TABLE education.courses (
  barcode text PRIMARY KEY -- unique identifier,
  updated_at date,
  media_url text,
  popularity_score character varying(256),
  image_url character varying(64),
  cost numeric,
  currency character varying(64) NOT NULL,
  enrollment_id text NOT NULL -- reference to enrollments.id,
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(id)
)

[User] Get all departments.

[Assistant] SELECT * FROM education.departments;

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

[Assistant] SELECT * FROM education.departments ORDER BY created_at DESC;

[User] Restrict the output to 5 items.

[Assistant] SELECT * FROM education.departments ORDER BY created_at DESC LIMIT 5;


[User] Retrieve all departments.

[Assistant] SELECT * FROM education.departments;

[User] List departments that have description LIKE 'A%'.

[Assistant] SELECT * FROM education.departments WHERE description LIKE 'A%';

[User] What is the min views for each created_at in departments?

[Assistant] SELECT created_at, MIN(views) AS min_views FROM education.departments GROUP BY created_at;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.investments (
  venue_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at timestamp,
  description text,
  capacity text,
  parking_available varchar,
  geo_point character varying(256),
  payment_id text NOT NULL -- reference to payments.invoice_id,
  FOREIGN KEY (payment_id) REFERENCES payments(invoice_id)
)

CREATE TABLE finance.payments (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  traded_at timestamp,
  currency character varying(256),
  payment_status text NOT NULL,
  approval_status varchar,
  card_type character varying(256),
  investment_id integer NOT NULL -- reference to investments.venue_id,
  FOREIGN KEY (investment_id) REFERENCES investments(venue_id)
)

[User] Show me all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

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

[Assistant] SELECT * FROM finance.payments WHERE traded_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY currency ASC;


[User] List description, geo_point, capacity from investments.

[Assistant] SELECT description, geo_point, capacity FROM finance.investments;

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

[Assistant] SELECT description, geo_point, capacity FROM finance.investments WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Can you order these by description descending?

[Assistant] SELECT description, geo_point, capacity FROM finance.investments WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY description DESC;


[User] List all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Retrieve investments where description LIKE 'A%'.

[Assistant] SELECT * FROM finance.investments WHERE description LIKE 'A%';

[User] Restrict the output to 25 items.

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


[User] Retrieve all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Can you order these by updated_at ascending?

[Assistant] SELECT * FROM finance.investments ORDER BY updated_at ASC;

[User] Show only 20 records.

[Assistant] SELECT * FROM finance.investments ORDER BY updated_at ASC LIMIT 20;


[User] Show me currency, card_type, payment_status for all payments.

[Assistant] SELECT currency, card_type, payment_status FROM finance.payments;

[User] List currency, traded_at, description, updated_at for each payment along with their investment information.

[Assistant] SELECT currency, card_type, payment_status, investments.description, investments.updated_at FROM finance.payments JOIN finance.investments ON payments.investment_id = investments.venue_id;

[User] Show the results sorted by traded_at descending.

[Assistant] SELECT currency, card_type, payment_status, investments.description, investments.updated_at FROM finance.payments JOIN finance.investments ON payments.investment_id = investments.venue_id ORDER BY traded_at DESC;


[User] Get updated_at, payment_id, geo_point from all investments.

[Assistant] SELECT updated_at, payment_id, geo_point FROM finance.investments;

[User] Retrieve investments where geo_point LIKE 'A%'.

[Assistant] SELECT updated_at, payment_id, geo_point FROM finance.investments WHERE geo_point LIKE 'A%';

[User] Get the distribution of investments across different parking_available values.

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


[User] Display all investments.

[Assistant] SELECT * FROM finance.investments;

[User] List payment_id, created_at, approval_status, investment_id for each investment along with their payment information.

[Assistant] SELECT *, payments.approval_status, payments.investment_id FROM finance.investments JOIN finance.payments ON investments.payment_id = payments.invoice_id;

[User] How many investments are there per payment_id?

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


[User] What are the capacity, geo_point, parking_available of each investment?

[Assistant] SELECT capacity, geo_point, parking_available FROM finance.investments;

[User] Show me created_at, parking_available, investment_id, currency from investments and their related payments.

[Assistant] SELECT capacity, geo_point, parking_available, payments.investment_id, payments.currency FROM finance.investments JOIN finance.payments ON investments.payment_id = payments.invoice_id;

[User] Return just 100 rows.

[Assistant] SELECT capacity, geo_point, parking_available, payments.investment_id, payments.currency FROM finance.investments JOIN finance.payments ON investments.payment_id = payments.invoice_id LIMIT 100;


[User] Get all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Find investments from last week.

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

[User] Sort the results by parking_available ascending.

[Assistant] SELECT * FROM finance.investments WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY parking_available ASC;


[User] Retrieve parking_available, updated_at, created_at for every investment.

[Assistant] SELECT parking_available, updated_at, created_at FROM finance.investments;

[User] Sort the results by geo_point ascending.

[Assistant] SELECT parking_available, updated_at, created_at FROM finance.investments ORDER BY geo_point ASC;

[User] Show me average of capacity grouped by payment_id for investments.

[Assistant] SELECT payment_id, AVERAGE(capacity) AS average_capacity FROM finance.investments GROUP BY payment_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.customers (
  user_id integer PRIMARY KEY -- unique identifier,
  last_active timestamp,
  updated_at date,
  gender character varying(256) NOT NULL,
  full_name char NOT NULL,
  bio varchar,
  investment_id text -- reference to investments.person_id,
  FOREIGN KEY (investment_id) REFERENCES investments(person_id)
)

CREATE TABLE finance.investments (
  person_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  language character varying(128),
  display_name text,
  bio varchar NOT NULL,
  website character varying(64) NOT NULL,
  timezone character varying(256) NOT NULL,
  is_active boolean -- indicates if active is true,
  customer_id integer NOT NULL -- reference to customers.user_id,
  FOREIGN KEY (customer_id) REFERENCES customers(user_id)
)

[User] List all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Show only 20 records.

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


[User] Get all investments.

[Assistant] SELECT * FROM finance.investments;

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

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

[User] Show me the count of investments grouped by language.

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


[User] Retrieve all customers.

[Assistant] SELECT * FROM finance.customers;

[User] List gender, investment_id, website, language for each customer along with their investment information.

[Assistant] SELECT *, investments.website, investments.language FROM finance.customers JOIN finance.investments ON customers.investment_id = investments.person_id;

[User] Can you order these by updated_at ascending?

[Assistant] SELECT *, investments.website, investments.language FROM finance.customers JOIN finance.investments ON customers.investment_id = investments.person_id ORDER BY updated_at ASC;


[User] Get bio, is_active, display_name from all investments.

[Assistant] SELECT bio, is_active, display_name FROM finance.investments;

[User] Find investments between January and March.

[Assistant] SELECT bio, is_active, display_name FROM finance.investments WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Calculate sum of is_active for each is_active in investments.

[Assistant] SELECT is_active, SUM(is_active) AS sum_is_active FROM finance.investments GROUP BY is_active;


[User] List gender, full_name, investment_id from customers.

[Assistant] SELECT gender, full_name, investment_id FROM finance.customers;

[User] Can you order these by gender descending?

[Assistant] SELECT gender, full_name, investment_id FROM finance.customers ORDER BY gender DESC;

[User] Tally up customers by last_active.

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


[User] Get all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Get investments that match is_active = TRUE.

[Assistant] SELECT * FROM finance.investments WHERE is_active = TRUE;

[User] Limit the results to 25 rows.

[Assistant] SELECT * FROM finance.investments WHERE is_active = TRUE LIMIT 25;


[User] Show me updated_at, website, language for all investments.

[Assistant] SELECT updated_at, website, language FROM finance.investments;

[User] List bio, is_active, updated_at, investment_id for each investment along with their customer information.

[Assistant] SELECT updated_at, website, language, customers.updated_at, customers.investment_id FROM finance.investments JOIN finance.customers ON investments.customer_id = customers.user_id;

[User] Limit the results to 100 rows.

[Assistant] SELECT updated_at, website, language, customers.updated_at, customers.investment_id FROM finance.investments JOIN finance.customers ON investments.customer_id = customers.user_id LIMIT 100;


[User] List is_active, language, customer_id from investments.

[Assistant] SELECT is_active, language, customer_id FROM finance.investments;

[User] Can you order these by display_name descending?

[Assistant] SELECT is_active, language, customer_id FROM finance.investments ORDER BY display_name DESC;

[User] Show me the count of investments grouped by display_name.

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


[User] Retrieve all investments.

[Assistant] SELECT * FROM finance.investments;

[User] List timezone, is_active, investment_id, gender for each investment along with their customer information.

[Assistant] SELECT *, customers.investment_id, customers.gender FROM finance.investments JOIN finance.customers ON investments.customer_id = customers.user_id;

[User] Show me the count of investments grouped by customer_id.

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


[User] Retrieve full_name, bio, investment_id for every customer.

[Assistant] SELECT full_name, bio, investment_id FROM finance.customers;

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

[Assistant] SELECT full_name, bio, investment_id FROM finance.customers WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Return just 15 rows.

[Assistant] SELECT full_name, bio, investment_id FROM finance.customers WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' 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 finance.transactions (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  traded_at timestamp without time zone,
  discount integer NOT NULL,
  fee character varying(128)
)

CREATE TABLE finance.investments (
  product_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  expires_at timestamp without time zone,
  msrp char NOT NULL,
  name character varying(256),
  price numeric(38,14),
  customer_id integer -- reference to customers.user_id,
  FOREIGN KEY (customer_id) REFERENCES customers(user_id)
)

CREATE TABLE finance.customers (
  user_id integer PRIMARY KEY -- unique identifier,
  joined_at date,
  updated_at timestamp without time zone,
  full_name text,
  zip_code char,
  membership_level character varying(128),
  account_status character varying(64),
  is_active bit NOT NULL -- indicates if active is true
)

[User] Get all investments.

[Assistant] SELECT * FROM finance.investments;

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

[Assistant] SELECT * FROM finance.investments WHERE expires_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Sort the results by product_id descending.

[Assistant] SELECT * FROM finance.investments WHERE expires_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY product_id DESC;


[User] List all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Get investments that match msrp LIKE 'A%'.

[Assistant] SELECT * FROM finance.investments WHERE msrp LIKE 'A%';

[User] Tally up investments by name.

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


[User] Get product_id, expires_at, price from all investments.

[Assistant] SELECT product_id, expires_at, price FROM finance.investments;

[User] Find investments from 2023.

[Assistant] SELECT product_id, expires_at, price FROM finance.investments WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Group investments by expires_at and show the min of price.

[Assistant] SELECT expires_at, MIN(price) AS min_price FROM finance.investments GROUP BY expires_at;


[User] Get all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Get all investments from 2023.

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

[User] Show me the count of investments grouped by name.

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


[User] Display all investments.

[Assistant] SELECT * FROM finance.investments;

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

[Assistant] SELECT * FROM finance.investments ORDER BY created_at DESC;

[User] What is the max expires_at for each product_id in investments?

[Assistant] SELECT product_id, MAX(expires_at) AS max_expires_at FROM finance.investments GROUP BY product_id;


[User] Show me all investments.

[Assistant] SELECT * FROM finance.investments;

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

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

[User] Calculate max of customer_id for each name in investments.

[Assistant] SELECT name, MAX(customer_id) AS max_customer_id FROM finance.investments GROUP BY name;


[User] What are the price, product_id, name of each investment?

[Assistant] SELECT price, product_id, name FROM finance.investments;

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

[Assistant] SELECT price, product_id, name FROM finance.investments WHERE created_at > '2023-01-01';

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

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


[User] Get customer_id, created_at, price from all investments.

[Assistant] SELECT customer_id, created_at, price FROM finance.investments;

[User] Can you order these by created_at ascending?

[Assistant] SELECT customer_id, created_at, price FROM finance.investments ORDER BY created_at ASC;

[User] Can you order these by created_at ascending?

[Assistant] SELECT customer_id, created_at, price FROM finance.investments ORDER BY created_at ASC;


[User] Get msrp, expires_at, price from all investments.

[Assistant] SELECT msrp, expires_at, price FROM finance.investments;

[User] Sort the results by expires_at descending.

[Assistant] SELECT msrp, expires_at, price FROM finance.investments ORDER BY expires_at DESC;

[User] Get min of customer_id by customer_id from investments.

[Assistant] SELECT customer_id, MIN(customer_id) AS min_customer_id FROM finance.investments GROUP BY customer_id;


[User] Retrieve all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Retrieve investments where customer_id > 76.

[Assistant] SELECT * FROM finance.investments WHERE customer_id > 76;

[User] Show the results sorted by customer_id ascending.

[Assistant] SELECT * FROM finance.investments WHERE customer_id > 76 ORDER BY customer_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 manufacturing.addresses (
  venue_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  last_inspected date,
  latitude character varying(256),
  location_lon text NOT NULL,
  street char,
  location_lat character varying(256) NOT NULL,
  coordinates character varying(128),
  timezone character varying(128),
  zip_code character varying(256)
)

CREATE TABLE manufacturing.content (
  id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  media_url text NOT NULL,
  keywords text NOT NULL,
  image_url character varying(128),
  description text
)

CREATE TABLE manufacturing.catalog (
  sku character varying(64) NOT NULL -- unique identifier,
  published_at timestamp,
  subcategory character varying(256) NOT NULL,
  currency char NOT NULL,
  reserved character varying(256),
  media_url character varying(128),
  msrp varchar,
  conten_id text NOT NULL -- reference to content.id,
  FOREIGN KEY (conten_id) REFERENCES content(id)
)

CREATE TABLE manufacturing.accounts (
  transaction_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  status char,
  customer_id character varying(64) -- identifier for customer,
  user_id character varying(256),
  description character varying(128),
  invoice_number character varying(64) NOT NULL
)

[User] Show me all catalog.

[Assistant] SELECT * FROM manufacturing.catalog;

[User] Find catalog older than 6 months.

[Assistant] SELECT * FROM manufacturing.catalog WHERE published_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Restrict the output to 50 items.

[Assistant] SELECT * FROM manufacturing.catalog WHERE published_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 50;


[User] Retrieve reserved, media_url, conten_id for every catalog.

[Assistant] SELECT reserved, media_url, conten_id FROM manufacturing.catalog;

[User] Can you order these by conten_id ascending?

[Assistant] SELECT reserved, media_url, conten_id FROM manufacturing.catalog ORDER BY conten_id ASC;

[User] Only show the top 15 results.

[Assistant] SELECT reserved, media_url, conten_id FROM manufacturing.catalog ORDER BY conten_id ASC LIMIT 15;


[User] Get all catalog.

[Assistant] SELECT * FROM manufacturing.catalog;

[User] List catalog with dates created yesterday.

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

[User] Tally up catalog by published_at.

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


[User] Retrieve all catalog.

[Assistant] SELECT * FROM manufacturing.catalog;

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

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

[User] Restrict the output to 20 items.

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


[User] Display all catalog.

[Assistant] SELECT * FROM manufacturing.catalog;

[User] Retrieve currency, media_url, image_url, created_at showing the relationship between catalog and content.

[Assistant] SELECT *, content.image_url, content.created_at FROM manufacturing.catalog JOIN manufacturing.content ON catalog.conten_id = content.id;

[User] Return just 15 rows.

[Assistant] SELECT *, content.image_url, content.created_at FROM manufacturing.catalog JOIN manufacturing.content ON catalog.conten_id = content.id LIMIT 15;


[User] Retrieve conten_id, sku, published_at for every catalog.

[Assistant] SELECT conten_id, sku, published_at FROM manufacturing.catalog;

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

[Assistant] SELECT conten_id, sku, published_at FROM manufacturing.catalog ORDER BY msrp DESC;

[User] Show me max of currency grouped by subcategory for catalog.

[Assistant] SELECT subcategory, MAX(currency) AS max_currency FROM manufacturing.catalog GROUP BY subcategory;


[User] Get all catalog.

[Assistant] SELECT * FROM manufacturing.catalog;

[User] Show the results sorted by msrp ascending.

[Assistant] SELECT * FROM manufacturing.catalog ORDER BY msrp ASC;

[User] Show the results sorted by media_url ascending.

[Assistant] SELECT * FROM manufacturing.catalog ORDER BY media_url ASC;


[User] Get all catalog.

[Assistant] SELECT * FROM manufacturing.catalog;

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

[Assistant] SELECT * FROM manufacturing.catalog WHERE published_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Show me the count of catalog grouped by reserved.

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


[User] List conten_id, reserved, msrp from catalog.

[Assistant] SELECT conten_id, reserved, msrp FROM manufacturing.catalog;

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

[Assistant] SELECT conten_id, reserved, msrp FROM manufacturing.catalog WHERE published_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Sort the results by reserved ascending.

[Assistant] SELECT conten_id, reserved, msrp FROM manufacturing.catalog WHERE published_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY reserved ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.departments (
  id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  payment_status character varying(128) NOT NULL,
  customer_id char -- identifier for customer,
  approval_status char,
  tax numeric(38,14),
  enrollment_id integer NOT NULL -- reference to enrollments.employee_id,
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(employee_id)
)

CREATE TABLE education.students (
  customer_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  last_active date,
  gender char,
  membership_level character varying(128),
  api_key character varying(256),
  language character varying(64),
  is_verified boolean,
  password_hash character varying(256) NOT NULL,
  nationality character varying(256)
)

CREATE TABLE education.courses (
  id integer PRIMARY KEY -- unique identifier,
  created_at date,
  score char,
  attachment_url text NOT NULL,
  description char NOT NULL,
  thumbnail text,
  visibility varchar NOT NULL,
  content varchar NOT NULL,
  student_id integer -- reference to students.customer_id,
  FOREIGN KEY (student_id) REFERENCES students(customer_id)
)

CREATE TABLE education.enrollments (
  employee_id integer PRIMARY KEY -- unique identifier,
  last_active timestamp,
  updated_at date,
  password_hash varchar,
  membership_level character varying(64) NOT NULL,
  username text NOT NULL,
  department_id text NOT NULL -- reference to departments.id,
  FOREIGN KEY (department_id) REFERENCES departments(id)
)

[User] Show me all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Find enrollments where department_id LIKE 'A%'.

[Assistant] SELECT * FROM education.enrollments WHERE department_id LIKE 'A%';

[User] Can you order these by username descending?

[Assistant] SELECT * FROM education.enrollments WHERE department_id LIKE 'A%' ORDER BY username DESC;


[User] Show me all courses.

[Assistant] SELECT * FROM education.courses;

[User] Order the output by created_at ascending.

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

[User] Return just 100 rows.

[Assistant] SELECT * FROM education.courses ORDER BY created_at ASC 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 education.enrollments (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  traded_at timestamp without time zone,
  processed_at timestamp without time zone,
  exchange_rate char,
  status character varying(128) NOT NULL,
  user_id text -- identifier for user,
  amount integer,
  total decimal NOT NULL,
  subtotal numeric
)

CREATE TABLE education.departments (
  venue_id character varying(64) NOT NULL -- unique identifier,
  last_inspected timestamp,
  updated_at timestamp without time zone,
  capacity varchar NOT NULL,
  address_line2 character varying(128),
  type char,
  category character varying(64) NOT NULL,
  name character varying(64) NOT NULL,
  parking_available character varying(128),
  teacher_id integer -- reference to teachers.user_id,
  FOREIGN KEY (teacher_id) REFERENCES teachers(user_id)
)

CREATE TABLE education.teachers (
  user_id integer PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  api_key character varying(64),
  avatar character varying(128),
  birth_date timestamp without time zone NOT NULL,
  is_verified bit -- indicates if verified is true,
  membership_level character varying(256) NOT NULL,
  token text NOT NULL
)

[User] List last_inspected, type, name from departments.

[Assistant] SELECT last_inspected, type, name FROM education.departments;

[User] Can you order these by address_line2 descending?

[Assistant] SELECT last_inspected, type, name FROM education.departments ORDER BY address_line2 DESC;

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

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


[User] List all departments.

[Assistant] SELECT * FROM education.departments;

[User] List departments that have name LIKE 'A%'.

[Assistant] SELECT * FROM education.departments WHERE name LIKE 'A%';

[User] Count the number of departments in each last_inspected category.

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


[User] Display all departments.

[Assistant] SELECT * FROM education.departments;

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

[Assistant] SELECT * FROM education.departments WHERE parking_available LIKE 'A%';

[User] Limit the results to 25 rows.

[Assistant] SELECT * FROM education.departments WHERE parking_available LIKE 'A%' LIMIT 25;


[User] Show me all departments.

[Assistant] SELECT * FROM education.departments;

[User] List departments that have teacher_id > 48.

[Assistant] SELECT * FROM education.departments WHERE teacher_id > 48;

[User] Order the output by name descending.

[Assistant] SELECT * FROM education.departments WHERE teacher_id > 48 ORDER BY name DESC;


[User] Display all departments.

[Assistant] SELECT * FROM education.departments;

[User] Sort the results by teacher_id descending.

[Assistant] SELECT * FROM education.departments ORDER BY teacher_id DESC;

[User] Calculate sum of name for each last_inspected in departments.

[Assistant] SELECT last_inspected, SUM(name) AS sum_name FROM education.departments GROUP BY last_inspected;


[User] Display all departments.

[Assistant] SELECT * FROM education.departments;

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

[Assistant] SELECT * FROM education.departments WHERE type LIKE 'A%';

[User] Group departments by name and show the sum of category.

[Assistant] SELECT name, SUM(category) AS sum_category FROM education.departments GROUP BY name;


[User] List all departments.

[Assistant] SELECT * FROM education.departments;

[User] Show me departments that were created yesterday.

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

[User] Tally up departments by capacity.

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


[User] Show me all departments.

[Assistant] SELECT * FROM education.departments;

[User] Find departments where address_line2 LIKE 'A%'.

[Assistant] SELECT * FROM education.departments WHERE address_line2 LIKE 'A%';

[User] Restrict the output to 100 items.

[Assistant] SELECT * FROM education.departments WHERE address_line2 LIKE 'A%' LIMIT 100;


[User] Show me teacher_id, venue_id, type for all departments.

[Assistant] SELECT teacher_id, venue_id, type FROM education.departments;

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

[Assistant] SELECT teacher_id, venue_id, type FROM education.departments WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Tally up departments by name.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE sports.sales (
  payment_id text PRIMARY KEY -- unique identifier,
  completed_at date,
  approval_status text NOT NULL,
  status varchar,
  payment_method character varying(128) NOT NULL,
  payment_status varchar,
  discount integer,
  merchandis_id text NOT NULL -- reference to merchandise.id,
  FOREIGN KEY (merchandis_id) REFERENCES merchandise(id)
)

CREATE TABLE sports.merchandise (
  id text PRIMARY KEY -- unique identifier,
  published_at date,
  views char,
  rating character varying(128),
  cost smallint NOT NULL
)

[User] Retrieve approval_status, discount, payment_method for every sale.

[Assistant] SELECT approval_status, discount, payment_method FROM sports.sales;

[User] Show me discount, status, cost, published_at from sales and their related merchandise.

[Assistant] SELECT approval_status, discount, payment_method, merchandise.cost, merchandise.published_at FROM sports.sales JOIN sports.merchandise ON sales.merchandis_id = merchandise.id;

[User] Only show the top 100 results.

[Assistant] SELECT approval_status, discount, payment_method, merchandise.cost, merchandise.published_at FROM sports.sales JOIN sports.merchandise ON sales.merchandis_id = merchandise.id LIMIT 100;


[User] Retrieve merchandis_id, completed_at, payment_method for every sale.

[Assistant] SELECT merchandis_id, completed_at, payment_method FROM sports.sales;

[User] Show me merchandis_id, status, published_at, cost from sales and their related merchandise.

[Assistant] SELECT merchandis_id, completed_at, payment_method, merchandise.published_at, merchandise.cost FROM sports.sales JOIN sports.merchandise ON sales.merchandis_id = merchandise.id;

[User] Get min of status by approval_status from sales.

[Assistant] SELECT approval_status, MIN(status) AS min_status FROM sports.sales GROUP BY approval_status;


[User] Display all sales.

[Assistant] SELECT * FROM sports.sales;

[User] Get status, approval_status, published_at, cost by joining sales with merchandise.

[Assistant] SELECT *, merchandise.published_at, merchandise.cost FROM sports.sales JOIN sports.merchandise ON sales.merchandis_id = merchandise.id;

[User] Show only 15 records.

[Assistant] SELECT *, merchandise.published_at, merchandise.cost FROM sports.sales JOIN sports.merchandise ON sales.merchandis_id = merchandise.id LIMIT 15;


[User] Display all sales.

[Assistant] SELECT * FROM sports.sales;

[User] Retrieve sales where status LIKE 'A%'.

[Assistant] SELECT * FROM sports.sales WHERE status LIKE 'A%';

[User] Sort the results by payment_method ascending.

[Assistant] SELECT * FROM sports.sales WHERE status LIKE 'A%' ORDER BY payment_method ASC;


[User] Retrieve payment_method, completed_at, discount for every sale.

[Assistant] SELECT payment_method, completed_at, discount FROM sports.sales;

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

[Assistant] SELECT payment_method, completed_at, discount FROM sports.sales ORDER BY completed_at ASC;

[User] Only show the top 25 results.

[Assistant] SELECT payment_method, completed_at, discount FROM sports.sales ORDER BY completed_at ASC LIMIT 25;


[User] Get completed_at, payment_status, merchandis_id from all sales.

[Assistant] SELECT completed_at, payment_status, merchandis_id FROM sports.sales;

[User] List payment_status, status, cost, published_at for each sale along with their merchandise information.

[Assistant] SELECT completed_at, payment_status, merchandis_id, merchandise.cost, merchandise.published_at FROM sports.sales JOIN sports.merchandise ON sales.merchandis_id = merchandise.id;

[User] Restrict the output to 25 items.

[Assistant] SELECT completed_at, payment_status, merchandis_id, merchandise.cost, merchandise.published_at FROM sports.sales JOIN sports.merchandise ON sales.merchandis_id = merchandise.id LIMIT 25;


[User] List payment_method, merchandis_id, completed_at from sales.

[Assistant] SELECT payment_method, merchandis_id, completed_at FROM sports.sales;

[User] Get status, payment_status, published_at, cost by joining sales with merchandise.

[Assistant] SELECT payment_method, merchandis_id, completed_at, merchandise.published_at, merchandise.cost FROM sports.sales JOIN sports.merchandise ON sales.merchandis_id = merchandise.id;

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

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


[User] Show me payment_status, completed_at, merchandis_id for all sales.

[Assistant] SELECT payment_status, completed_at, merchandis_id FROM sports.sales;

[User] Show me status, approval_status, cost, published_at from sales and their related merchandise.

[Assistant] SELECT payment_status, completed_at, merchandis_id, merchandise.cost, merchandise.published_at FROM sports.sales JOIN sports.merchandise ON sales.merchandis_id = merchandise.id;

[User] Show me the count of sales grouped by completed_at.

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


[User] Get payment_method, completed_at, approval_status from all sales.

[Assistant] SELECT payment_method, completed_at, approval_status FROM sports.sales;

[User] Show the results sorted by completed_at descending.

[Assistant] SELECT payment_method, completed_at, approval_status FROM sports.sales ORDER BY completed_at DESC;

[User] Restrict the output to 5 items.

[Assistant] SELECT payment_method, completed_at, approval_status FROM sports.sales ORDER BY completed_at DESC LIMIT 5;


[User] Show me status, payment_method, completed_at for all sales.

[Assistant] SELECT status, payment_method, completed_at FROM sports.sales;

[User] Can you order these by approval_status ascending?

[Assistant] SELECT status, payment_method, completed_at FROM sports.sales ORDER BY approval_status ASC;

[User] Tally up sales by approval_status.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.messages (
  comment_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp,
  edited_at date,
  title char,
  author_id character varying(128) NOT NULL -- identifier for author,
  thumbnail char NOT NULL,
  likes char,
  subject character varying(64),
  media_url text
)

CREATE TABLE socialmedia.posts (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  user_id character varying(64),
  description character varying(256),
  subject character varying(256),
  content text,
  media_url char,
  views character varying(256) NOT NULL,
  author_id varchar -- identifier for author
)

[User] Get comment_id, published_at, subject from all messages.

[Assistant] SELECT comment_id, published_at, subject FROM socialmedia.messages;

[User] Find messages where published_at > '2023-01-01'.

[Assistant] SELECT comment_id, published_at, subject FROM socialmedia.messages WHERE published_at > '2023-01-01';

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

[Assistant] SELECT comment_id, published_at, subject FROM socialmedia.messages WHERE published_at > '2023-01-01' ORDER BY author_id DESC;


[User] Display all posts.

[Assistant] SELECT * FROM socialmedia.posts;

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

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

[User] Restrict the output to 20 items.

[Assistant] SELECT * FROM socialmedia.posts WHERE updated_at > '2023-12-01' LIMIT 20;


[User] Show me likes, title, edited_at for all messages.

[Assistant] SELECT likes, title, edited_at FROM socialmedia.messages;

[User] Get all messages from 2023.

[Assistant] SELECT likes, title, edited_at FROM socialmedia.messages WHERE published_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Show me average of title grouped by likes for messages.

[Assistant] SELECT likes, AVERAGE(title) AS average_title FROM socialmedia.messages GROUP BY likes;


[User] Retrieve title, author_id, thumbnail for every message.

[Assistant] SELECT title, author_id, thumbnail FROM socialmedia.messages;

[User] Get messages that match edited_at > '2023-01-01'.

[Assistant] SELECT title, author_id, thumbnail FROM socialmedia.messages WHERE edited_at > '2023-01-01';

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

[Assistant] SELECT title, author_id, thumbnail FROM socialmedia.messages WHERE edited_at > '2023-01-01' ORDER BY published_at DESC;


[User] Get comment_id, thumbnail, likes from all messages.

[Assistant] SELECT comment_id, thumbnail, likes FROM socialmedia.messages;

[User] Get all messages older than 6 months.

[Assistant] SELECT comment_id, thumbnail, likes FROM socialmedia.messages WHERE published_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Show the results sorted by published_at descending.

[Assistant] SELECT comment_id, thumbnail, likes FROM socialmedia.messages WHERE published_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY published_at DESC;


[User] Retrieve all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Get all messages between January and March.

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

[User] Order the output by published_at descending.

[Assistant] SELECT * FROM socialmedia.messages WHERE edited_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY published_at DESC;


[User] Retrieve all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Show the results sorted by comment_id descending.

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

[User] Show the results sorted by title ascending.

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


[User] Display all posts.

[Assistant] SELECT * FROM socialmedia.posts;

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

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

[User] Limit the results to 50 rows.

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


[User] Get edited_at, title, subject from all messages.

[Assistant] SELECT edited_at, title, subject FROM socialmedia.messages;

[User] Find messages modified within the last hour.

[Assistant] SELECT edited_at, title, subject FROM socialmedia.messages WHERE published_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Calculate sum of published_at for each thumbnail in messages.

[Assistant] SELECT thumbnail, SUM(published_at) AS sum_published_at FROM socialmedia.messages GROUP BY thumbnail;


[User] Retrieve all messages.

[Assistant] SELECT * FROM socialmedia.messages;

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

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

[User] Tally up messages by media_url.

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