[User] Show me all likes.

[Assistant] SELECT * FROM socialmedia.likes;

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

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

[User] Sort the results by card_type descending.

[Assistant] SELECT * FROM socialmedia.likes WHERE processed_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY card_type 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] List user_id, fee, processed_at from likes.

[Assistant] SELECT user_id, fee, processed_at FROM socialmedia.likes;

[User] List processed_at, price, subject, views for each like along with their message information.

[Assistant] SELECT user_id, fee, processed_at, messages.subject, messages.views FROM socialmedia.likes JOIN socialmedia.messages ON likes.message_id = messages.message_id;

[User] Get min of price by fee from likes.

[Assistant] SELECT fee, MIN(price) AS min_price FROM socialmedia.likes GROUP BY fee;


[User] List fee, buyer_id, card_type from likes.

[Assistant] SELECT fee, buyer_id, card_type FROM socialmedia.likes;

[User] List likes that have message_id LIKE 'A%'.

[Assistant] SELECT fee, buyer_id, card_type FROM socialmedia.likes WHERE message_id LIKE 'A%';

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

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


[User] List all likes.

[Assistant] SELECT * FROM socialmedia.likes;

[User] List likes with dates from 2023.

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

[User] Group likes by processed_at and show the sum of account_id.

[Assistant] SELECT processed_at, SUM(account_id) AS sum_account_id FROM socialmedia.likes GROUP BY processed_at;


[User] Get all likes.

[Assistant] SELECT * FROM socialmedia.likes;

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

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

[User] What is the min account_id for each price in likes?

[Assistant] SELECT price, MIN(account_id) AS min_account_id FROM socialmedia.likes GROUP BY price;


[User] Show me processed_at, user_id, message_id for all likes.

[Assistant] SELECT processed_at, user_id, message_id FROM socialmedia.likes;

[User] List fee, message_id, thumbnail, published_at for each like along with their message information.

[Assistant] SELECT processed_at, user_id, message_id, messages.thumbnail, messages.published_at FROM socialmedia.likes JOIN socialmedia.messages ON likes.message_id = messages.message_id;

[User] Group likes by fee and show the average of price.

[Assistant] SELECT fee, AVERAGE(price) AS average_price FROM socialmedia.likes GROUP BY fee;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE music.merchandise (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  name character varying(64) NOT NULL,
  video_url character varying(128) -- identifier for video_url,
  reserved character varying(128) NOT NULL,
  popularity_score varchar,
  account_id text -- reference to accounts.id,
  FOREIGN KEY (account_id) REFERENCES accounts(id)
)

CREATE TABLE music.accounts (
  id varchar PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  vendor_id char,
  user_id char -- identifier for user,
  notes character varying(256) NOT NULL,
  reconciliation_status character varying(256) NOT NULL,
  credit text
)

CREATE TABLE music.orders (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp,
  approval_status character varying(256) NOT NULL,
  tax smallint,
  seller_id character varying(256),
  quantity varchar NOT NULL,
  status character varying(64)
)

[User] List all merchandise.

[Assistant] SELECT * FROM music.merchandise;

[User] Order the output by video_url descending.

[Assistant] SELECT * FROM music.merchandise ORDER BY video_url DESC;

[User] Show the results sorted by name descending.

[Assistant] SELECT * FROM music.merchandise ORDER BY name DESC;


[User] Get all merchandise.

[Assistant] SELECT * FROM music.merchandise;

[User] Retrieve account_id, video_url, payment_date, vendor_id showing the relationship between merchandise and accounts.

[Assistant] SELECT *, accounts.payment_date, accounts.vendor_id FROM music.merchandise JOIN music.accounts ON merchandise.account_id = accounts.id;

[User] Get min of name by updated_at from merchandise.

[Assistant] SELECT updated_at, MIN(name) AS min_name FROM music.merchandise GROUP BY updated_at;


[User] Display all merchandise.

[Assistant] SELECT * FROM music.merchandise;

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

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

[User] Can you order these by video_url descending?

[Assistant] SELECT * FROM music.merchandise WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY video_url DESC;


[User] Get name, id, video_url from all merchandise.

[Assistant] SELECT name, id, video_url FROM music.merchandise;

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

[Assistant] SELECT name, id, video_url FROM music.merchandise WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Calculate sum of video_url for each reserved in merchandise.

[Assistant] SELECT reserved, SUM(video_url) AS sum_video_url FROM music.merchandise GROUP BY reserved;


[User] Show me reserved, account_id, updated_at for all merchandise.

[Assistant] SELECT reserved, account_id, updated_at FROM music.merchandise;

[User] Show me reserved, popularity_score, reconciliation_status, notes from merchandise and their related accounts.

[Assistant] SELECT reserved, account_id, updated_at, accounts.reconciliation_status, accounts.notes FROM music.merchandise JOIN music.accounts ON merchandise.account_id = accounts.id;

[User] Can you order these by id descending?

[Assistant] SELECT reserved, account_id, updated_at, accounts.reconciliation_status, accounts.notes FROM music.merchandise JOIN music.accounts ON merchandise.account_id = accounts.id ORDER BY id DESC;


[User] Get name, popularity_score, reserved from all merchandise.

[Assistant] SELECT name, popularity_score, reserved FROM music.merchandise;

[User] Sort the results by video_url descending.

[Assistant] SELECT name, popularity_score, reserved FROM music.merchandise ORDER BY video_url DESC;

[User] Calculate min of popularity_score for each updated_at in merchandise.

[Assistant] SELECT updated_at, MIN(popularity_score) AS min_popularity_score FROM music.merchandise GROUP BY updated_at;


[User] Retrieve all merchandise.

[Assistant] SELECT * FROM music.merchandise;

[User] Show me merchandise with name LIKE 'A%'.

[Assistant] SELECT * FROM music.merchandise WHERE name LIKE 'A%';

[User] Order the output by popularity_score descending.

[Assistant] SELECT * FROM music.merchandise WHERE name LIKE 'A%' ORDER BY popularity_score DESC;


[User] Show me name, updated_at, id for all merchandise.

[Assistant] SELECT name, updated_at, id FROM music.merchandise;

[User] List merchandise that have video_url LIKE 'A%'.

[Assistant] SELECT name, updated_at, id FROM music.merchandise WHERE video_url LIKE 'A%';

[User] Get min of id by id from merchandise.

[Assistant] SELECT id, MIN(id) AS min_id FROM music.merchandise GROUP BY id;


[User] What are the reserved, account_id, name of each merchandise?

[Assistant] SELECT reserved, account_id, name FROM music.merchandise;

[User] Can you order these by id ascending?

[Assistant] SELECT reserved, account_id, name FROM music.merchandise ORDER BY id ASC;

[User] Show me average of updated_at grouped by name for merchandise.

[Assistant] SELECT name, AVERAGE(updated_at) AS average_updated_at FROM music.merchandise GROUP BY name;


[User] What are the reserved, account_id, popularity_score of each merchandise?

[Assistant] SELECT reserved, account_id, popularity_score FROM music.merchandise;

[User] Get video_url, popularity_score, notes, vendor_id by joining merchandise with accounts.

[Assistant] SELECT reserved, account_id, popularity_score, accounts.notes, accounts.vendor_id FROM music.merchandise JOIN music.accounts ON merchandise.account_id = accounts.id;

[User] Restrict the output to 50 items.

[Assistant] SELECT reserved, account_id, popularity_score, accounts.notes, accounts.vendor_id FROM music.merchandise JOIN music.accounts ON merchandise.account_id = accounts.id LIMIT 50;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.order_items (
  id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  currency character varying(64),
  payee_id character varying(128) -- identifier for payee,
  debit text NOT NULL,
  vendor_id varchar,
  approval_status character varying(256),
  status character varying(128) NOT NULL
)

CREATE TABLE e-commerce.users (
  id varchar PRIMARY KEY -- unique identifier,
  joined_at timestamp,
  display_name text,
  password_hash character varying(256),
  salt text,
  is_active boolean -- indicates if active is true,
  bio char NOT NULL
)

CREATE TABLE e-commerce.products (
  barcode character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  thumbnail_url text NOT NULL,
  backorder text,
  user_id text -- reference to users.id,
  order_item_id text -- reference to order_items.id,
  FOREIGN KEY (user_id) REFERENCES users(id),
  FOREIGN KEY (order_item_id) REFERENCES order_items(id)
)

[User] Show me all products.

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

[User] List backorder, order_item_id, is_active, salt for each product along with their user information.

[Assistant] SELECT *, users.is_active, users.salt FROM e-commerce.products JOIN e-commerce.users ON products.user_id = users.id;

[User] Return just 100 rows.

[Assistant] SELECT *, users.is_active, users.salt FROM e-commerce.products JOIN e-commerce.users ON products.user_id = users.id LIMIT 100;


[User] Show me updated_at, user_id, order_item_id for all products.

[Assistant] SELECT updated_at, user_id, order_item_id FROM e-commerce.products;

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

[Assistant] SELECT updated_at, user_id, order_item_id FROM e-commerce.products WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Order the output by barcode ascending.

[Assistant] SELECT updated_at, user_id, order_item_id FROM e-commerce.products WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY barcode ASC;


[User] Get all products.

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

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

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

[User] Order the output by order_item_id descending.

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


[User] Show me backorder, order_item_id, barcode for all products.

[Assistant] SELECT backorder, order_item_id, barcode FROM e-commerce.products;

[User] What user_id, thumbnail_url, salt, is_active do we have for products and their associated users?

[Assistant] SELECT backorder, order_item_id, barcode, users.salt, users.is_active FROM e-commerce.products JOIN e-commerce.users ON products.user_id = users.id;

[User] Only show the top 20 results.

[Assistant] SELECT backorder, order_item_id, barcode, users.salt, users.is_active FROM e-commerce.products JOIN e-commerce.users ON products.user_id = users.id LIMIT 20;


[User] Show me updated_at, backorder, order_item_id for all products.

[Assistant] SELECT updated_at, backorder, order_item_id FROM e-commerce.products;

[User] Can you order these by barcode descending?

[Assistant] SELECT updated_at, backorder, order_item_id FROM e-commerce.products ORDER BY barcode DESC;

[User] Can you order these by thumbnail_url descending?

[Assistant] SELECT updated_at, backorder, order_item_id FROM e-commerce.products ORDER BY thumbnail_url DESC;


[User] Retrieve all products.

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

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

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

[User] Can you order these by order_item_id descending?

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


[User] Show me user_id, updated_at, thumbnail_url for all products.

[Assistant] SELECT user_id, updated_at, thumbnail_url FROM e-commerce.products;

[User] Find products older than 6 months.

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

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

[Assistant] SELECT user_id, updated_at, thumbnail_url FROM e-commerce.products WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY order_item_id ASC;


[User] What are the thumbnail_url, updated_at, backorder of each product?

[Assistant] SELECT thumbnail_url, updated_at, backorder FROM e-commerce.products;

[User] What order_item_id, updated_at, is_active, bio do we have for products and their associated users?

[Assistant] SELECT thumbnail_url, updated_at, backorder, users.is_active, users.bio FROM e-commerce.products JOIN e-commerce.users ON products.user_id = users.id;

[User] Tally up products by updated_at.

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


[User] List all products.

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

[User] Can you order these by user_id ascending?

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

[User] What is the count backorder for each updated_at in products?

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


[User] Get all products.

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

[User] Sort the results by order_item_id descending.

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

[User] Sort the results by thumbnail_url ascending.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.messages (
  message_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp without time zone,
  updated_at date,
  score text,
  description varchar,
  reply_to_id character varying(64),
  media_url text,
  thumbnail char,
  parent_id text -- identifier for parent,
  follower_id text NOT NULL -- reference to followers.product_id,
  FOREIGN KEY (follower_id) REFERENCES followers(product_id)
)

CREATE TABLE socialmedia.followers (
  product_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  title text,
  currency text NOT NULL,
  thumbnail_url character varying(64),
  video_url varchar -- identifier for video_url,
  discount bigint,
  media_url character varying(128)
)

CREATE TABLE socialmedia.groups (
  item_id character varying(64) NOT NULL -- unique identifier,
  published_at timestamp,
  msrp char,
  discount bigint NOT NULL,
  brand char,
  available character varying(128),
  video_url character varying(256)
)

[User] Display all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Get all messages from last week.

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

[User] Get average of published_at by parent_id from messages.

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


[User] Get all messages.

[Assistant] SELECT * FROM socialmedia.messages;

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

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

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

[Assistant] SELECT * FROM socialmedia.messages WHERE published_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY media_url ASC;


[User] Get all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Show the results sorted by media_url descending.

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

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

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


[User] List all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Sort the results by thumbnail ascending.

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

[User] Count the number of messages in each media_url category.

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


[User] Show me all messages.

[Assistant] SELECT * FROM socialmedia.messages;

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

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

[User] Limit the results to 100 rows.

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


[User] Get all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] List parent_id, reply_to_id, created_at, video_url for each message along with their follower information.

[Assistant] SELECT *, followers.created_at, followers.video_url FROM socialmedia.messages JOIN socialmedia.followers ON messages.follower_id = followers.product_id;

[User] Only show the top 25 results.

[Assistant] SELECT *, followers.created_at, followers.video_url FROM socialmedia.messages JOIN socialmedia.followers ON messages.follower_id = followers.product_id LIMIT 25;


[User] List all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Sort the results by media_url ascending.

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

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

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


[User] Retrieve all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Show me thumbnail, message_id, created_at, thumbnail_url from messages and their related followers.

[Assistant] SELECT *, followers.created_at, followers.thumbnail_url FROM socialmedia.messages JOIN socialmedia.followers ON messages.follower_id = followers.product_id;

[User] Group messages by updated_at and show the min of published_at.

[Assistant] SELECT updated_at, MIN(published_at) AS min_published_at FROM socialmedia.messages GROUP BY updated_at;


[User] List published_at, follower_id, description from messages.

[Assistant] SELECT published_at, follower_id, description FROM socialmedia.messages;

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

[Assistant] SELECT published_at, follower_id, description FROM socialmedia.messages WHERE score LIKE 'A%';

[User] Only show the top 50 results.

[Assistant] SELECT published_at, follower_id, description FROM socialmedia.messages WHERE score LIKE 'A%' LIMIT 50;


[User] Get all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Sort the results by thumbnail descending.

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

[User] Show only 10 records.

[Assistant] SELECT * FROM socialmedia.messages ORDER BY thumbnail 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 education.students (
  user_id integer PRIMARY KEY -- unique identifier,
  joined_at date,
  display_name character varying(64) NOT NULL,
  website varchar,
  state text NOT NULL,
  language character varying(64),
  bio char NOT NULL,
  department_id integer NOT NULL -- reference to departments.employee_id,
  teacher_id text NOT NULL -- reference to teachers.account_id,
  FOREIGN KEY (department_id) REFERENCES departments(employee_id),
  FOREIGN KEY (teacher_id) REFERENCES teachers(account_id)
)

CREATE TABLE education.teachers (
  account_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  invoice_number char,
  description text,
  reference_number character varying(128)
)

CREATE TABLE education.departments (
  employee_id integer PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  website varchar,
  display_name char,
  age text NOT NULL,
  student_id integer -- reference to students.user_id,
  FOREIGN KEY (student_id) REFERENCES students(user_id)
)

[User] List all departments.

[Assistant] SELECT * FROM education.departments;

[User] List departments with dates created yesterday.

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

[User] Get max of display_name by display_name from departments.

[Assistant] SELECT display_name, MAX(display_name) AS max_display_name FROM education.departments GROUP BY display_name;


[User] List language, website, display_name from students.

[Assistant] SELECT language, website, display_name FROM education.students;

[User] Get state, bio, website, age by joining students with departments.

[Assistant] SELECT language, website, display_name, departments.website, departments.age FROM education.students JOIN education.departments ON students.department_id = departments.employee_id;

[User] Show me count of language grouped by department_id for students.

[Assistant] SELECT department_id, COUNT(language) AS count_language FROM education.students GROUP BY department_id;


[User] List age, website, student_id from departments.

[Assistant] SELECT age, website, student_id FROM education.departments;

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

[Assistant] SELECT age, website, student_id FROM education.departments WHERE display_name LIKE 'A%';

[User] Group departments by display_name and show the sum of age.

[Assistant] SELECT display_name, SUM(age) AS sum_age FROM education.departments GROUP BY display_name;


[User] List all departments.

[Assistant] SELECT * FROM education.departments;

[User] Show the results sorted by last_active ascending.

[Assistant] SELECT * FROM education.departments ORDER BY last_active ASC;

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

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


[User] List 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] Get the distribution of departments across different display_name values.

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


[User] Retrieve all departments.

[Assistant] SELECT * FROM education.departments;

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

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

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

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


[User] Get all departments.

[Assistant] SELECT * FROM education.departments;

[User] Show me display_name, age, joined_at, language from departments and their related students.

[Assistant] SELECT *, students.joined_at, students.language FROM education.departments JOIN education.students ON departments.student_id = students.user_id;

[User] Calculate max of student_id for each last_active in departments.

[Assistant] SELECT last_active, MAX(student_id) AS max_student_id FROM education.departments GROUP BY last_active;


[User] Display all students.

[Assistant] SELECT * FROM education.students;

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

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

[User] Order the output by language descending.

[Assistant] SELECT * FROM education.students WHERE joined_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY language DESC;


[User] Show me all departments.

[Assistant] SELECT * FROM education.departments;

[User] Find departments from last week.

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

[User] Return just 15 rows.

[Assistant] SELECT * FROM education.departments WHERE last_active >= CURRENT_DATE - INTERVAL '7 days' LIMIT 15;


[User] List state, bio, joined_at from students.

[Assistant] SELECT state, bio, joined_at FROM education.students;

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

[Assistant] SELECT state, bio, joined_at FROM education.students WHERE state LIKE 'A%';

[User] Calculate sum of teacher_id for each joined_at in students.

[Assistant] SELECT joined_at, SUM(teacher_id) AS sum_teacher_id FROM education.students GROUP BY joined_at;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.audits (
  employee_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  first_name character varying(64),
  account_status char,
  api_key character varying(64),
  is_verified bit NOT NULL -- indicates if verified is true,
  membership_level character varying(64),
  address varchar,
  country character varying(256)
)

CREATE TABLE finance.investments (
  store_id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  created_at timestamp,
  longitude text,
  description character varying(64),
  parking_available character varying(64),
  country char,
  payment_id integer -- reference to payments.payment_id,
  FOREIGN KEY (payment_id) REFERENCES payments(payment_id)
)

CREATE TABLE finance.loans (
  store_id text PRIMARY KEY -- unique identifier,
  last_inspected timestamp,
  created_at timestamp,
  operating_hours varchar,
  name char NOT NULL,
  type varchar,
  geo_point character varying(64),
  postal_code character varying(64)
)

CREATE TABLE finance.payments (
  payment_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at timestamp,
  exchange_rate varchar,
  card_type character varying(128),
  user_id character varying(256) -- identifier for user,
  seller_id character varying(256),
  delivery_status varchar,
  price numeric NOT NULL,
  loan_id text -- reference to loans.store_id,
  FOREIGN KEY (loan_id) REFERENCES loans(store_id)
)

[User] Retrieve all investments.

[Assistant] SELECT * FROM finance.investments;

[User] Can you order these by updated_at ascending?

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

[User] Group investments by payment_id and show the max of payment_id.

[Assistant] SELECT payment_id, MAX(payment_id) AS max_payment_id FROM finance.investments GROUP BY payment_id;


[User] Display all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Get payments that match price > 75.

[Assistant] SELECT * FROM finance.payments WHERE price > 75;

[User] Sort the results by created_at ascending.

[Assistant] SELECT * FROM finance.payments WHERE price > 75 ORDER BY created_at ASC;


[User] List all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Only show the top 15 results.

[Assistant] SELECT * FROM finance.payments WHERE created_at > '2023-12-01' LIMIT 15;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.loans (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  expires_at timestamp,
  quantity varchar NOT NULL,
  msrp char,
  featured_rank varchar,
  title character varying(256),
  tax_rate character varying(256),
  stock_level character varying(64),
  audit_id text NOT NULL -- reference to audits.product_id,
  FOREIGN KEY (audit_id) REFERENCES audits(product_id)
)

CREATE TABLE finance.investments (
  payment_id character varying(64) NOT NULL -- unique identifier,
  processed_at timestamp without time zone,
  exchange_rate char,
  delivery_status character varying(256) NOT NULL,
  seller_id character varying(256)
)

CREATE TABLE finance.accounts (
  payment_id character varying(64) NOT NULL -- unique identifier,
  due_date timestamp without time zone,
  currency character varying(128),
  description text NOT NULL,
  payee_id character varying(256) -- identifier for payee,
  reconciliation_status character varying(256) NOT NULL
)

CREATE TABLE finance.audits (
  product_id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp,
  quantity character varying(128) NOT NULL,
  stock_level varchar NOT NULL
)

[User] What are the msrp, quantity, stock_level of each loan?

[Assistant] SELECT msrp, quantity, stock_level FROM finance.loans;

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

[Assistant] SELECT msrp, quantity, stock_level FROM finance.loans WHERE expires_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Restrict the output to 15 items.

[Assistant] SELECT msrp, quantity, stock_level FROM finance.loans WHERE expires_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 15;


[User] List audit_id, updated_at, quantity from loans.

[Assistant] SELECT audit_id, updated_at, quantity FROM finance.loans;

[User] Show the results sorted by id descending.

[Assistant] SELECT audit_id, updated_at, quantity FROM finance.loans ORDER BY id DESC;

[User] Limit the results to 5 rows.

[Assistant] SELECT audit_id, updated_at, quantity FROM finance.loans ORDER BY id DESC LIMIT 5;


[User] Get audit_id, tax_rate, updated_at from all loans.

[Assistant] SELECT audit_id, tax_rate, updated_at FROM finance.loans;

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

[Assistant] SELECT audit_id, tax_rate, updated_at FROM finance.loans WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Show the results sorted by expires_at ascending.

[Assistant] SELECT audit_id, tax_rate, updated_at FROM finance.loans WHERE updated_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY expires_at ASC;


[User] Get all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Find loans modified within the last hour.

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

[User] How many loans are there per id?

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


[User] List all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Retrieve loans where msrp LIKE 'A%'.

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

[User] Show only 15 records.

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


[User] What are the id, updated_at, audit_id of each loan?

[Assistant] SELECT id, updated_at, audit_id FROM finance.loans;

[User] Show the results sorted by msrp ascending.

[Assistant] SELECT id, updated_at, audit_id FROM finance.loans ORDER BY msrp ASC;

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

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


[User] List all loans.

[Assistant] SELECT * FROM finance.loans;

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

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

[User] Show me sum of tax_rate grouped by audit_id for loans.

[Assistant] SELECT audit_id, SUM(tax_rate) AS sum_tax_rate FROM finance.loans GROUP BY audit_id;


[User] What are the updated_at, quantity, featured_rank of each loan?

[Assistant] SELECT updated_at, quantity, featured_rank FROM finance.loans;

[User] Order the output by tax_rate descending.

[Assistant] SELECT updated_at, quantity, featured_rank FROM finance.loans ORDER BY tax_rate DESC;

[User] Sort the results by updated_at ascending.

[Assistant] SELECT updated_at, quantity, featured_rank FROM finance.loans ORDER BY updated_at ASC;


[User] Retrieve all loans.

[Assistant] SELECT * FROM finance.loans;

[User] Sort the results by tax_rate ascending.

[Assistant] SELECT * FROM finance.loans ORDER BY tax_rate ASC;

[User] Can you order these by tax_rate descending?

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


[User] List updated_at, quantity, audit_id from loans.

[Assistant] SELECT updated_at, quantity, audit_id FROM finance.loans;

[User] Show the results sorted by stock_level ascending.

[Assistant] SELECT updated_at, quantity, audit_id FROM finance.loans ORDER BY stock_level ASC;

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

[Assistant] SELECT updated_at, quantity, audit_id FROM finance.loans ORDER BY audit_id 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.users (
  id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  gender character varying(64),
  display_name character varying(128),
  website character varying(256) NOT NULL,
  last_login timestamp without time zone,
  country character varying(256) NOT NULL,
  comment_id text NOT NULL -- reference to comments.content_id,
  FOREIGN KEY (comment_id) REFERENCES comments(content_id)
)

CREATE TABLE socialmedia.groups (
  message_id text PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  content varchar,
  views text,
  thumbnail varchar,
  reply_to_id character varying(256) NOT NULL,
  description character varying(64),
  image_url character varying(256) NOT NULL,
  user_id integer NOT NULL -- reference to users.id,
  FOREIGN KEY (user_id) REFERENCES users(id)
)

CREATE TABLE socialmedia.comments (
  content_id text PRIMARY KEY -- unique identifier,
  edited_at timestamp without time zone,
  score character varying(64),
  keywords character varying(256) NOT NULL,
  reply_to_id char -- identifier for reply_to,
  user_id integer NOT NULL -- reference to users.id,
  FOREIGN KEY (user_id) REFERENCES users(id)
)

[User] Display all groups.

[Assistant] SELECT * FROM socialmedia.groups;

[User] Order the output by views ascending.

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

[User] Show me max of user_id grouped by reply_to_id for groups.

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


[User] Display all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Get gender, created_at, reply_to_id, user_id by joining users with comments.

[Assistant] SELECT *, comments.reply_to_id, comments.user_id FROM socialmedia.users JOIN socialmedia.comments ON users.comment_id = comments.content_id;

[User] Tally up users by gender.

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


[User] List all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Show the results sorted by edited_at ascending.

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

[User] Limit the results to 50 rows.

[Assistant] SELECT * FROM socialmedia.comments ORDER BY edited_at ASC LIMIT 50;


[User] Get content, user_id, description from all groups.

[Assistant] SELECT content, user_id, description FROM socialmedia.groups;

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

[Assistant] SELECT content, user_id, description FROM socialmedia.groups ORDER BY views DESC;

[User] Tally up groups by content.

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


[User] Get all groups.

[Assistant] SELECT * FROM socialmedia.groups;

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

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

[User] Get average of thumbnail by content from groups.

[Assistant] SELECT content, AVERAGE(thumbnail) AS average_thumbnail FROM socialmedia.groups GROUP BY content;


[User] Show me edited_at, keywords, user_id for all comments.

[Assistant] SELECT edited_at, keywords, user_id FROM socialmedia.comments;

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

[Assistant] SELECT edited_at, keywords, user_id FROM socialmedia.comments WHERE edited_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Tally up comments by edited_at.

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


[User] Show me score, edited_at, reply_to_id for all comments.

[Assistant] SELECT score, edited_at, reply_to_id FROM socialmedia.comments;

[User] Get all comments created yesterday.

[Assistant] SELECT score, edited_at, reply_to_id FROM socialmedia.comments WHERE edited_at = CURRENT_DATE - INTERVAL '1 day';

[User] What is the average reply_to_id for each user_id in comments?

[Assistant] SELECT user_id, AVERAGE(reply_to_id) AS average_reply_to_id FROM socialmedia.comments GROUP BY user_id;


[User] Retrieve published_at, content, reply_to_id for every group.

[Assistant] SELECT published_at, content, reply_to_id FROM socialmedia.groups;

[User] Show me published_at, reply_to_id, last_login, comment_id from groups and their related users.

[Assistant] SELECT published_at, content, reply_to_id, users.last_login, users.comment_id FROM socialmedia.groups JOIN socialmedia.users ON groups.user_id = users.id;

[User] What is the average user_id for each views in groups?

[Assistant] SELECT views, AVERAGE(user_id) AS average_user_id FROM socialmedia.groups GROUP BY views;


[User] Show me all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] Retrieve score, keywords, comment_id, last_login showing the relationship between comments and users.

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

[User] Restrict the output to 25 items.

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


[User] List all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Get last_login, display_name, edited_at, score by joining users with comments.

[Assistant] SELECT *, comments.edited_at, comments.score FROM socialmedia.users JOIN socialmedia.comments ON users.comment_id = comments.content_id;

[User] Can you order these by gender ascending?

[Assistant] SELECT *, comments.edited_at, comments.score FROM socialmedia.users JOIN socialmedia.comments ON users.comment_id = comments.content_id ORDER BY gender ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.payments (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  payment_status char NOT NULL,
  currency character varying(128) NOT NULL,
  user_id character varying(256),
  buyer_id char -- identifier for buyer,
  product_id character varying(128) NOT NULL -- identifier for product,
  status varchar NOT NULL,
  customer_id text NOT NULL -- identifier for customer,
  investment_id text NOT NULL -- reference to investments.transaction_id,
  FOREIGN KEY (investment_id) REFERENCES investments(transaction_id)
)

CREATE TABLE finance.investments (
  transaction_id varchar PRIMARY KEY -- unique identifier,
  completed_at date,
  cancelled_at date,
  quantity character varying(128),
  currency character varying(128) NOT NULL
)

[User] List user_id, payment_status, status from payments.

[Assistant] SELECT user_id, payment_status, status FROM finance.payments;

[User] Show me currency, investment_id, completed_at, quantity from payments and their related investments.

[Assistant] SELECT user_id, payment_status, status, investments.completed_at, investments.quantity FROM finance.payments JOIN finance.investments ON payments.investment_id = investments.transaction_id;

[User] Calculate sum of buyer_id for each updated_at in payments.

[Assistant] SELECT updated_at, SUM(buyer_id) AS sum_buyer_id FROM finance.payments GROUP BY updated_at;


[User] Show me all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Limit the results to 10 rows.

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


[User] Display all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Can you order these by updated_at ascending?

[Assistant] SELECT * FROM finance.payments WHERE product_id LIKE 'A%' ORDER BY updated_at ASC;


[User] Display all payments.

[Assistant] SELECT * FROM finance.payments;

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

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

[User] Limit the results to 100 rows.

[Assistant] SELECT * FROM finance.payments WHERE buyer_id LIKE 'A%' LIMIT 100;


[User] Show me all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Show the results sorted by investment_id ascending.

[Assistant] SELECT * FROM finance.payments ORDER BY investment_id ASC;

[User] How many payments are there per updated_at?

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


[User] Show me investment_id, product_id, updated_at for all payments.

[Assistant] SELECT investment_id, product_id, updated_at FROM finance.payments;

[User] Show me payments that were created yesterday.

[Assistant] SELECT investment_id, product_id, updated_at FROM finance.payments WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

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

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


[User] Retrieve all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Find payments modified within the last hour.

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

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

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


[User] Get product_id, buyer_id, investment_id from all payments.

[Assistant] SELECT product_id, buyer_id, investment_id FROM finance.payments;

[User] What investment_id, buyer_id, completed_at, cancelled_at do we have for payments and their associated investments?

[Assistant] SELECT product_id, buyer_id, investment_id, investments.completed_at, investments.cancelled_at FROM finance.payments JOIN finance.investments ON payments.investment_id = investments.transaction_id;

[User] Show the results sorted by investment_id descending.

[Assistant] SELECT product_id, buyer_id, investment_id, investments.completed_at, investments.cancelled_at FROM finance.payments JOIN finance.investments ON payments.investment_id = investments.transaction_id ORDER BY investment_id DESC;


[User] Display all payments.

[Assistant] SELECT * FROM finance.payments;

[User] Find payments where currency LIKE 'A%'.

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

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

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


[User] Retrieve buyer_id, product_id, investment_id for every payment.

[Assistant] SELECT buyer_id, product_id, investment_id FROM finance.payments;

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

[Assistant] SELECT buyer_id, product_id, investment_id FROM finance.payments WHERE investment_id LIKE 'A%';

[User] Order the output by user_id descending.

[Assistant] SELECT buyer_id, product_id, investment_id FROM finance.payments WHERE investment_id LIKE 'A%' ORDER BY user_id DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE socialmedia.posts (
  comment_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  views character varying(256),
  keywords char NOT NULL,
  categories varchar,
  event_id integer NOT NULL -- reference to events.id,
  like_id text NOT NULL -- reference to likes.barcode,
  FOREIGN KEY (event_id) REFERENCES events(id),
  FOREIGN KEY (like_id) REFERENCES likes(barcode)
)

CREATE TABLE socialmedia.events (
  id integer PRIMARY KEY -- unique identifier,
  last_inspected timestamp,
  updated_at timestamp without time zone,
  timezone character varying(128),
  capacity varchar NOT NULL,
  state character varying(256),
  city character varying(256),
  coordinates text NOT NULL,
  location_lat character varying(256) NOT NULL,
  like_id text -- reference to likes.barcode,
  FOREIGN KEY (like_id) REFERENCES likes(barcode)
)

CREATE TABLE socialmedia.likes (
  barcode varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  updated_at timestamp without time zone,
  thumbnail_url varchar,
  category character varying(256),
  video_url text NOT NULL -- identifier for video_url
)

[User] Get all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Retrieve events where last_inspected > '2023-01-01'.

[Assistant] SELECT * FROM socialmedia.events WHERE last_inspected > '2023-01-01';

[User] Show only 15 records.

[Assistant] SELECT * FROM socialmedia.events WHERE last_inspected > '2023-01-01' LIMIT 15;


[User] What are the location_lat, state, timezone of each event?

[Assistant] SELECT location_lat, state, timezone FROM socialmedia.events;

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

[Assistant] SELECT location_lat, state, timezone FROM socialmedia.events WHERE updated_at > '2023-12-01';

[User] Return just 10 rows.

[Assistant] SELECT location_lat, state, timezone FROM socialmedia.events WHERE updated_at > '2023-12-01' LIMIT 10;


[User] Retrieve keywords, comment_id, created_at for every post.

[Assistant] SELECT keywords, comment_id, created_at FROM socialmedia.posts;

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

[Assistant] SELECT keywords, comment_id, created_at FROM socialmedia.posts WHERE created_at > '2023-12-01';

[User] Restrict the output to 5 items.

[Assistant] SELECT keywords, comment_id, created_at FROM socialmedia.posts WHERE created_at > '2023-12-01' LIMIT 5;


[User] What are the like_id, city, capacity of each event?

[Assistant] SELECT like_id, city, capacity FROM socialmedia.events;

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

[Assistant] SELECT like_id, city, capacity FROM socialmedia.events WHERE last_inspected <= CURRENT_DATE - INTERVAL '6 months';

[User] Restrict the output to 10 items.

[Assistant] SELECT like_id, city, capacity FROM socialmedia.events WHERE last_inspected <= CURRENT_DATE - INTERVAL '6 months' LIMIT 10;


[User] Retrieve all events.

[Assistant] SELECT * FROM socialmedia.events;

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

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

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

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


[User] Show me all posts.

[Assistant] SELECT * FROM socialmedia.posts;

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

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

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

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


[User] Show me timezone, city, coordinates for all events.

[Assistant] SELECT timezone, city, coordinates FROM socialmedia.events;

[User] Retrieve updated_at, capacity, thumbnail_url, category showing the relationship between events and likes.

[Assistant] SELECT timezone, city, coordinates, likes.thumbnail_url, likes.category FROM socialmedia.events JOIN socialmedia.likes ON events.like_id = likes.barcode;

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

[Assistant] SELECT timezone, city, coordinates, likes.thumbnail_url, likes.category FROM socialmedia.events JOIN socialmedia.likes ON events.like_id = likes.barcode ORDER BY like_id ASC;


[User] Display all events.

[Assistant] SELECT * FROM socialmedia.events;

[User] Get capacity, last_inspected, updated_at, created_at by joining events with likes.

[Assistant] SELECT *, likes.updated_at, likes.created_at FROM socialmedia.events JOIN socialmedia.likes ON events.like_id = likes.barcode;

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

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


[User] Retrieve location_lat, last_inspected, state for every event.

[Assistant] SELECT location_lat, last_inspected, state FROM socialmedia.events;

[User] Sort the results by last_inspected descending.

[Assistant] SELECT location_lat, last_inspected, state FROM socialmedia.events ORDER BY last_inspected DESC;

[User] Calculate max of last_inspected for each state in events.

[Assistant] SELECT state, MAX(last_inspected) AS max_last_inspected FROM socialmedia.events GROUP BY state;


[User] List all events.

[Assistant] SELECT * FROM socialmedia.events;

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

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

[User] How many events are there per city?

[Assistant] SELECT city, COUNT(*) AS count FROM socialmedia.events GROUP BY city 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.followers (
  user_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  joined_at timestamp without time zone,
  is_active bit,
  bio character varying(64) NOT NULL,
  api_key character varying(64),
  salt varchar NOT NULL,
  message_id integer -- reference to messages.comment_id,
  FOREIGN KEY (message_id) REFERENCES messages(comment_id)
)

CREATE TABLE socialmedia.messages (
  comment_id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  subject text,
  categories char NOT NULL,
  user_id text NOT NULL -- identifier for user,
  reply_to_id character varying(256) NOT NULL,
  description text,
  follower_id text -- reference to followers.user_id,
  FOREIGN KEY (follower_id) REFERENCES followers(user_id)
)

[User] Get all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Sort the results by message_id descending.

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

[User] Limit the results to 25 rows.

[Assistant] SELECT * FROM socialmedia.followers ORDER BY message_id DESC LIMIT 25;


[User] Retrieve is_active, joined_at, api_key for every follower.

[Assistant] SELECT is_active, joined_at, api_key FROM socialmedia.followers;

[User] List followers that have bio LIKE 'A%'.

[Assistant] SELECT is_active, joined_at, api_key FROM socialmedia.followers WHERE bio LIKE 'A%';

[User] How many followers are there per is_active?

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


[User] Retrieve reply_to_id, categories, user_id for every message.

[Assistant] SELECT reply_to_id, categories, user_id FROM socialmedia.messages;

[User] Retrieve categories, updated_at, bio, joined_at showing the relationship between messages and followers.

[Assistant] SELECT reply_to_id, categories, user_id, followers.bio, followers.joined_at FROM socialmedia.messages JOIN socialmedia.followers ON messages.follower_id = followers.user_id;

[User] How many messages are there per description?

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


[User] Show me updated_at, follower_id, subject for all messages.

[Assistant] SELECT updated_at, follower_id, subject FROM socialmedia.messages;

[User] List follower_id, updated_at, message_id, api_key for each message along with their follower information.

[Assistant] SELECT updated_at, follower_id, subject, followers.message_id, followers.api_key FROM socialmedia.messages JOIN socialmedia.followers ON messages.follower_id = followers.user_id;

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

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


[User] Display all messages.

[Assistant] SELECT * FROM socialmedia.messages;

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

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

[User] Restrict the output to 100 items.

[Assistant] SELECT * FROM socialmedia.messages ORDER BY description ASC LIMIT 100;


[User] Show me reply_to_id, follower_id, updated_at for all messages.

[Assistant] SELECT reply_to_id, follower_id, updated_at FROM socialmedia.messages;

[User] List follower_id, subject, created_at, api_key for each message along with their follower information.

[Assistant] SELECT reply_to_id, follower_id, updated_at, followers.created_at, followers.api_key FROM socialmedia.messages JOIN socialmedia.followers ON messages.follower_id = followers.user_id;

[User] Show me max of categories grouped by updated_at for messages.

[Assistant] SELECT updated_at, MAX(categories) AS max_categories FROM socialmedia.messages GROUP BY updated_at;


[User] Retrieve all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] What updated_at, user_id, created_at, message_id do we have for messages and their associated followers?

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

[User] Calculate max of categories for each updated_at in messages.

[Assistant] SELECT updated_at, MAX(categories) AS max_categories FROM socialmedia.messages GROUP BY updated_at;


[User] Get categories, follower_id, updated_at from all messages.

[Assistant] SELECT categories, follower_id, updated_at FROM socialmedia.messages;

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

[Assistant] SELECT categories, follower_id, updated_at FROM socialmedia.messages WHERE updated_at > '2023-01-01';

[User] Order the output by description descending.

[Assistant] SELECT categories, follower_id, updated_at FROM socialmedia.messages WHERE updated_at > '2023-01-01' ORDER BY description DESC;


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Get followers that match joined_at > '2023-01-01'.

[Assistant] SELECT * FROM socialmedia.followers WHERE joined_at > '2023-01-01';

[User] Group followers by created_at and show the average of message_id.

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


[User] Display all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Get followers that match is_active = TRUE.

[Assistant] SELECT * FROM socialmedia.followers WHERE is_active = TRUE;

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

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


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.departments (
  post_id text PRIMARY KEY -- unique identifier,
  published_at timestamp without time zone,
  visibility char NOT NULL,
  attachment_url character varying(128) NOT NULL,
  user_id varchar -- identifier for user,
  thumbnail character varying(64) NOT NULL,
  keywords text NOT NULL
)

CREATE TABLE healthcare.medical_records (
  id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  capacity character varying(64),
  operating_hours text,
  accessibility text
)

[User] Get all departments.

[Assistant] SELECT * FROM healthcare.departments;

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

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

[User] Calculate sum of visibility for each keywords in departments.

[Assistant] SELECT keywords, SUM(visibility) AS sum_visibility FROM healthcare.departments GROUP BY keywords;


[User] List all departments.

[Assistant] SELECT * FROM healthcare.departments;

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

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

[User] Only show the top 100 results.

[Assistant] SELECT * FROM healthcare.departments WHERE published_at > '2023-01-01' LIMIT 100;


[User] Get all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

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

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

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

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


[User] Show me user_id, keywords, published_at for all departments.

[Assistant] SELECT user_id, keywords, published_at FROM healthcare.departments;

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

[Assistant] SELECT user_id, keywords, published_at FROM healthcare.departments WHERE visibility LIKE 'A%';

[User] Show the results sorted by attachment_url descending.

[Assistant] SELECT user_id, keywords, published_at FROM healthcare.departments WHERE visibility LIKE 'A%' ORDER BY attachment_url DESC;


[User] Get all departments.

[Assistant] SELECT * FROM healthcare.departments;

[User] Sort the results by keywords ascending.

[Assistant] SELECT * FROM healthcare.departments ORDER BY keywords ASC;

[User] Can you order these by published_at descending?

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


[User] Show me published_at, thumbnail, user_id for all departments.

[Assistant] SELECT published_at, thumbnail, user_id FROM healthcare.departments;

[User] Get all departments created yesterday.

[Assistant] SELECT published_at, thumbnail, user_id FROM healthcare.departments WHERE published_at = CURRENT_DATE - INTERVAL '1 day';

[User] Only show the top 50 results.

[Assistant] SELECT published_at, thumbnail, user_id FROM healthcare.departments WHERE published_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 50;


[User] Get id, created_at, operating_hours from all medical_records.

[Assistant] SELECT id, created_at, operating_hours FROM healthcare.medical_records;

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

[Assistant] SELECT id, created_at, operating_hours FROM healthcare.medical_records WHERE capacity LIKE 'A%';

[User] Show the results sorted by operating_hours ascending.

[Assistant] SELECT id, created_at, operating_hours FROM healthcare.medical_records WHERE capacity LIKE 'A%' ORDER BY operating_hours ASC;


[User] Show me all departments.

[Assistant] SELECT * FROM healthcare.departments;

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

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

[User] Get count of attachment_url by thumbnail from departments.

[Assistant] SELECT thumbnail, COUNT(attachment_url) AS count_attachment_url FROM healthcare.departments GROUP BY thumbnail;


[User] Get capacity, accessibility, created_at from all medical_records.

[Assistant] SELECT capacity, accessibility, created_at FROM healthcare.medical_records;

[User] Show the results sorted by id descending.

[Assistant] SELECT capacity, accessibility, created_at FROM healthcare.medical_records ORDER BY id DESC;

[User] Calculate average of id for each capacity in medical_records.

[Assistant] SELECT capacity, AVERAGE(id) AS average_id FROM healthcare.medical_records GROUP BY capacity;


[User] Show me all medical_records.

[Assistant] SELECT * FROM healthcare.medical_records;

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

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

[User] Show me count of operating_hours grouped by id for medical_records.

[Assistant] SELECT id, COUNT(operating_hours) AS count_operating_hours FROM healthcare.medical_records GROUP BY id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.reviews (
  post_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  updated_at date,
  message varchar NOT NULL,
  user_id text -- identifier for user,
  likes character varying(256),
  rating character varying(64)
)

CREATE TABLE e-commerce.users (
  id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  phone character varying(128) NOT NULL,
  status character varying(128)
)

[User] Get all reviews.

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

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

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

[User] Limit the results to 50 rows.

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


[User] Show me all reviews.

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

[User] Show the results sorted by likes ascending.

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

[User] Tally up reviews by post_id.

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


[User] Show me created_at, status, phone for all users.

[Assistant] SELECT created_at, status, phone FROM e-commerce.users;

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

[Assistant] SELECT created_at, status, phone FROM e-commerce.users WHERE id LIKE 'A%';

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

[Assistant] SELECT created_at, status, phone FROM e-commerce.users WHERE id LIKE 'A%' ORDER BY phone DESC;


[User] Retrieve id, phone, status for every user.

[Assistant] SELECT id, phone, status FROM e-commerce.users;

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

[Assistant] SELECT id, phone, status FROM e-commerce.users WHERE created_at > '2023-01-01';

[User] What is the average phone for each status in users?

[Assistant] SELECT status, AVERAGE(phone) AS average_phone FROM e-commerce.users GROUP BY status;


[User] Retrieve all users.

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

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

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

[User] Sort the results by status descending.

[Assistant] SELECT * FROM e-commerce.users WHERE created_at > '2023-12-01' ORDER BY status DESC;


[User] List message, created_at, rating from reviews.

[Assistant] SELECT message, created_at, rating FROM e-commerce.reviews;

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

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

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

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


[User] Display all users.

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

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

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

[User] What is the average created_at for each status in users?

[Assistant] SELECT status, AVERAGE(created_at) AS average_created_at FROM e-commerce.users GROUP BY status;


[User] What are the rating, likes, updated_at of each review?

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

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

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

[User] Tally up reviews by likes.

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


[User] What are the id, phone, status of each user?

[Assistant] SELECT id, phone, status FROM e-commerce.users;

[User] Show me users that were created yesterday.

[Assistant] SELECT id, phone, status FROM e-commerce.users WHERE created_at = CURRENT_DATE - INTERVAL '1 day';

[User] Show the results sorted by status ascending.

[Assistant] SELECT id, phone, status FROM e-commerce.users WHERE created_at = CURRENT_DATE - INTERVAL '1 day' ORDER BY status ASC;


[User] List likes, post_id, rating from reviews.

[Assistant] SELECT likes, post_id, rating FROM e-commerce.reviews;

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

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

[User] How many reviews are there per message?

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.assets (
  id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  subcategory character varying(128) NOT NULL,
  thumbnail_url character varying(64),
  rating text,
  name text NOT NULL,
  user_id text NOT NULL -- reference to users.id,
  FOREIGN KEY (user_id) REFERENCES users(id)
)

CREATE TABLE tradingplatform.users (
  id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  first_name text NOT NULL,
  profile_picture_url text,
  username text NOT NULL,
  full_name character varying(128),
  country varchar NOT NULL,
  state character varying(256),
  token character varying(128) NOT NULL
)

CREATE TABLE tradingplatform.metadata (
  payment_id character varying(64) NOT NULL -- unique identifier,
  traded_at timestamp,
  updated_at date,
  status character varying(256),
  delivery_status char,
  fee text,
  seller_id varchar NOT NULL,
  account_id character varying(256),
  buyer_id char -- identifier for buyer,
  tax bigint NOT NULL,
  user_id text -- reference to users.id,
  asset_id text NOT NULL -- reference to assets.id,
  FOREIGN KEY (user_id) REFERENCES users(id),
  FOREIGN KEY (asset_id) REFERENCES assets(id)
)

[User] Retrieve rating, created_at, thumbnail_url for every asset.

[Assistant] SELECT rating, created_at, thumbnail_url FROM tradingplatform.assets;

[User] Find assets older than 6 months.

[Assistant] SELECT rating, created_at, thumbnail_url FROM tradingplatform.assets WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Restrict the output to 25 items.

[Assistant] SELECT rating, created_at, thumbnail_url FROM tradingplatform.assets WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 25;


[User] Show me updated_at, seller_id, traded_at for all metadata.

[Assistant] SELECT updated_at, seller_id, traded_at FROM tradingplatform.metadata;

[User] Get fee, traded_at, created_at, full_name by joining metadata with users.

[Assistant] SELECT updated_at, seller_id, traded_at, users.created_at, users.full_name FROM tradingplatform.metadata JOIN tradingplatform.users ON metadata.user_id = users.id;

[User] How many metadata are there per asset_id?

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


[User] Get user_id, buyer_id, updated_at from all metadata.

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

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

[Assistant] SELECT user_id, buyer_id, updated_at FROM tradingplatform.metadata WHERE buyer_id LIKE 'A%';

[User] Show me sum of updated_at grouped by status for metadata.

[Assistant] SELECT status, SUM(updated_at) AS sum_updated_at FROM tradingplatform.metadata GROUP BY status;


[User] Get all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Show the results sorted by created_at descending.

[Assistant] SELECT * FROM tradingplatform.assets ORDER BY created_at DESC;

[User] What is the min subcategory for each subcategory in assets?

[Assistant] SELECT subcategory, MIN(subcategory) AS min_subcategory FROM tradingplatform.assets GROUP BY subcategory;


[User] Show me rating, subcategory, thumbnail_url for all assets.

[Assistant] SELECT rating, subcategory, thumbnail_url FROM tradingplatform.assets;

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

[Assistant] SELECT rating, subcategory, thumbnail_url FROM tradingplatform.assets WHERE name LIKE 'A%';

[User] Show me average of thumbnail_url grouped by user_id for assets.

[Assistant] SELECT user_id, AVERAGE(thumbnail_url) AS average_thumbnail_url FROM tradingplatform.assets GROUP BY user_id;


[User] List all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

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

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

[User] Restrict the output to 100 items.

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


[User] Display all metadata.

[Assistant] SELECT * FROM tradingplatform.metadata;

[User] Get metadata that match account_id LIKE 'A%'.

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

[User] Limit the results to 50 rows.

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


[User] Retrieve thumbnail_url, user_id, subcategory for every asset.

[Assistant] SELECT thumbnail_url, user_id, subcategory FROM tradingplatform.assets;

[User] Sort the results by subcategory descending.

[Assistant] SELECT thumbnail_url, user_id, subcategory FROM tradingplatform.assets ORDER BY subcategory DESC;

[User] Show me count of created_at grouped by name for assets.

[Assistant] SELECT name, COUNT(created_at) AS count_created_at FROM tradingplatform.assets GROUP BY name;


[User] What are the asset_id, payment_id, tax of each metadata?

[Assistant] SELECT asset_id, payment_id, tax FROM tradingplatform.metadata;

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

[Assistant] SELECT asset_id, payment_id, tax FROM tradingplatform.metadata ORDER BY fee DESC;

[User] Tally up metadata by fee.

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


[User] List all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Show the results sorted by user_id ascending.

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

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

[Assistant] SELECT user_id, COUNT(*) AS count FROM tradingplatform.assets GROUP BY user_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 education.students (
  customer_id text PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  gender character varying(128),
  salt char NOT NULL,
  last_name character varying(256) NOT NULL,
  email varchar NOT NULL,
  status character varying(256),
  assignment_id integer -- reference to assignments.transaction_id,
  FOREIGN KEY (assignment_id) REFERENCES assignments(transaction_id)
)

CREATE TABLE education.assignments (
  transaction_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  completed_at timestamp without time zone,
  currency char,
  product_id character varying(64) NOT NULL -- identifier for product,
  seller_id character varying(256) NOT NULL -- identifier for seller,
  payment_status character varying(256)
)

[User] Get all students.

[Assistant] SELECT * FROM education.students;

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

[Assistant] SELECT * FROM education.students WHERE status LIKE 'A%';

[User] Only show the top 5 results.

[Assistant] SELECT * FROM education.students WHERE status LIKE 'A%' LIMIT 5;


[User] Get assignment_id, last_active, email from all students.

[Assistant] SELECT assignment_id, last_active, email FROM education.students;

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

[Assistant] SELECT assignment_id, last_active, email FROM education.students ORDER BY last_name ASC;

[User] Get min of last_name by status from students.

[Assistant] SELECT status, MIN(last_name) AS min_last_name FROM education.students GROUP BY status;


[User] List last_name, assignment_id, status from students.

[Assistant] SELECT last_name, assignment_id, status FROM education.students;

[User] Order the output by gender descending.

[Assistant] SELECT last_name, assignment_id, status FROM education.students ORDER BY gender DESC;

[User] Show the results sorted by status descending.

[Assistant] SELECT last_name, assignment_id, status FROM education.students ORDER BY status DESC;


[User] Get all students.

[Assistant] SELECT * FROM education.students;

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

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

[User] Can you order these by salt descending?

[Assistant] SELECT * FROM education.students WHERE last_active <= CURRENT_DATE - INTERVAL '6 months' ORDER BY salt DESC;


[User] Retrieve all students.

[Assistant] SELECT * FROM education.students;

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

[Assistant] SELECT * FROM education.students WHERE last_active >= CURRENT_DATE - INTERVAL '30 days';

[User] Can you order these by assignment_id descending?

[Assistant] SELECT * FROM education.students WHERE last_active >= CURRENT_DATE - INTERVAL '30 days' ORDER BY assignment_id DESC;


[User] Show me email, salt, status for all students.

[Assistant] SELECT email, salt, status FROM education.students;

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

[Assistant] SELECT email, salt, status FROM education.students ORDER BY salt DESC;

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

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


[User] List all students.

[Assistant] SELECT * FROM education.students;

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

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

[User] Only show the top 25 results.

[Assistant] SELECT * FROM education.students WHERE last_active > '2023-12-01' LIMIT 25;


[User] What are the salt, assignment_id, last_active of each student?

[Assistant] SELECT salt, assignment_id, last_active FROM education.students;

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

[Assistant] SELECT salt, assignment_id, last_active FROM education.students WHERE last_name LIKE 'A%';

[User] Get max of last_active by status from students.

[Assistant] SELECT status, MAX(last_active) AS max_last_active FROM education.students GROUP BY status;


[User] Show me assignment_id, salt, email for all students.

[Assistant] SELECT assignment_id, salt, email FROM education.students;

[User] Can you order these by last_active descending?

[Assistant] SELECT assignment_id, salt, email FROM education.students ORDER BY last_active DESC;

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

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


[User] Show me all students.

[Assistant] SELECT * FROM education.students;

[User] Get students that match assignment_id > 91.

[Assistant] SELECT * FROM education.students WHERE assignment_id > 91;

[User] Sort the results by salt descending.

[Assistant] SELECT * FROM education.students WHERE assignment_id > 91 ORDER BY salt 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.order_items (
  employee_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  last_active date,
  website character varying(256),
  password_hash character varying(64),
  state char NOT NULL,
  account_status character varying(128),
  categorie_id text NOT NULL -- reference to categories.person_id,
  FOREIGN KEY (categorie_id) REFERENCES categories(person_id)
)

CREATE TABLE e-commerce.categories (
  person_id text PRIMARY KEY -- unique identifier,
  joined_at timestamp,
  last_active timestamp without time zone,
  last_name text,
  address character varying(128) NOT NULL,
  display_name character varying(128),
  nationality character varying(64),
  email text
)

[User] Retrieve all order_items.

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

[User] Find order_items from 2023.

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

[User] Show only 15 records.

[Assistant] SELECT * FROM e-commerce.order_items WHERE last_active BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 15;


[User] Get all order_items.

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

[User] Retrieve order_items where website LIKE 'A%'.

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

[User] Show me the count of order_items grouped by password_hash.

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


[User] Show me categorie_id, employee_id, password_hash for all order_items.

[Assistant] SELECT categorie_id, employee_id, password_hash FROM e-commerce.order_items;

[User] Sort the results by account_status ascending.

[Assistant] SELECT categorie_id, employee_id, password_hash FROM e-commerce.order_items ORDER BY account_status ASC;

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

[Assistant] SELECT categorie_id, employee_id, password_hash FROM e-commerce.order_items ORDER BY password_hash ASC;


[User] Show me state, account_status, website for all order_items.

[Assistant] SELECT state, account_status, website FROM e-commerce.order_items;

[User] Get all order_items from 2023.

[Assistant] SELECT state, account_status, website FROM e-commerce.order_items WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Only show the top 50 results.

[Assistant] SELECT state, account_status, website FROM e-commerce.order_items WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' LIMIT 50;


[User] List last_active, website, categorie_id from order_items.

[Assistant] SELECT last_active, website, categorie_id FROM e-commerce.order_items;

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

[Assistant] SELECT last_active, website, categorie_id FROM e-commerce.order_items WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Calculate sum of categorie_id for each created_at in order_items.

[Assistant] SELECT created_at, SUM(categorie_id) AS sum_categorie_id FROM e-commerce.order_items GROUP BY created_at;


[User] Display all order_items.

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

[User] Show me categorie_id, password_hash, nationality, email from order_items and their related categories.

[Assistant] SELECT *, categories.nationality, categories.email FROM e-commerce.order_items JOIN e-commerce.categories ON order_items.categorie_id = categories.person_id;

[User] Tally up order_items by state.

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


[User] Get last_active, state, password_hash from all order_items.

[Assistant] SELECT last_active, state, password_hash FROM e-commerce.order_items;

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

[Assistant] SELECT last_active, state, password_hash FROM e-commerce.order_items WHERE last_active >= CURRENT_DATE - INTERVAL '30 days';

[User] Show the results sorted by last_active ascending.

[Assistant] SELECT last_active, state, password_hash FROM e-commerce.order_items WHERE last_active >= CURRENT_DATE - INTERVAL '30 days' ORDER BY last_active ASC;


[User] List employee_id, website, password_hash from order_items.

[Assistant] SELECT employee_id, website, password_hash FROM e-commerce.order_items;

[User] Show me last_active, employee_id, nationality, display_name from order_items and their related categories.

[Assistant] SELECT employee_id, website, password_hash, categories.nationality, categories.display_name FROM e-commerce.order_items JOIN e-commerce.categories ON order_items.categorie_id = categories.person_id;

[User] Order the output by created_at descending.

[Assistant] SELECT employee_id, website, password_hash, categories.nationality, categories.display_name FROM e-commerce.order_items JOIN e-commerce.categories ON order_items.categorie_id = categories.person_id ORDER BY created_at DESC;


[User] List website, password_hash, employee_id from order_items.

[Assistant] SELECT website, password_hash, employee_id FROM e-commerce.order_items;

[User] List state, categorie_id, last_active, address for each order_item along with their categorie information.

[Assistant] SELECT website, password_hash, employee_id, categories.last_active, categories.address FROM e-commerce.order_items JOIN e-commerce.categories ON order_items.categorie_id = categories.person_id;

[User] Sort the results by password_hash ascending.

[Assistant] SELECT website, password_hash, employee_id, categories.last_active, categories.address FROM e-commerce.order_items JOIN e-commerce.categories ON order_items.categorie_id = categories.person_id ORDER BY password_hash ASC;


[User] Retrieve all order_items.

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

[User] Get all order_items created yesterday.

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

[User] Group order_items by employee_id and show the average of state.

[Assistant] SELECT employee_id, AVERAGE(state) AS average_state FROM e-commerce.order_items GROUP BY employee_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.courses (
  message_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  rating character varying(128),
  image_url character varying(128) NOT NULL,
  parent_id character varying(64) -- identifier for parent,
  text character varying(128),
  keywords character varying(128) NOT NULL
)

CREATE TABLE education.grades (
  id character varying(64) NOT NULL -- unique identifier,
  traded_at timestamp,
  processed_at timestamp,
  card_type char NOT NULL,
  approval_status char NOT NULL,
  amount decimal NOT NULL,
  discount bigint,
  customer_id text,
  payment_status text,
  status character varying(256) NOT NULL
)

CREATE TABLE education.assignments (
  id character varying(64) NOT NULL -- unique identifier,
  edited_at timestamp,
  updated_at timestamp,
  keywords varchar,
  format character varying(256) NOT NULL,
  user_id character varying(128) NOT NULL -- identifier for user,
  subject char,
  reply_to_id char -- identifier for reply_to
)

CREATE TABLE education.students (
  employee_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at timestamp without time zone,
  status text,
  username character varying(128),
  city varchar NOT NULL,
  course_id text NOT NULL -- reference to courses.message_id,
  FOREIGN KEY (course_id) REFERENCES courses(message_id)
)

[User] Retrieve city, course_id, created_at for every student.

[Assistant] SELECT city, course_id, created_at FROM education.students;

[User] Find students created yesterday.

[Assistant] SELECT city, course_id, created_at FROM education.students WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Group students by city and show the min of username.

[Assistant] SELECT city, MIN(username) AS min_username FROM education.students GROUP BY city;


[User] List all students.

[Assistant] SELECT * FROM education.students;

[User] Retrieve updated_at, course_id, created_at, image_url showing the relationship between students and courses.

[Assistant] SELECT *, courses.created_at, courses.image_url FROM education.students JOIN education.courses ON students.course_id = courses.message_id;

[User] Return just 15 rows.

[Assistant] SELECT *, courses.created_at, courses.image_url FROM education.students JOIN education.courses ON students.course_id = courses.message_id LIMIT 15;


[User] Retrieve all students.

[Assistant] SELECT * FROM education.students;

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

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

[User] Only show the top 15 results.

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


[User] Get all students.

[Assistant] SELECT * FROM education.students;

[User] Sort the results by created_at ascending.

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

[User] Show me count of status grouped by course_id for students.

[Assistant] SELECT course_id, COUNT(status) AS count_status FROM education.students GROUP BY course_id;


[User] Retrieve status, course_id, username for every student.

[Assistant] SELECT status, course_id, username FROM education.students;

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

[Assistant] SELECT status, course_id, username FROM education.students WHERE username LIKE 'A%';

[User] Sort the results by created_at descending.

[Assistant] SELECT status, course_id, username FROM education.students WHERE username LIKE 'A%' ORDER BY created_at DESC;


[User] Get all students.

[Assistant] SELECT * FROM education.students;

[User] What created_at, city, parent_id, keywords do we have for students and their associated courses?

[Assistant] SELECT *, courses.parent_id, courses.keywords FROM education.students JOIN education.courses ON students.course_id = courses.message_id;

[User] What is the average username for each status in students?

[Assistant] SELECT status, AVERAGE(username) AS average_username FROM education.students GROUP BY status;


[User] List all students.

[Assistant] SELECT * FROM education.students;

[User] Get students that match username LIKE 'A%'.

[Assistant] SELECT * FROM education.students WHERE username LIKE 'A%';

[User] Tally up students by status.

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


[User] What are the status, city, username of each student?

[Assistant] SELECT status, city, username FROM education.students;

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

[Assistant] SELECT status, city, username FROM education.students WHERE created_at > '2023-12-01';

[User] How many students are there per username?

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


[User] Display all students.

[Assistant] SELECT * FROM education.students;

[User] Can you order these by created_at ascending?

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

[User] Tally up students by status.

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


[User] Show me all students.

[Assistant] SELECT * FROM education.students;

[User] Show the results sorted by course_id descending.

[Assistant] SELECT * FROM education.students ORDER BY course_id DESC;

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

[Assistant] SELECT city, COUNT(*) AS count FROM education.students GROUP BY city 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.departments (
  content_id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at date,
  views character varying(64),
  rating character varying(64),
  shares character varying(128),
  format char,
  thumbnail character varying(256),
  student_id text NOT NULL -- reference to students.employee_id,
  FOREIGN KEY (student_id) REFERENCES students(employee_id)
)

CREATE TABLE education.students (
  employee_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  is_active boolean,
  zip_code character varying(64),
  website text NOT NULL,
  department_id text -- reference to departments.content_id,
  FOREIGN KEY (department_id) REFERENCES departments(content_id)
)

[User] What are the student_id, views, shares of each department?

[Assistant] SELECT student_id, views, shares FROM education.departments;

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

[Assistant] SELECT student_id, views, shares FROM education.departments WHERE updated_at > '2023-12-01';

[User] Restrict the output to 10 items.

[Assistant] SELECT student_id, views, shares FROM education.departments WHERE updated_at > '2023-12-01' LIMIT 10;


[User] Show me zip_code, is_active, website for all students.

[Assistant] SELECT zip_code, is_active, website FROM education.students;

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

[Assistant] SELECT zip_code, is_active, website FROM education.students WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Tally up students by is_active.

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


[User] List zip_code, created_at, department_id from students.

[Assistant] SELECT zip_code, created_at, department_id FROM education.students;

[User] Can you order these by department_id ascending?

[Assistant] SELECT zip_code, created_at, department_id FROM education.students ORDER BY department_id ASC;

[User] Can you order these by zip_code ascending?

[Assistant] SELECT zip_code, created_at, department_id FROM education.students ORDER BY zip_code ASC;


[User] Get thumbnail, created_at, shares from all departments.

[Assistant] SELECT thumbnail, created_at, shares FROM education.departments;

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

[Assistant] SELECT thumbnail, created_at, shares FROM education.departments WHERE student_id LIKE 'A%';

[User] Calculate average of rating for each shares in departments.

[Assistant] SELECT shares, AVERAGE(rating) AS average_rating FROM education.departments GROUP BY shares;


[User] Show me department_id, is_active, created_at for all students.

[Assistant] SELECT department_id, is_active, created_at FROM education.students;

[User] Retrieve department_id, is_active, thumbnail, updated_at showing the relationship between students and departments.

[Assistant] SELECT department_id, is_active, created_at, departments.thumbnail, departments.updated_at FROM education.students JOIN education.departments ON students.department_id = departments.content_id;

[User] Calculate count of created_at for each website in students.

[Assistant] SELECT website, COUNT(created_at) AS count_created_at FROM education.students GROUP BY website;


[User] Retrieve created_at, rating, views for every department.

[Assistant] SELECT created_at, rating, views FROM education.departments;

[User] What format, shares, website, department_id do we have for departments and their associated students?

[Assistant] SELECT created_at, rating, views, students.website, students.department_id FROM education.departments JOIN education.students ON departments.student_id = students.employee_id;

[User] Return just 5 rows.

[Assistant] SELECT created_at, rating, views, students.website, students.department_id FROM education.departments JOIN education.students ON departments.student_id = students.employee_id LIMIT 5;


[User] Retrieve all departments.

[Assistant] SELECT * FROM education.departments;

[User] Show me departments that were from 2023.

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

[User] Order the output by shares descending.

[Assistant] SELECT * FROM education.departments WHERE updated_at BETWEEN '2023-01-01' AND '2023-12-31' ORDER BY shares DESC;


[User] Show me format, student_id, rating for all departments.

[Assistant] SELECT format, student_id, rating FROM education.departments;

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

[Assistant] SELECT format, student_id, rating FROM education.departments WHERE shares LIKE 'A%';

[User] Limit the results to 100 rows.

[Assistant] SELECT format, student_id, rating FROM education.departments WHERE shares LIKE 'A%' LIMIT 100;


[User] List zip_code, created_at, website from students.

[Assistant] SELECT zip_code, created_at, website FROM education.students;

[User] Find students from last week.

[Assistant] SELECT zip_code, created_at, website FROM education.students WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Order the output by website descending.

[Assistant] SELECT zip_code, created_at, website FROM education.students WHERE created_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY website DESC;


[User] Show me format, views, student_id for all departments.

[Assistant] SELECT format, views, student_id FROM education.departments;

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

[Assistant] SELECT format, views, student_id FROM education.departments WHERE updated_at > '2023-12-01';

[User] Calculate sum of student_id for each student_id in departments.

[Assistant] SELECT student_id, SUM(student_id) AS sum_student_id FROM education.departments GROUP BY student_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.doctors (
  venue_id text PRIMARY KEY -- unique identifier,
  created_at date,
  last_inspected timestamp without time zone,
  street character varying(128),
  country character varying(128) NOT NULL,
  type text,
  capacity text,
  billin_id integer NOT NULL -- reference to billing.invoice_id,
  appointment_id text -- reference to appointments.customer_id,
  FOREIGN KEY (billin_id) REFERENCES billing(invoice_id),
  FOREIGN KEY (appointment_id) REFERENCES appointments(customer_id)
)

CREATE TABLE healthcare.billing (
  invoice_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  due_date timestamp,
  notes char,
  exchange_rate character varying(256),
  reference_number varchar,
  balance bigint,
  customer_id character varying(128) -- identifier for customer,
  appointment_id text NOT NULL -- reference to appointments.customer_id,
  patient_id text NOT NULL -- reference to patients.id,
  FOREIGN KEY (appointment_id) REFERENCES appointments(customer_id),
  FOREIGN KEY (patient_id) REFERENCES patients(id)
)

CREATE TABLE healthcare.appointments (
  customer_id varchar PRIMARY KEY -- unique identifier,
  last_active timestamp,
  created_at timestamp without time zone,
  last_login timestamp,
  age text,
  status character varying(256) NOT NULL
)

CREATE TABLE healthcare.patients (
  id text PRIMARY KEY -- unique identifier,
  joined_at date,
  status varchar,
  last_login date NOT NULL,
  salt text,
  api_key char,
  first_name character varying(64) NOT NULL
)

[User] List all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Retrieve billing where reference_number LIKE 'A%'.

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

[User] Show only 50 records.

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