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 logistics.catalog (
  id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  featured_rank char,
  backorder varchar,
  image_url character varying(256),
  branche_id integer NOT NULL -- reference to branches.store_id,
  FOREIGN KEY (branche_id) REFERENCES branches(store_id)
)

CREATE TABLE logistics.branches (
  store_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  last_inspected timestamp without time zone,
  parking_available char,
  accessibility text,
  location_lat varchar,
  longitude char,
  coordinates character varying(256),
  city character varying(256) NOT NULL,
  message_id integer -- reference to messages.message_id,
  FOREIGN KEY (message_id) REFERENCES messages(message_id)
)

CREATE TABLE logistics.messages (
  message_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  likes character varying(128),
  thumbnail character varying(256) NOT NULL,
  attachment_url character varying(128),
  parent_id character varying(128),
  media_url character varying(64),
  reply_to_id character varying(64),
  branche_id integer -- reference to branches.store_id,
  FOREIGN KEY (branche_id) REFERENCES branches(store_id)
)

[User] Display all catalog.

[Assistant] SELECT * FROM logistics.catalog;

[User] Show the results sorted by updated_at descending.

[Assistant] SELECT * FROM logistics.catalog ORDER BY updated_at DESC;

[User] Group catalog by image_url and show the sum of updated_at.

[Assistant] SELECT image_url, SUM(updated_at) AS sum_updated_at FROM logistics.catalog GROUP BY image_url;


[User] List city, coordinates, location_lat from branches.

[Assistant] SELECT city, coordinates, location_lat FROM logistics.branches;

[User] Get parking_available, accessibility, attachment_url, parent_id by joining branches with messages.

[Assistant] SELECT city, coordinates, location_lat, messages.attachment_url, messages.parent_id FROM logistics.branches JOIN logistics.messages ON branches.message_id = messages.message_id;

[User] What is the count location_lat for each coordinates in branches?

[Assistant] SELECT coordinates, COUNT(location_lat) AS count_location_lat FROM logistics.branches GROUP BY coordinates;


[User] Show me all branches.

[Assistant] SELECT * FROM logistics.branches;

[User] Find branches older than 6 months.

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

[User] Return just 10 rows.

[Assistant] SELECT * FROM logistics.branches WHERE last_inspected <= CURRENT_DATE - INTERVAL '6 months' LIMIT 10;


[User] Retrieve reply_to_id, likes, media_url for every message.

[Assistant] SELECT reply_to_id, likes, media_url FROM logistics.messages;

[User] Find messages created yesterday.

[Assistant] SELECT reply_to_id, likes, media_url FROM logistics.messages WHERE created_at = CURRENT_DATE - INTERVAL '1 day';

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

[Assistant] SELECT reply_to_id, likes, media_url FROM logistics.messages WHERE created_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY attachment_url DESC;


[User] Retrieve all branches.

[Assistant] SELECT * FROM logistics.branches;

[User] Can you order these by updated_at ascending?

[Assistant] SELECT * FROM logistics.branches ORDER BY updated_at ASC;

[User] Order the output by location_lat ascending.

[Assistant] SELECT * FROM logistics.branches ORDER BY location_lat ASC;


[User] Show me parent_id, attachment_url, thumbnail for all messages.

[Assistant] SELECT parent_id, attachment_url, thumbnail FROM logistics.messages;

[User] Get media_url, thumbnail, coordinates, location_lat by joining messages with branches.

[Assistant] SELECT parent_id, attachment_url, thumbnail, branches.coordinates, branches.location_lat FROM logistics.messages JOIN logistics.branches ON messages.branche_id = branches.store_id;

[User] Get max of branche_id by attachment_url from messages.

[Assistant] SELECT attachment_url, MAX(branche_id) AS max_branche_id FROM logistics.messages GROUP BY attachment_url;


[User] Retrieve updated_at, image_url, branche_id for every catalog.

[Assistant] SELECT updated_at, image_url, branche_id FROM logistics.catalog;

[User] Get catalog that match branche_id > 73.

[Assistant] SELECT updated_at, image_url, branche_id FROM logistics.catalog WHERE branche_id > 73;

[User] Return just 100 rows.

[Assistant] SELECT updated_at, image_url, branche_id FROM logistics.catalog WHERE branche_id > 73 LIMIT 100;


[User] List branche_id, backorder, featured_rank from catalog.

[Assistant] SELECT branche_id, backorder, featured_rank FROM logistics.catalog;

[User] Retrieve branche_id, backorder, last_inspected, location_lat showing the relationship between catalog and branches.

[Assistant] SELECT branche_id, backorder, featured_rank, branches.last_inspected, branches.location_lat FROM logistics.catalog JOIN logistics.branches ON catalog.branche_id = branches.store_id;

[User] Tally up catalog by featured_rank.

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


[User] Retrieve all messages.

[Assistant] SELECT * FROM logistics.messages;

[User] Find messages between January and March.

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

[User] Tally up messages by reply_to_id.

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


[User] List all branches.

[Assistant] SELECT * FROM logistics.branches;

[User] What parking_available, coordinates, branche_id, likes do we have for branches and their associated messages?

[Assistant] SELECT *, messages.branche_id, messages.likes FROM logistics.branches JOIN logistics.messages ON branches.message_id = messages.message_id;

[User] Get average of city by city from branches.

[Assistant] SELECT city, AVERAGE(city) AS average_city FROM logistics.branches GROUP BY city;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.doctors (
  barcode text PRIMARY KEY -- unique identifier,
  updated_at date,
  manufacturer character varying(256),
  featured_rank varchar,
  rating varchar,
  appointment_id integer NOT NULL -- reference to appointments.comment_id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(comment_id)
)

CREATE TABLE healthcare.appointments (
  comment_id integer PRIMARY KEY -- unique identifier,
  published_at timestamp,
  updated_at date,
  shares varchar,
  author_id character varying(128),
  rating character varying(256),
  user_id character varying(128),
  doctor_id text -- reference to doctors.barcode,
  FOREIGN KEY (doctor_id) REFERENCES doctors(barcode)
)

CREATE TABLE healthcare.medical_records (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at timestamp,
  city character varying(256) NOT NULL,
  location_lat varchar,
  parking_available text NOT NULL,
  doctor_id text -- reference to doctors.barcode,
  FOREIGN KEY (doctor_id) REFERENCES doctors(barcode)
)

CREATE TABLE healthcare.prescriptions (
  id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  vendor_id char,
  user_id text,
  approval_status character varying(64),
  credit text,
  reference_number varchar
)

[User] Retrieve all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Get updated_at, rating, rating, manufacturer by joining appointments with doctors.

[Assistant] SELECT *, doctors.rating, doctors.manufacturer FROM healthcare.appointments JOIN healthcare.doctors ON appointments.doctor_id = doctors.barcode;

[User] Return just 5 rows.

[Assistant] SELECT *, doctors.rating, doctors.manufacturer FROM healthcare.appointments JOIN healthcare.doctors ON appointments.doctor_id = doctors.barcode LIMIT 5;


[User] List rating, user_id, updated_at from appointments.

[Assistant] SELECT rating, user_id, updated_at FROM healthcare.appointments;

[User] Retrieve doctor_id, shares, featured_rank, appointment_id showing the relationship between appointments and doctors.

[Assistant] SELECT rating, user_id, updated_at, doctors.featured_rank, doctors.appointment_id FROM healthcare.appointments JOIN healthcare.doctors ON appointments.doctor_id = doctors.barcode;

[User] Calculate count of rating for each rating in appointments.

[Assistant] SELECT rating, COUNT(rating) AS count_rating FROM healthcare.appointments GROUP BY rating;


[User] List location_lat, created_at, doctor_id from medical_records.

[Assistant] SELECT location_lat, created_at, doctor_id FROM healthcare.medical_records;

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

[Assistant] SELECT location_lat, created_at, doctor_id FROM healthcare.medical_records WHERE created_at > '2023-01-01';

[User] Show the results sorted by city descending.

[Assistant] SELECT location_lat, created_at, doctor_id FROM healthcare.medical_records WHERE created_at > '2023-01-01' ORDER BY city DESC;


[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Order the output by featured_rank ascending.

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

[User] Restrict the output to 5 items.

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


[User] Retrieve all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Order the output by updated_at descending.

[Assistant] SELECT * FROM healthcare.appointments ORDER BY updated_at DESC;

[User] Group appointments by doctor_id and show the min of updated_at.

[Assistant] SELECT doctor_id, MIN(updated_at) AS min_updated_at FROM healthcare.appointments GROUP BY doctor_id;


[User] Show me all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Show the results sorted by manufacturer ascending.

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

[User] Show the results sorted by updated_at descending.

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


[User] Show me all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

[User] Retrieve appointment_id, featured_rank, user_id, author_id showing the relationship between doctors and appointments.

[Assistant] SELECT *, appointments.user_id, appointments.author_id FROM healthcare.doctors JOIN healthcare.appointments ON doctors.appointment_id = appointments.comment_id;

[User] Restrict the output to 15 items.

[Assistant] SELECT *, appointments.user_id, appointments.author_id FROM healthcare.doctors JOIN healthcare.appointments ON doctors.appointment_id = appointments.comment_id LIMIT 15;


[User] Get featured_rank, rating, appointment_id from all doctors.

[Assistant] SELECT featured_rank, rating, appointment_id FROM healthcare.doctors;

[User] Sort the results by updated_at ascending.

[Assistant] SELECT featured_rank, rating, appointment_id FROM healthcare.doctors ORDER BY updated_at ASC;

[User] Order the output by manufacturer descending.

[Assistant] SELECT featured_rank, rating, appointment_id FROM healthcare.doctors ORDER BY manufacturer DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.shipping (
  product_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  available char,
  description character varying(256) NOT NULL,
  stock_level character varying(128),
  order_item_id text -- reference to order_items.id,
  FOREIGN KEY (order_item_id) REFERENCES order_items(id)
)

CREATE TABLE e-commerce.order_items (
  id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  last_login timestamp without time zone NOT NULL,
  first_name character varying(64),
  status char
)

CREATE TABLE e-commerce.users (
  person_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  last_login date NOT NULL,
  display_name character varying(64),
  api_key character varying(64) NOT NULL,
  website character varying(64)
)

[User] What are the created_at, product_id, description of each shipping?

[Assistant] SELECT created_at, product_id, description FROM e-commerce.shipping;

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

[Assistant] SELECT created_at, product_id, description FROM e-commerce.shipping WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] How many shipping are there per created_at?

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


[User] Retrieve all shipping.

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

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

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

[User] Only show the top 20 results.

[Assistant] SELECT * FROM e-commerce.shipping WHERE created_at > '2023-12-01' LIMIT 20;


[User] Retrieve created_at, description, product_id for every shipping.

[Assistant] SELECT created_at, description, product_id FROM e-commerce.shipping;

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

[Assistant] SELECT created_at, description, product_id FROM e-commerce.shipping WHERE order_item_id LIKE 'A%';

[User] Restrict the output to 10 items.

[Assistant] SELECT created_at, description, product_id FROM e-commerce.shipping WHERE order_item_id LIKE 'A%' LIMIT 10;


[User] List created_at, available, product_id from shipping.

[Assistant] SELECT created_at, available, product_id FROM e-commerce.shipping;

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

[Assistant] SELECT created_at, available, product_id FROM e-commerce.shipping WHERE description LIKE 'A%';

[User] Can you order these by order_item_id descending?

[Assistant] SELECT created_at, available, product_id FROM e-commerce.shipping WHERE description LIKE 'A%' ORDER BY order_item_id DESC;


[User] Retrieve all shipping.

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

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

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

[User] Show me max of description grouped by available for shipping.

[Assistant] SELECT available, MAX(description) AS max_description FROM e-commerce.shipping GROUP BY available;


[User] What are the order_item_id, created_at, product_id of each shipping?

[Assistant] SELECT order_item_id, created_at, product_id FROM e-commerce.shipping;

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

[Assistant] SELECT order_item_id, created_at, product_id FROM e-commerce.shipping WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Show the results sorted by stock_level ascending.

[Assistant] SELECT order_item_id, created_at, product_id FROM e-commerce.shipping WHERE created_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY stock_level ASC;


[User] Show me product_id, order_item_id, available for all shipping.

[Assistant] SELECT product_id, order_item_id, available FROM e-commerce.shipping;

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

[Assistant] SELECT product_id, order_item_id, available FROM e-commerce.shipping WHERE stock_level LIKE 'A%';

[User] Restrict the output to 5 items.

[Assistant] SELECT product_id, order_item_id, available FROM e-commerce.shipping WHERE stock_level LIKE 'A%' LIMIT 5;


[User] Get all shipping.

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

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

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

[User] Group shipping by order_item_id and show the max of order_item_id.

[Assistant] SELECT order_item_id, MAX(order_item_id) AS max_order_item_id FROM e-commerce.shipping GROUP BY order_item_id;


[User] Get all shipping.

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

[User] Find shipping created yesterday.

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

[User] Get the distribution of shipping across different order_item_id values.

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


[User] Get all shipping.

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

[User] Retrieve available, description, first_name, created_at showing the relationship between shipping and order_items.

[Assistant] SELECT *, order_items.first_name, order_items.created_at FROM e-commerce.shipping JOIN e-commerce.order_items ON shipping.order_item_id = order_items.id;

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

[Assistant] SELECT created_at, COUNT(*) AS count FROM e-commerce.shipping 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 education.assignments (
  sku character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  cost decimal,
  media_url char NOT NULL,
  thumbnail_url character varying(128),
  category char NOT NULL,
  student_id integer -- reference to students.user_id,
  FOREIGN KEY (student_id) REFERENCES students(user_id)
)

CREATE TABLE education.teachers (
  id integer PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  total numeric,
  card_type character varying(256),
  exchange_rate char NOT NULL,
  payment_status character varying(64),
  tax integer,
  student_id integer NOT NULL -- reference to students.user_id,
  FOREIGN KEY (student_id) REFERENCES students(user_id)
)

CREATE TABLE education.departments (
  customer_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  display_name character varying(256),
  last_name character varying(128),
  full_name character varying(64),
  website character varying(256),
  first_name character varying(64),
  student_id integer -- reference to students.user_id,
  FOREIGN KEY (student_id) REFERENCES students(user_id)
)

CREATE TABLE education.students (
  user_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  country varchar,
  last_name text,
  city text,
  zip_code character varying(64)
)

[User] Get all departments.

[Assistant] SELECT * FROM education.departments;

[User] Show me departments with website LIKE 'A%'.

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

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

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


[User] Retrieve student_id, sku, media_url for every assignment.

[Assistant] SELECT student_id, sku, media_url FROM education.assignments;

[User] Retrieve assignments where thumbnail_url LIKE 'A%'.

[Assistant] SELECT student_id, sku, media_url FROM education.assignments WHERE thumbnail_url LIKE 'A%';

[User] Order the output by sku ascending.

[Assistant] SELECT student_id, sku, media_url FROM education.assignments WHERE thumbnail_url LIKE 'A%' ORDER BY sku ASC;


[User] Show me all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

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

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


[User] Show me created_at, display_name, last_name for all departments.

[Assistant] SELECT created_at, display_name, last_name FROM education.departments;

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

[Assistant] SELECT created_at, display_name, last_name FROM education.departments WHERE first_name LIKE 'A%';

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

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


[User] Display all assignments.

[Assistant] SELECT * FROM education.assignments;

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

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

[User] Show only 50 records.

[Assistant] SELECT * FROM education.assignments WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 50;


[User] Get all assignments.

[Assistant] SELECT * FROM education.assignments;

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

[Assistant] SELECT * FROM education.assignments WHERE created_at > '2023-01-01';

[User] Limit the results to 100 rows.

[Assistant] SELECT * FROM education.assignments WHERE created_at > '2023-01-01' LIMIT 100;


[User] Show me full_name, last_name, website for all departments.

[Assistant] SELECT full_name, last_name, website FROM education.departments;

[User] Sort the results by last_name descending.

[Assistant] SELECT full_name, last_name, website FROM education.departments ORDER BY last_name DESC;

[User] Show only 10 records.

[Assistant] SELECT full_name, last_name, website FROM education.departments ORDER BY last_name DESC LIMIT 10;


[User] Display all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Show me assignments with cost > 98.

[Assistant] SELECT * FROM education.assignments WHERE cost > 98;

[User] Count the number of assignments in each sku category.

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


[User] Get all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

[User] Get the distribution of teachers across different processed_at values.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.patients (
  customer_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  zip_code character varying(256),
  password_hash varchar,
  token character varying(64),
  is_active bit,
  email character varying(128) NOT NULL,
  status character varying(256)
)

CREATE TABLE healthcare.doctors (
  store_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  last_inspected timestamp,
  name char NOT NULL,
  geo_point character varying(128),
  latitude varchar NOT NULL,
  appointment_id text NOT NULL -- reference to appointments.sku,
  FOREIGN KEY (appointment_id) REFERENCES appointments(sku)
)

CREATE TABLE healthcare.appointments (
  sku varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at timestamp without time zone,
  backorder char,
  subcategory varchar,
  reserved character varying(128),
  image_url character varying(256) NOT NULL,
  msrp text NOT NULL,
  available character varying(64),
  department_id integer NOT NULL -- reference to departments.comment_id,
  FOREIGN KEY (department_id) REFERENCES departments(comment_id)
)

CREATE TABLE healthcare.departments (
  comment_id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp without time zone,
  score character varying(256),
  message char,
  views char,
  author_id character varying(256),
  patient_id text NOT NULL -- reference to patients.customer_id,
  FOREIGN KEY (patient_id) REFERENCES patients(customer_id)
)

[User] Display all doctors.

[Assistant] SELECT * FROM healthcare.doctors;

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

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

[User] Sort the results by name descending.

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


[User] Retrieve all departments.

[Assistant] SELECT * FROM healthcare.departments;

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

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

[User] What is the count score for each author_id in departments?

[Assistant] SELECT author_id, COUNT(score) AS count_score FROM healthcare.departments GROUP BY author_id;


[User] Display all appointments.

[Assistant] SELECT * FROM healthcare.appointments;

[User] Sort the results by available descending.

[Assistant] SELECT * FROM healthcare.appointments ORDER BY available DESC;

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM healthcare.appointments ORDER BY available DESC LIMIT 10;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.audits (
  post_id integer PRIMARY KEY -- unique identifier,
  edited_at date,
  published_at timestamp without time zone,
  likes character varying(128),
  categories text NOT NULL,
  reply_to_id char -- identifier for reply_to,
  account_id integer -- reference to accounts.id,
  FOREIGN KEY (account_id) REFERENCES accounts(id)
)

CREATE TABLE finance.accounts (
  id integer PRIMARY KEY -- unique identifier,
  due_date timestamp,
  created_at timestamp without time zone,
  approval_status char NOT NULL,
  customer_id char NOT NULL -- identifier for customer,
  notes varchar,
  exchange_rate text NOT NULL
)

CREATE TABLE finance.payments (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  user_id text -- identifier for user,
  discount integer,
  subtotal numeric,
  account_id integer -- reference to accounts.id,
  audit_id integer NOT NULL -- reference to audits.post_id,
  FOREIGN KEY (account_id) REFERENCES accounts(id),
  FOREIGN KEY (audit_id) REFERENCES audits(post_id)
)

CREATE TABLE finance.investments (
  customer_id character varying(64) NOT NULL -- unique identifier,
  joined_at timestamp,
  token char NOT NULL,
  language varchar,
  email char,
  timezone text NOT NULL,
  state character varying(256),
  account_status text
)

[User] Show me all audits.

[Assistant] SELECT * FROM finance.audits;

[User] Order the output by categories descending.

[Assistant] SELECT * FROM finance.audits ORDER BY categories DESC;

[User] Order the output by categories descending.

[Assistant] SELECT * FROM finance.audits ORDER BY categories DESC;


[User] Retrieve all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Count the number of payments in each account_id category.

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


[User] Get user_id, audit_id, account_id from all payments.

[Assistant] SELECT user_id, audit_id, account_id FROM finance.payments;

[User] Find payments older than 6 months.

[Assistant] SELECT user_id, audit_id, account_id FROM finance.payments WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Get the distribution of payments across different discount values.

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


[User] Display all payments.

[Assistant] SELECT * FROM finance.payments;

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

[Assistant] SELECT * FROM finance.payments ORDER BY discount DESC;

[User] Only show the top 100 results.

[Assistant] SELECT * FROM finance.payments ORDER BY discount DESC LIMIT 100;


[User] Retrieve all payments.

[Assistant] SELECT * FROM finance.payments;

[User] What discount, user_id, due_date, notes do we have for payments and their associated accounts?

[Assistant] SELECT *, accounts.due_date, accounts.notes FROM finance.payments JOIN finance.accounts ON payments.account_id = accounts.id;

[User] Show me count of transaction_id grouped by subtotal for payments.

[Assistant] SELECT subtotal, COUNT(transaction_id) AS count_transaction_id FROM finance.payments GROUP BY subtotal;


[User] Get all audits.

[Assistant] SELECT * FROM finance.audits;

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

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

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

[Assistant] SELECT * FROM finance.audits WHERE published_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY reply_to_id ASC;


[User] What are the subtotal, user_id, discount of each payment?

[Assistant] SELECT subtotal, user_id, discount FROM finance.payments;

[User] Sort the results by audit_id ascending.

[Assistant] SELECT subtotal, user_id, discount FROM finance.payments ORDER BY audit_id ASC;

[User] Order the output by discount descending.

[Assistant] SELECT subtotal, user_id, discount FROM finance.payments ORDER BY discount DESC;


[User] Get subtotal, audit_id, updated_at from all payments.

[Assistant] SELECT subtotal, audit_id, updated_at FROM finance.payments;

[User] Sort the results by discount ascending.

[Assistant] SELECT subtotal, audit_id, updated_at FROM finance.payments ORDER BY discount ASC;

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

[Assistant] SELECT transaction_id, COUNT(*) AS count FROM finance.payments GROUP BY transaction_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 finance.audits (
  invoice_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  user_id character varying(128) -- identifier for user,
  customer_id varchar,
  investment_id text -- reference to investments.product_id,
  FOREIGN KEY (investment_id) REFERENCES investments(product_id)
)

CREATE TABLE finance.loans (
  transaction_id integer PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  completed_at date,
  payment_status character varying(128),
  status char,
  amount numeric(38,14),
  price numeric,
  customer_id character varying(256),
  subtotal numeric
)

CREATE TABLE finance.investments (
  product_id text PRIMARY KEY -- unique identifier,
  created_at date,
  expires_at timestamp,
  popularity_score character varying(128),
  rating varchar,
  price numeric(38,14),
  name char,
  loan_id integer NOT NULL -- reference to loans.transaction_id,
  FOREIGN KEY (loan_id) REFERENCES loans(transaction_id)
)

[User] Get popularity_score, expires_at, created_at from all investments.

[Assistant] SELECT popularity_score, expires_at, created_at FROM finance.investments;

[User] Sort the results by loan_id ascending.

[Assistant] SELECT popularity_score, expires_at, created_at FROM finance.investments ORDER BY loan_id ASC;

[User] Limit the results to 100 rows.

[Assistant] SELECT popularity_score, expires_at, created_at FROM finance.investments ORDER BY loan_id ASC LIMIT 100;


[User] List name, rating, created_at from investments.

[Assistant] SELECT name, rating, created_at FROM finance.investments;

[User] Find investments modified within the last hour.

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

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

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


[User] Retrieve investment_id, created_at, customer_id for every audit.

[Assistant] SELECT investment_id, created_at, customer_id FROM finance.audits;

[User] Show me audits with investment_id LIKE 'A%'.

[Assistant] SELECT investment_id, created_at, customer_id FROM finance.audits WHERE investment_id LIKE 'A%';

[User] Limit the results to 100 rows.

[Assistant] SELECT investment_id, created_at, customer_id FROM finance.audits WHERE investment_id LIKE 'A%' LIMIT 100;


[User] Show me all audits.

[Assistant] SELECT * FROM finance.audits;

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

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

[User] How many audits are there per customer_id?

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


[User] List user_id, created_at, customer_id from audits.

[Assistant] SELECT user_id, created_at, customer_id FROM finance.audits;

[User] Show me audits that were created yesterday.

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

[User] How many audits are there per created_at?

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


[User] Show me customer_id, investment_id, created_at for all audits.

[Assistant] SELECT customer_id, investment_id, created_at FROM finance.audits;

[User] Get all audits created yesterday.

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

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

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


[User] Get expires_at, created_at, loan_id from all investments.

[Assistant] SELECT expires_at, created_at, loan_id FROM finance.investments;

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

[Assistant] SELECT expires_at, created_at, loan_id FROM finance.investments ORDER BY created_at DESC;

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

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


[User] Show me all audits.

[Assistant] SELECT * FROM finance.audits;

[User] What created_at, customer_id, name, popularity_score do we have for audits and their associated investments?

[Assistant] SELECT *, investments.name, investments.popularity_score FROM finance.audits JOIN finance.investments ON audits.investment_id = investments.product_id;

[User] Restrict the output to 15 items.

[Assistant] SELECT *, investments.name, investments.popularity_score FROM finance.audits JOIN finance.investments ON audits.investment_id = investments.product_id LIMIT 15;


[User] Retrieve all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Retrieve loan_id, rating, amount, subtotal showing the relationship between investments and loans.

[Assistant] SELECT *, loans.amount, loans.subtotal FROM finance.investments JOIN finance.loans ON investments.loan_id = loans.transaction_id;

[User] Show only 5 records.

[Assistant] SELECT *, loans.amount, loans.subtotal FROM finance.investments JOIN finance.loans ON investments.loan_id = loans.transaction_id LIMIT 5;


[User] List customer_id, created_at, investment_id from audits.

[Assistant] SELECT customer_id, created_at, investment_id FROM finance.audits;

[User] Show the results sorted by user_id descending.

[Assistant] SELECT customer_id, created_at, investment_id FROM finance.audits ORDER BY user_id DESC;

[User] Return just 5 rows.

[Assistant] SELECT customer_id, created_at, investment_id FROM finance.audits ORDER BY user_id DESC LIMIT 5;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE retail.addresses (
  venue_id text PRIMARY KEY -- unique identifier,
  last_inspected timestamp,
  updated_at date,
  category varchar NOT NULL,
  type character varying(128),
  parking_available character varying(64),
  accessibility text,
  coordinates text
)

CREATE TABLE retail.items (
  item_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp,
  created_at timestamp without time zone,
  name text,
  cost numeric,
  thumbnail_url char NOT NULL,
  image_url char,
  featured_rank char NOT NULL,
  currency varchar,
  description character varying(256),
  addresse_id text -- reference to addresses.venue_id,
  FOREIGN KEY (addresse_id) REFERENCES addresses(venue_id)
)

[User] Show me description, thumbnail_url, image_url for all items.

[Assistant] SELECT description, thumbnail_url, image_url FROM retail.items;

[User] Find items from 2023.

[Assistant] SELECT description, thumbnail_url, image_url FROM retail.items WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Show only 10 records.

[Assistant] SELECT description, thumbnail_url, image_url FROM retail.items WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 10;


[User] What are the cost, currency, name of each item?

[Assistant] SELECT cost, currency, name FROM retail.items;

[User] Order the output by created_at ascending.

[Assistant] SELECT cost, currency, name FROM retail.items ORDER BY created_at ASC;

[User] Can you order these by featured_rank ascending?

[Assistant] SELECT cost, currency, name FROM retail.items ORDER BY featured_rank ASC;


[User] Show me name, addresse_id, item_id for all items.

[Assistant] SELECT name, addresse_id, item_id FROM retail.items;

[User] List items that have image_url LIKE 'A%'.

[Assistant] SELECT name, addresse_id, item_id FROM retail.items WHERE image_url LIKE 'A%';

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

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


[User] Display all items.

[Assistant] SELECT * FROM retail.items;

[User] Can you order these by image_url descending?

[Assistant] SELECT * FROM retail.items ORDER BY image_url DESC;

[User] Show me average of addresse_id grouped by description for items.

[Assistant] SELECT description, AVERAGE(addresse_id) AS average_addresse_id FROM retail.items GROUP BY description;


[User] List all items.

[Assistant] SELECT * FROM retail.items;

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

[Assistant] SELECT * FROM retail.items ORDER BY currency ASC;

[User] Get max of thumbnail_url by published_at from items.

[Assistant] SELECT published_at, MAX(thumbnail_url) AS max_thumbnail_url FROM retail.items GROUP BY published_at;


[User] Show me name, published_at, created_at for all items.

[Assistant] SELECT name, published_at, created_at FROM retail.items;

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

[Assistant] SELECT name, published_at, created_at FROM retail.items WHERE description LIKE 'A%';

[User] Group items by item_id and show the min of cost.

[Assistant] SELECT item_id, MIN(cost) AS min_cost FROM retail.items GROUP BY item_id;


[User] Show me all items.

[Assistant] SELECT * FROM retail.items;

[User] List items that have thumbnail_url LIKE 'A%'.

[Assistant] SELECT * FROM retail.items WHERE thumbnail_url LIKE 'A%';

[User] Calculate min of name for each description in items.

[Assistant] SELECT description, MIN(name) AS min_name FROM retail.items GROUP BY description;


[User] List all items.

[Assistant] SELECT * FROM retail.items;

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

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

[User] How many items are there per thumbnail_url?

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


[User] List cost, currency, created_at from items.

[Assistant] SELECT cost, currency, created_at FROM retail.items;

[User] List featured_rank, name, coordinates, parking_available for each item along with their addresse information.

[Assistant] SELECT cost, currency, created_at, addresses.coordinates, addresses.parking_available FROM retail.items JOIN retail.addresses ON items.addresse_id = addresses.venue_id;

[User] Tally up items by image_url.

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


[User] Display all items.

[Assistant] SELECT * FROM retail.items;

[User] Can you order these by addresse_id ascending?

[Assistant] SELECT * FROM retail.items ORDER BY addresse_id ASC;

[User] How many items are there per cost?

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.courses (
  id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  published_at timestamp,
  image_url character varying(128) NOT NULL,
  brand char NOT NULL,
  manufacturer character varying(64),
  rating text,
  views character varying(256),
  name text,
  popularity_score varchar,
  student_id text NOT NULL -- reference to students.user_id,
  FOREIGN KEY (student_id) REFERENCES students(user_id)
)

CREATE TABLE education.students (
  user_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  joined_at timestamp without time zone,
  password_hash text,
  birth_date date,
  gender varchar,
  bio char
)

[User] Display all courses.

[Assistant] SELECT * FROM education.courses;

[User] Show me rating, views, bio, last_active from courses and their related students.

[Assistant] SELECT *, students.bio, students.last_active FROM education.courses JOIN education.students ON courses.student_id = students.user_id;

[User] Get the distribution of courses across different popularity_score values.

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


[User] Get all courses.

[Assistant] SELECT * FROM education.courses;

[User] Order the output by published_at ascending.

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

[User] Tally up courses by name.

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


[User] Show me rating, image_url, created_at for all courses.

[Assistant] SELECT rating, image_url, created_at FROM education.courses;

[User] Get manufacturer, name, joined_at, bio by joining courses with students.

[Assistant] SELECT rating, image_url, created_at, students.joined_at, students.bio FROM education.courses JOIN education.students ON courses.student_id = students.user_id;

[User] Calculate max of manufacturer for each rating in courses.

[Assistant] SELECT rating, MAX(manufacturer) AS max_manufacturer FROM education.courses GROUP BY rating;


[User] Show me published_at, created_at, image_url for all courses.

[Assistant] SELECT published_at, created_at, image_url FROM education.courses;

[User] Order the output by name descending.

[Assistant] SELECT published_at, created_at, image_url FROM education.courses ORDER BY name DESC;

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

[Assistant] SELECT rating, MAX(rating) AS max_rating FROM education.courses GROUP BY rating;


[User] Get all courses.

[Assistant] SELECT * FROM education.courses;

[User] Order the output by created_at descending.

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

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

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


[User] Display all courses.

[Assistant] SELECT * FROM education.courses;

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

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

[User] Calculate min of manufacturer for each created_at in courses.

[Assistant] SELECT created_at, MIN(manufacturer) AS min_manufacturer FROM education.courses GROUP BY created_at;


[User] Show me popularity_score, brand, image_url for all courses.

[Assistant] SELECT popularity_score, brand, image_url FROM education.courses;

[User] What rating, image_url, birth_date, bio do we have for courses and their associated students?

[Assistant] SELECT popularity_score, brand, image_url, students.birth_date, students.bio FROM education.courses JOIN education.students ON courses.student_id = students.user_id;

[User] Group courses by image_url and show the sum of published_at.

[Assistant] SELECT image_url, SUM(published_at) AS sum_published_at FROM education.courses GROUP BY image_url;


[User] List manufacturer, name, popularity_score from courses.

[Assistant] SELECT manufacturer, name, popularity_score FROM education.courses;

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

[Assistant] SELECT manufacturer, name, popularity_score FROM education.courses WHERE manufacturer LIKE 'A%';

[User] Return just 15 rows.

[Assistant] SELECT manufacturer, name, popularity_score FROM education.courses WHERE manufacturer LIKE 'A%' LIMIT 15;


[User] What are the manufacturer, published_at, name of each course?

[Assistant] SELECT manufacturer, published_at, name FROM education.courses;

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

[Assistant] SELECT manufacturer, published_at, name FROM education.courses WHERE published_at >= CURRENT_DATE - INTERVAL '30 days';

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

[Assistant] SELECT manufacturer, published_at, name FROM education.courses WHERE published_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY created_at ASC;


[User] Get all courses.

[Assistant] SELECT * FROM education.courses;

[User] Sort the results by manufacturer ascending.

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

[User] Get count of manufacturer by popularity_score from courses.

[Assistant] SELECT popularity_score, COUNT(manufacturer) AS count_manufacturer FROM education.courses GROUP BY popularity_score;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.reviews (
  content_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  subject character varying(64) NOT NULL,
  keywords character varying(256) NOT NULL,
  content text NOT NULL,
  thumbnail character varying(64),
  shippin_id text -- reference to shipping.store_id,
  FOREIGN KEY (shippin_id) REFERENCES shipping(store_id)
)

CREATE TABLE e-commerce.products (
  product_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  expires_at timestamp,
  popularity_score char,
  stock_level text NOT NULL,
  currency varchar,
  thumbnail_url varchar,
  review_id text NOT NULL -- reference to reviews.content_id,
  FOREIGN KEY (review_id) REFERENCES reviews(content_id)
)

CREATE TABLE e-commerce.shipping (
  store_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  last_inspected timestamp,
  timezone text,
  longitude character varying(128),
  name character varying(64) NOT NULL,
  address_line2 text
)

[User] What are the popularity_score, expires_at, currency of each product?

[Assistant] SELECT popularity_score, expires_at, currency FROM e-commerce.products;

[User] Can you order these by review_id ascending?

[Assistant] SELECT popularity_score, expires_at, currency FROM e-commerce.products ORDER BY review_id ASC;

[User] Show only 100 records.

[Assistant] SELECT popularity_score, expires_at, currency FROM e-commerce.products ORDER BY review_id ASC LIMIT 100;


[User] Get content, thumbnail, keywords from all reviews.

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

[User] Find reviews from last week.

[Assistant] SELECT content, thumbnail, keywords FROM e-commerce.reviews WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days';

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

[Assistant] SELECT content, thumbnail, keywords FROM e-commerce.reviews WHERE updated_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY shippin_id ASC;


[User] Get all reviews.

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

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

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

[User] Only show the top 15 results.

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


[User] Retrieve updated_at, currency, stock_level for every product.

[Assistant] SELECT updated_at, currency, stock_level FROM e-commerce.products;

[User] Sort the results by currency descending.

[Assistant] SELECT updated_at, currency, stock_level FROM e-commerce.products ORDER BY currency DESC;

[User] What is the count expires_at for each review_id in products?

[Assistant] SELECT review_id, COUNT(expires_at) AS count_expires_at FROM e-commerce.products GROUP BY review_id;


[User] List keywords, thumbnail, content from reviews.

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

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

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

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

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


[User] Display all products.

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

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

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

[User] Show the results sorted by updated_at descending.

[Assistant] SELECT * FROM e-commerce.products WHERE expires_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY updated_at DESC;


[User] Retrieve all products.

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

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

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

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

[Assistant] SELECT expires_at, COUNT(updated_at) AS count_updated_at FROM e-commerce.products GROUP BY expires_at;


[User] List all reviews.

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

[User] What thumbnail, shippin_id, address_line2, longitude do we have for reviews and their associated shipping?

[Assistant] SELECT *, shipping.address_line2, shipping.longitude FROM e-commerce.reviews JOIN e-commerce.shipping ON reviews.shippin_id = shipping.store_id;

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

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


[User] List all reviews.

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

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

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

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

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


[User] Get all reviews.

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

[User] Sort the results by shippin_id ascending.

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

[User] Return just 20 rows.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.metadata (
  sku integer PRIMARY KEY -- unique identifier,
  created_at date,
  discount decimal,
  backorder character varying(256),
  video_url varchar -- identifier for video_url,
  featured_rank char NOT NULL,
  notification_id text NOT NULL -- reference to notifications.barcode,
  FOREIGN KEY (notification_id) REFERENCES notifications(barcode)
)

CREATE TABLE tradingplatform.notifications (
  barcode text PRIMARY KEY -- unique identifier,
  published_at date,
  video_url character varying(256) NOT NULL -- identifier for video_url,
  tax_rate character varying(64) NOT NULL,
  stock_level character varying(256),
  views character varying(64),
  popularity_score character varying(256),
  image_url character varying(256),
  metadat_id integer NOT NULL -- reference to metadata.sku,
  FOREIGN KEY (metadat_id) REFERENCES metadata(sku)
)

[User] Show me image_url, views, stock_level for all notifications.

[Assistant] SELECT image_url, views, stock_level FROM tradingplatform.notifications;

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

[Assistant] SELECT image_url, views, stock_level FROM tradingplatform.notifications WHERE image_url LIKE 'A%';

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

[Assistant] SELECT image_url, views, stock_level FROM tradingplatform.notifications WHERE image_url LIKE 'A%' ORDER BY views ASC;


[User] List popularity_score, video_url, metadat_id from notifications.

[Assistant] SELECT popularity_score, video_url, metadat_id FROM tradingplatform.notifications;

[User] Get notifications that match stock_level LIKE 'A%'.

[Assistant] SELECT popularity_score, video_url, metadat_id FROM tradingplatform.notifications WHERE stock_level LIKE 'A%';

[User] Order the output by tax_rate ascending.

[Assistant] SELECT popularity_score, video_url, metadat_id FROM tradingplatform.notifications WHERE stock_level LIKE 'A%' ORDER BY tax_rate ASC;


[User] List backorder, created_at, notification_id from metadata.

[Assistant] SELECT backorder, created_at, notification_id FROM tradingplatform.metadata;

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

[Assistant] SELECT backorder, created_at, notification_id FROM tradingplatform.metadata WHERE video_url LIKE 'A%';

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

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


[User] List popularity_score, metadat_id, views from notifications.

[Assistant] SELECT popularity_score, metadat_id, views FROM tradingplatform.notifications;

[User] Retrieve published_at, image_url, backorder, video_url showing the relationship between notifications and metadata.

[Assistant] SELECT popularity_score, metadat_id, views, metadata.backorder, metadata.video_url FROM tradingplatform.notifications JOIN tradingplatform.metadata ON notifications.metadat_id = metadata.sku;

[User] Show the results sorted by stock_level ascending.

[Assistant] SELECT popularity_score, metadat_id, views, metadata.backorder, metadata.video_url FROM tradingplatform.notifications JOIN tradingplatform.metadata ON notifications.metadat_id = metadata.sku ORDER BY stock_level ASC;


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

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

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

[User] Show only 20 records.

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


[User] Show me notification_id, featured_rank, backorder for all metadata.

[Assistant] SELECT notification_id, featured_rank, backorder FROM tradingplatform.metadata;

[User] Can you order these by created_at ascending?

[Assistant] SELECT notification_id, featured_rank, backorder FROM tradingplatform.metadata ORDER BY created_at ASC;

[User] Order the output by backorder ascending.

[Assistant] SELECT notification_id, featured_rank, backorder FROM tradingplatform.metadata ORDER BY backorder ASC;


[User] Show me all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

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

[Assistant] SELECT * FROM tradingplatform.metadata WHERE created_at > '2023-01-01';

[User] Order the output by video_url descending.

[Assistant] SELECT * FROM tradingplatform.metadata WHERE created_at > '2023-01-01' ORDER BY video_url DESC;


[User] List all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

[User] Show me notifications that were from 2023.

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

[User] Order the output by tax_rate descending.

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


[User] Show me all notifications.

[Assistant] SELECT * FROM tradingplatform.notifications;

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

[Assistant] SELECT * FROM tradingplatform.notifications ORDER BY popularity_score DESC;

[User] What is the sum views for each views in notifications?

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


[User] Get all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

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

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

[User] Group metadata by video_url and show the count of notification_id.

[Assistant] SELECT video_url, COUNT(notification_id) AS count_notification_id FROM tradingplatform.metadata GROUP BY video_url;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.doctors (
  id text PRIMARY KEY -- unique identifier,
  completed_at timestamp without time zone,
  subtotal numeric NOT NULL,
  buyer_id char,
  product_id character varying(64) NOT NULL,
  amount bigint NOT NULL,
  status text NOT NULL,
  exchange_rate varchar
)

CREATE TABLE healthcare.departments (
  customer_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  joined_at timestamp,
  address text NOT NULL,
  birth_date timestamp,
  api_key character varying(128),
  language text,
  account_status char NOT NULL,
  full_name varchar,
  doctor_id text -- reference to doctors.id,
  FOREIGN KEY (doctor_id) REFERENCES doctors(id)
)

[User] Get full_name, address, doctor_id from all departments.

[Assistant] SELECT full_name, address, doctor_id FROM healthcare.departments;

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

[Assistant] SELECT full_name, address, doctor_id FROM healthcare.departments WHERE birth_date <= CURRENT_DATE - INTERVAL '6 months';

[User] Group departments by full_name and show the average of doctor_id.

[Assistant] SELECT full_name, AVERAGE(doctor_id) AS average_doctor_id FROM healthcare.departments GROUP BY full_name;


[User] Retrieve all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Show me address, api_key, subtotal, completed_at from departments and their related doctors.

[Assistant] SELECT *, doctors.subtotal, doctors.completed_at FROM healthcare.departments JOIN healthcare.doctors ON departments.doctor_id = doctors.id;

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

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


[User] What are the joined_at, full_name, birth_date of each department?

[Assistant] SELECT joined_at, full_name, birth_date FROM healthcare.departments;

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

[Assistant] SELECT joined_at, full_name, birth_date FROM healthcare.departments WHERE api_key LIKE 'A%';

[User] How many departments are there per address?

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


[User] List all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] List birth_date, created_at, product_id, exchange_rate for each department along with their doctor information.

[Assistant] SELECT *, doctors.product_id, doctors.exchange_rate FROM healthcare.departments JOIN healthcare.doctors ON departments.doctor_id = doctors.id;

[User] Return just 20 rows.

[Assistant] SELECT *, doctors.product_id, doctors.exchange_rate FROM healthcare.departments JOIN healthcare.doctors ON departments.doctor_id = doctors.id LIMIT 20;


[User] Show me customer_id, created_at, birth_date for all departments.

[Assistant] SELECT customer_id, created_at, birth_date FROM healthcare.departments;

[User] Show me created_at, language, exchange_rate, subtotal from departments and their related doctors.

[Assistant] SELECT customer_id, created_at, birth_date, doctors.exchange_rate, doctors.subtotal FROM healthcare.departments JOIN healthcare.doctors ON departments.doctor_id = doctors.id;

[User] Order the output by account_status ascending.

[Assistant] SELECT customer_id, created_at, birth_date, doctors.exchange_rate, doctors.subtotal FROM healthcare.departments JOIN healthcare.doctors ON departments.doctor_id = doctors.id ORDER BY account_status ASC;


[User] List all departments.

[Assistant] SELECT * FROM healthcare.departments;

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

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

[User] Show me average of full_name grouped by account_status for departments.

[Assistant] SELECT account_status, AVERAGE(full_name) AS average_full_name FROM healthcare.departments GROUP BY account_status;


[User] What are the customer_id, language, full_name of each department?

[Assistant] SELECT customer_id, language, full_name FROM healthcare.departments;

[User] Get birth_date, customer_id, status, product_id by joining departments with doctors.

[Assistant] SELECT customer_id, language, full_name, doctors.status, doctors.product_id FROM healthcare.departments JOIN healthcare.doctors ON departments.doctor_id = doctors.id;

[User] How many departments are there per api_key?

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


[User] Get doctor_id, account_status, customer_id from all departments.

[Assistant] SELECT doctor_id, account_status, customer_id FROM healthcare.departments;

[User] List language, address, exchange_rate, completed_at for each department along with their doctor information.

[Assistant] SELECT doctor_id, account_status, customer_id, doctors.exchange_rate, doctors.completed_at FROM healthcare.departments JOIN healthcare.doctors ON departments.doctor_id = doctors.id;

[User] How many departments are there per joined_at?

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


[User] What are the created_at, language, address of each department?

[Assistant] SELECT created_at, language, address FROM healthcare.departments;

[User] Order the output by address descending.

[Assistant] SELECT created_at, language, address FROM healthcare.departments ORDER BY address DESC;

[User] Get min of account_status by customer_id from departments.

[Assistant] SELECT customer_id, MIN(account_status) AS min_account_status FROM healthcare.departments GROUP BY customer_id;


[User] Display all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Can you order these by customer_id descending?

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

[User] Order the output by created_at descending.

[Assistant] SELECT * FROM healthcare.departments ORDER BY created_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 manufacturing.billing (
  transaction_id text PRIMARY KEY -- unique identifier,
  processed_at timestamp,
  payment_date timestamp without time zone,
  payee_id character varying(256),
  invoice_number varchar NOT NULL,
  credit char
)

CREATE TABLE manufacturing.articles (
  content_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  edited_at date,
  likes character varying(64) NOT NULL,
  text character varying(128),
  keywords character varying(256)
)

[User] What are the keywords, text, created_at of each article?

[Assistant] SELECT keywords, text, created_at FROM manufacturing.articles;

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

[Assistant] SELECT keywords, text, created_at FROM manufacturing.articles WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Only show the top 15 results.

[Assistant] SELECT keywords, text, created_at FROM manufacturing.articles WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 15;


[User] Get payment_date, credit, invoice_number from all billing.

[Assistant] SELECT payment_date, credit, invoice_number FROM manufacturing.billing;

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

[Assistant] SELECT payment_date, credit, invoice_number FROM manufacturing.billing WHERE payee_id LIKE 'A%';

[User] Get min of payee_id by invoice_number from billing.

[Assistant] SELECT invoice_number, MIN(payee_id) AS min_payee_id FROM manufacturing.billing GROUP BY invoice_number;


[User] Retrieve payee_id, credit, processed_at for every billing.

[Assistant] SELECT payee_id, credit, processed_at FROM manufacturing.billing;

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

[Assistant] SELECT payee_id, credit, processed_at FROM manufacturing.billing WHERE payment_date BETWEEN '2023-01-01' AND '2023-12-31';

[User] Show only 100 records.

[Assistant] SELECT payee_id, credit, processed_at FROM manufacturing.billing WHERE payment_date BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 100;


[User] List all billing.

[Assistant] SELECT * FROM manufacturing.billing;

[User] Sort the results by payment_date ascending.

[Assistant] SELECT * FROM manufacturing.billing ORDER BY payment_date ASC;

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

[Assistant] SELECT * FROM manufacturing.billing ORDER BY payment_date DESC;


[User] Retrieve payee_id, processed_at, payment_date for every billing.

[Assistant] SELECT payee_id, processed_at, payment_date FROM manufacturing.billing;

[User] Can you order these by payee_id descending?

[Assistant] SELECT payee_id, processed_at, payment_date FROM manufacturing.billing ORDER BY payee_id DESC;

[User] Get max of payment_date by processed_at from billing.

[Assistant] SELECT processed_at, MAX(payment_date) AS max_payment_date FROM manufacturing.billing GROUP BY processed_at;


[User] Show me all articles.

[Assistant] SELECT * FROM manufacturing.articles;

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

[Assistant] SELECT * FROM manufacturing.articles WHERE likes LIKE 'A%';

[User] Limit the results to 10 rows.

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


[User] Show me text, edited_at, created_at for all articles.

[Assistant] SELECT text, edited_at, created_at FROM manufacturing.articles;

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

[Assistant] SELECT text, edited_at, created_at FROM manufacturing.articles WHERE edited_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Return just 5 rows.

[Assistant] SELECT text, edited_at, created_at FROM manufacturing.articles WHERE edited_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 5;


[User] Get payee_id, payment_date, invoice_number from all billing.

[Assistant] SELECT payee_id, payment_date, invoice_number FROM manufacturing.billing;

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

[Assistant] SELECT payee_id, payment_date, invoice_number FROM manufacturing.billing WHERE processed_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Can you order these by invoice_number descending?

[Assistant] SELECT payee_id, payment_date, invoice_number FROM manufacturing.billing WHERE processed_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY invoice_number DESC;


[User] List keywords, edited_at, likes from articles.

[Assistant] SELECT keywords, edited_at, likes FROM manufacturing.articles;

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

[Assistant] SELECT keywords, edited_at, likes FROM manufacturing.articles WHERE edited_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Calculate count of created_at for each keywords in articles.

[Assistant] SELECT keywords, COUNT(created_at) AS count_created_at FROM manufacturing.articles GROUP BY keywords;


[User] List payee_id, processed_at, credit from billing.

[Assistant] SELECT payee_id, processed_at, credit FROM manufacturing.billing;

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

[Assistant] SELECT payee_id, processed_at, credit FROM manufacturing.billing WHERE processed_at > '2023-01-01';

[User] Order the output by payee_id ascending.

[Assistant] SELECT payee_id, processed_at, credit FROM manufacturing.billing WHERE processed_at > '2023-01-01' ORDER BY payee_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 government.catalog (
  product_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp,
  updated_at timestamp,
  video_url char NOT NULL,
  subcategory character varying(64),
  stock_level text,
  rating character varying(64) NOT NULL,
  purchase_id integer -- reference to purchases.invoice_id,
  FOREIGN KEY (purchase_id) REFERENCES purchases(invoice_id)
)

CREATE TABLE government.purchases (
  invoice_id integer PRIMARY KEY -- unique identifier,
  cancelled_at timestamp without time zone,
  updated_at date,
  currency character varying(64),
  fee char,
  payment_status char,
  seller_id character varying(128) -- identifier for seller,
  exchange_rate character varying(128)
)

[User] Retrieve product_id, video_url, published_at for every catalog.

[Assistant] SELECT product_id, video_url, published_at FROM government.catalog;

[User] Get product_id, video_url, cancelled_at, payment_status by joining catalog with purchases.

[Assistant] SELECT product_id, video_url, published_at, purchases.cancelled_at, purchases.payment_status FROM government.catalog JOIN government.purchases ON catalog.purchase_id = purchases.invoice_id;

[User] Restrict the output to 50 items.

[Assistant] SELECT product_id, video_url, published_at, purchases.cancelled_at, purchases.payment_status FROM government.catalog JOIN government.purchases ON catalog.purchase_id = purchases.invoice_id LIMIT 50;


[User] Retrieve product_id, stock_level, rating for every catalog.

[Assistant] SELECT product_id, stock_level, rating FROM government.catalog;

[User] Sort the results by updated_at ascending.

[Assistant] SELECT product_id, stock_level, rating FROM government.catalog ORDER BY updated_at ASC;

[User] Count the number of catalog in each purchase_id category.

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


[User] Get all catalog.

[Assistant] SELECT * FROM government.catalog;

[User] Show the results sorted by purchase_id ascending.

[Assistant] SELECT * FROM government.catalog ORDER BY purchase_id ASC;

[User] Show only 10 records.

[Assistant] SELECT * FROM government.catalog ORDER BY purchase_id ASC LIMIT 10;


[User] Retrieve product_id, stock_level, subcategory for every catalog.

[Assistant] SELECT product_id, stock_level, subcategory FROM government.catalog;

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

[Assistant] SELECT product_id, stock_level, subcategory FROM government.catalog WHERE updated_at > '2023-12-01';

[User] Only show the top 100 results.

[Assistant] SELECT product_id, stock_level, subcategory FROM government.catalog WHERE updated_at > '2023-12-01' LIMIT 100;


[User] Retrieve all catalog.

[Assistant] SELECT * FROM government.catalog;

[User] Can you order these by subcategory ascending?

[Assistant] SELECT * FROM government.catalog ORDER BY subcategory ASC;

[User] Can you order these by rating descending?

[Assistant] SELECT * FROM government.catalog ORDER BY rating DESC;


[User] List all catalog.

[Assistant] SELECT * FROM government.catalog;

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

[Assistant] SELECT * FROM government.catalog WHERE product_id LIKE 'A%';

[User] Get the distribution of catalog across different published_at values.

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


[User] Show me video_url, stock_level, published_at for all catalog.

[Assistant] SELECT video_url, stock_level, published_at FROM government.catalog;

[User] Sort the results by published_at ascending.

[Assistant] SELECT video_url, stock_level, published_at FROM government.catalog ORDER BY published_at ASC;

[User] Tally up catalog by published_at.

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


[User] What are the product_id, published_at, stock_level of each catalog?

[Assistant] SELECT product_id, published_at, stock_level FROM government.catalog;

[User] Get updated_at, video_url, fee, updated_at by joining catalog with purchases.

[Assistant] SELECT product_id, published_at, stock_level, purchases.fee, purchases.updated_at FROM government.catalog JOIN government.purchases ON catalog.purchase_id = purchases.invoice_id;

[User] Tally up catalog by video_url.

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


[User] Retrieve subcategory, updated_at, stock_level for every catalog.

[Assistant] SELECT subcategory, updated_at, stock_level FROM government.catalog;

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

[Assistant] SELECT subcategory, updated_at, stock_level FROM government.catalog WHERE published_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Group catalog by purchase_id and show the min of stock_level.

[Assistant] SELECT purchase_id, MIN(stock_level) AS min_stock_level FROM government.catalog GROUP BY purchase_id;


[User] Display all catalog.

[Assistant] SELECT * FROM government.catalog;

[User] Order the output by purchase_id descending.

[Assistant] SELECT * FROM government.catalog ORDER BY purchase_id DESC;

[User] Show me count of published_at grouped by published_at for catalog.

[Assistant] SELECT published_at, COUNT(published_at) AS count_published_at FROM government.catalog GROUP BY published_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 education.grades (
  barcode varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  updated_at date,
  image_url varchar NOT NULL,
  category char,
  featured_rank char NOT NULL,
  course_id text NOT NULL -- reference to courses.customer_id,
  FOREIGN KEY (course_id) REFERENCES courses(customer_id)
)

CREATE TABLE education.courses (
  customer_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  updated_at date,
  country char NOT NULL,
  email char,
  birth_date date,
  is_active boolean
)

[User] What are the course_id, image_url, created_at of each grade?

[Assistant] SELECT course_id, image_url, created_at FROM education.grades;

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

[Assistant] SELECT course_id, image_url, created_at FROM education.grades WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

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

[Assistant] SELECT course_id, image_url, created_at FROM education.grades WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY image_url DESC;


[User] What are the image_url, created_at, featured_rank of each grade?

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

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

[Assistant] SELECT image_url, created_at, featured_rank FROM education.grades WHERE image_url LIKE 'A%';

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

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


[User] Retrieve created_at, updated_at, category for every grade.

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

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

[Assistant] SELECT created_at, updated_at, category FROM education.grades WHERE updated_at > '2023-01-01';

[User] What is the max created_at for each category in grades?

[Assistant] SELECT category, MAX(created_at) AS max_created_at FROM education.grades GROUP BY category;


[User] Retrieve all grades.

[Assistant] SELECT * FROM education.grades;

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

[Assistant] SELECT * FROM education.grades WHERE updated_at > '2023-01-01';

[User] Return just 15 rows.

[Assistant] SELECT * FROM education.grades WHERE updated_at > '2023-01-01' LIMIT 15;


[User] List image_url, category, updated_at from grades.

[Assistant] SELECT image_url, category, updated_at FROM education.grades;

[User] Order the output by updated_at descending.

[Assistant] SELECT image_url, category, updated_at FROM education.grades ORDER BY updated_at DESC;

[User] Show only 100 records.

[Assistant] SELECT image_url, category, updated_at FROM education.grades ORDER BY updated_at DESC LIMIT 100;


[User] Show me course_id, created_at, image_url for all grades.

[Assistant] SELECT course_id, created_at, image_url FROM education.grades;

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

[Assistant] SELECT course_id, created_at, image_url FROM education.grades WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Sort the results by updated_at ascending.

[Assistant] SELECT course_id, created_at, image_url FROM education.grades WHERE created_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY updated_at ASC;


[User] Display all grades.

[Assistant] SELECT * FROM education.grades;

[User] Sort the results by featured_rank ascending.

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

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

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


[User] What are the created_at, updated_at, category of each grade?

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

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

[Assistant] SELECT created_at, updated_at, category FROM education.grades ORDER BY featured_rank ASC;

[User] How many grades are there per updated_at?

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


[User] List all grades.

[Assistant] SELECT * FROM education.grades;

[User] List category, course_id, birth_date, country for each grade along with their course information.

[Assistant] SELECT *, courses.birth_date, courses.country FROM education.grades JOIN education.courses ON grades.course_id = courses.customer_id;

[User] Return just 25 rows.

[Assistant] SELECT *, courses.birth_date, courses.country FROM education.grades JOIN education.courses ON grades.course_id = courses.customer_id LIMIT 25;


[User] Show me all grades.

[Assistant] SELECT * FROM education.grades;

[User] Get grades that match category LIKE 'A%'.

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

[User] Show me max of category grouped by updated_at for grades.

[Assistant] SELECT updated_at, MAX(category) AS max_category FROM education.grades GROUP BY updated_at;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.users (
  person_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  updated_at date,
  nationality text NOT NULL,
  address char NOT NULL,
  membership_level character varying(64),
  full_name character varying(128) NOT NULL,
  password_hash character varying(64),
  is_verified bit
)

CREATE TABLE e-commerce.shipping (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  website character varying(256) NOT NULL,
  timezone character varying(256),
  account_status character varying(128),
  user_id text NOT NULL -- reference to users.person_id,
  FOREIGN KEY (user_id) REFERENCES users(person_id)
)

[User] Retrieve timezone, user_id, account_status for every shipping.

[Assistant] SELECT timezone, user_id, account_status FROM e-commerce.shipping;

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

[Assistant] SELECT timezone, user_id, account_status FROM e-commerce.shipping ORDER BY website ASC;

[User] Order the output by website descending.

[Assistant] SELECT timezone, user_id, account_status FROM e-commerce.shipping ORDER BY website DESC;


[User] Show me account_status, user_id, id for all shipping.

[Assistant] SELECT account_status, user_id, id FROM e-commerce.shipping;

[User] Sort the results by id descending.

[Assistant] SELECT account_status, user_id, id FROM e-commerce.shipping ORDER BY id DESC;

[User] Limit the results to 20 rows.

[Assistant] SELECT account_status, user_id, id FROM e-commerce.shipping ORDER BY id DESC LIMIT 20;


[User] List all shipping.

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

[User] Find shipping older than 6 months.

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

[User] Order the output by website descending.

[Assistant] SELECT * FROM e-commerce.shipping WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY website DESC;


[User] Display all shipping.

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

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

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

[User] Group shipping by updated_at and show the count of account_status.

[Assistant] SELECT updated_at, COUNT(account_status) AS count_account_status FROM e-commerce.shipping GROUP BY updated_at;


[User] Retrieve user_id, timezone, account_status for every shipping.

[Assistant] SELECT user_id, timezone, account_status FROM e-commerce.shipping;

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

[Assistant] SELECT user_id, timezone, account_status FROM e-commerce.shipping WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Calculate count of updated_at for each account_status in shipping.

[Assistant] SELECT account_status, COUNT(updated_at) AS count_updated_at FROM e-commerce.shipping GROUP BY account_status;


[User] Show me all shipping.

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

[User] Get all shipping between January and March.

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

[User] Only show the top 15 results.

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


[User] Retrieve website, user_id, account_status for every shipping.

[Assistant] SELECT website, user_id, account_status FROM e-commerce.shipping;

[User] Retrieve account_status, user_id, full_name, updated_at showing the relationship between shipping and users.

[Assistant] SELECT website, user_id, account_status, users.full_name, users.updated_at FROM e-commerce.shipping JOIN e-commerce.users ON shipping.user_id = users.person_id;

[User] Tally up shipping by updated_at.

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


[User] Show me all shipping.

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

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

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

[User] Get min of id by updated_at from shipping.

[Assistant] SELECT updated_at, MIN(id) AS min_id FROM e-commerce.shipping GROUP BY updated_at;


[User] Show me all shipping.

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

[User] Can you order these by timezone ascending?

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

[User] Only show the top 10 results.

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


[User] Get all shipping.

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

[User] Can you order these by id ascending?

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

[User] Show only 10 records.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE travel.users (
  customer_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  language char NOT NULL,
  last_login timestamp without time zone NOT NULL,
  status character varying(64),
  is_verified bit,
  timezone character varying(256),
  facilitie_id integer NOT NULL -- reference to facilities.address_id,
  FOREIGN KEY (facilitie_id) REFERENCES facilities(address_id)
)

CREATE TABLE travel.facilities (
  address_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at timestamp,
  latitude character varying(128),
  type character varying(128),
  location_lat character varying(64),
  street text,
  location_lon character varying(128),
  postal_code text,
  user_id text NOT NULL -- reference to users.customer_id,
  FOREIGN KEY (user_id) REFERENCES users(customer_id)
)

[User] List all users.

[Assistant] SELECT * FROM travel.users;

[User] Can you order these by is_verified ascending?

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

[User] Return just 100 rows.

[Assistant] SELECT * FROM travel.users ORDER BY is_verified ASC LIMIT 100;


[User] List location_lon, updated_at, postal_code from facilities.

[Assistant] SELECT location_lon, updated_at, postal_code FROM travel.facilities;

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

[Assistant] SELECT location_lon, updated_at, postal_code FROM travel.facilities WHERE user_id LIKE 'A%';

[User] Only show the top 15 results.

[Assistant] SELECT location_lon, updated_at, postal_code FROM travel.facilities WHERE user_id LIKE 'A%' LIMIT 15;


[User] Show me all users.

[Assistant] SELECT * FROM travel.users;

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

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

[User] Calculate max of last_login for each updated_at in users.

[Assistant] SELECT updated_at, MAX(last_login) AS max_last_login FROM travel.users GROUP BY updated_at;


[User] Display all users.

[Assistant] SELECT * FROM travel.users;

[User] List status, timezone, location_lon, user_id for each user along with their facilitie information.

[Assistant] SELECT *, facilities.location_lon, facilities.user_id FROM travel.users JOIN travel.facilities ON users.facilitie_id = facilities.address_id;

[User] Only show the top 10 results.

[Assistant] SELECT *, facilities.location_lon, facilities.user_id FROM travel.users JOIN travel.facilities ON users.facilitie_id = facilities.address_id LIMIT 10;


[User] Show me is_verified, language, status for all users.

[Assistant] SELECT is_verified, language, status FROM travel.users;

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

[Assistant] SELECT is_verified, language, status FROM travel.users WHERE last_login > '2023-01-01';

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

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


[User] Display all facilities.

[Assistant] SELECT * FROM travel.facilities;

[User] Show me facilities with street LIKE 'A%'.

[Assistant] SELECT * FROM travel.facilities WHERE street LIKE 'A%';

[User] Tally up facilities by user_id.

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


[User] Show me updated_at, timezone, status for all users.

[Assistant] SELECT updated_at, timezone, status FROM travel.users;

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

[Assistant] SELECT updated_at, timezone, status FROM travel.users WHERE updated_at > '2023-01-01';

[User] Show only 25 records.

[Assistant] SELECT updated_at, timezone, status FROM travel.users WHERE updated_at > '2023-01-01' LIMIT 25;


[User] Get all facilities.

[Assistant] SELECT * FROM travel.facilities;

[User] Retrieve facilities where location_lon LIKE 'A%'.

[Assistant] SELECT * FROM travel.facilities WHERE location_lon LIKE 'A%';

[User] Return just 100 rows.

[Assistant] SELECT * FROM travel.facilities WHERE location_lon LIKE 'A%' LIMIT 100;


[User] Retrieve location_lat, street, type for every facilitie.

[Assistant] SELECT location_lat, street, type FROM travel.facilities;

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

[Assistant] SELECT location_lat, street, type FROM travel.facilities WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Tally up facilities by type.

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


[User] Show me all users.

[Assistant] SELECT * FROM travel.users;

[User] Sort the results by facilitie_id descending.

[Assistant] SELECT * FROM travel.users ORDER BY facilitie_id DESC;

[User] Group users by language and show the max of status.

[Assistant] SELECT language, MAX(status) AS max_status FROM travel.users GROUP BY language;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.orders (
  invoice_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  exchange_rate character varying(128),
  total decimal NOT NULL,
  card_type character varying(256),
  categorie_id integer -- reference to categories.post_id,
  FOREIGN KEY (categorie_id) REFERENCES categories(post_id)
)

CREATE TABLE e-commerce.categories (
  post_id integer PRIMARY KEY -- unique identifier,
  published_at date,
  created_at timestamp,
  tags varchar,
  image_url char,
  score character varying(128),
  keywords character varying(128) NOT NULL
)

CREATE TABLE e-commerce.inventory (
  sku varchar PRIMARY KEY -- unique identifier,
  created_at date,
  published_at timestamp,
  reserved text NOT NULL,
  backorder character varying(128),
  thumbnail_url character varying(64)
)

[User] List all orders.

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

[User] Get orders that match total > 65.

[Assistant] SELECT * FROM e-commerce.orders WHERE total > 65;

[User] Restrict the output to 25 items.

[Assistant] SELECT * FROM e-commerce.orders WHERE total > 65 LIMIT 25;


[User] Retrieve categorie_id, exchange_rate, updated_at for every order.

[Assistant] SELECT categorie_id, exchange_rate, updated_at FROM e-commerce.orders;

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

[Assistant] SELECT categorie_id, exchange_rate, updated_at FROM e-commerce.orders WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Return just 25 rows.

[Assistant] SELECT categorie_id, exchange_rate, updated_at FROM e-commerce.orders WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31' LIMIT 25;


[User] Retrieve all orders.

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

[User] Order the output by categorie_id ascending.

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

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

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


[User] List all orders.

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

[User] Order the output by card_type descending.

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

[User] Limit the results to 100 rows.

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


[User] List all orders.

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

[User] Retrieve card_type, total, keywords, tags showing the relationship between orders and categories.

[Assistant] SELECT *, categories.keywords, categories.tags FROM e-commerce.orders JOIN e-commerce.categories ON orders.categorie_id = categories.post_id;

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

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


[User] List updated_at, total, categorie_id from orders.

[Assistant] SELECT updated_at, total, categorie_id FROM e-commerce.orders;

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

[Assistant] SELECT updated_at, total, categorie_id FROM e-commerce.orders ORDER BY exchange_rate DESC;

[User] Restrict the output to 10 items.

[Assistant] SELECT updated_at, total, categorie_id FROM e-commerce.orders ORDER BY exchange_rate DESC LIMIT 10;


[User] Display all orders.

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

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

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

[User] How many orders are there per categorie_id?

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


[User] What are the updated_at, categorie_id, exchange_rate of each order?

[Assistant] SELECT updated_at, categorie_id, exchange_rate FROM e-commerce.orders;

[User] Show me exchange_rate, card_type, image_url, published_at from orders and their related categories.

[Assistant] SELECT updated_at, categorie_id, exchange_rate, categories.image_url, categories.published_at FROM e-commerce.orders JOIN e-commerce.categories ON orders.categorie_id = categories.post_id;

[User] Return just 25 rows.

[Assistant] SELECT updated_at, categorie_id, exchange_rate, categories.image_url, categories.published_at FROM e-commerce.orders JOIN e-commerce.categories ON orders.categorie_id = categories.post_id LIMIT 25;


[User] Show me all orders.

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

[User] List orders with dates from last week.

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

[User] Show only 20 records.

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


[User] Retrieve all orders.

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

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

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

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

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.likes (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  processed_at timestamp,
  fee text,
  card_type character varying(128),
  price decimal,
  buyer_id text -- identifier for buyer,
  account_id varchar,
  user_id text -- identifier for user,
  message_id text NOT NULL -- reference to messages.message_id,
  FOREIGN KEY (message_id) REFERENCES messages(message_id)
)

CREATE TABLE socialmedia.messages (
  message_id text PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  edited_at date,
  message char,
  thumbnail varchar NOT NULL,
  subject character varying(128),
  title char,
  attachment_url character varying(128),
  views char
)

[User] Show me all likes.

[Assistant] SELECT * FROM socialmedia.likes;

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

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

[User] Show me the count of likes grouped by invoice_id.

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


[User] List all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] Get likes that match processed_at > '2023-01-01'.

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

[User] Tally up likes by buyer_id.

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


[User] Retrieve all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] What invoice_id, user_id, message, attachment_url do we have for likes and their associated messages?

[Assistant] SELECT *, messages.message, messages.attachment_url FROM socialmedia.likes JOIN socialmedia.messages ON likes.message_id = messages.message_id;

[User] What is the sum card_type for each card_type in likes?

[Assistant] SELECT card_type, SUM(card_type) AS sum_card_type FROM socialmedia.likes GROUP BY card_type;


[User] List processed_at, buyer_id, invoice_id from likes.

[Assistant] SELECT processed_at, buyer_id, invoice_id FROM socialmedia.likes;

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

[Assistant] SELECT processed_at, buyer_id, invoice_id FROM socialmedia.likes WHERE processed_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Tally up likes by message_id.

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