[User] List all accounts.

[Assistant] SELECT * FROM finance.accounts;

[User] List payer_id, payment_id, discount, traded_at for each account along with their transaction information.

[Assistant] SELECT *, transactions.discount, transactions.traded_at FROM finance.accounts JOIN finance.transactions ON accounts.transaction_id = transactions.order_id;

[User] Limit the results to 20 rows.

[Assistant] SELECT *, transactions.discount, transactions.traded_at FROM finance.accounts JOIN finance.transactions ON accounts.transaction_id = transactions.order_id LIMIT 20;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.reviews (
  post_id integer PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  media_url character varying(128),
  likes text NOT NULL,
  user_id character varying(128) -- identifier for user,
  reply_to_id character varying(256) NOT NULL -- identifier for reply_to
)

CREATE TABLE e-commerce.products (
  id character varying(64) NOT NULL -- unique identifier,
  expires_at date,
  created_at timestamp,
  media_url varchar,
  available character varying(64) NOT NULL,
  msrp character varying(128)
)

CREATE TABLE e-commerce.users (
  id character varying(64) NOT NULL -- unique identifier,
  joined_at timestamp,
  first_name varchar,
  salt character varying(256),
  address character varying(256) NOT NULL,
  token text
)

CREATE TABLE e-commerce.inventory (
  item_id character varying(64) NOT NULL -- unique identifier,
  published_at date,
  updated_at date,
  msrp character varying(256),
  available varchar,
  price bigint,
  subcategory text,
  backorder character varying(256)
)

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

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

[User] Show me inventory that were created yesterday.

[Assistant] SELECT msrp, updated_at, available FROM e-commerce.inventory WHERE updated_at = CURRENT_DATE - INTERVAL '1 day';

[User] Tally up inventory by available.

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


[User] List id, available, msrp from products.

[Assistant] SELECT id, available, msrp FROM e-commerce.products;

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

[Assistant] SELECT id, available, msrp FROM e-commerce.products WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Count the number of products in each expires_at category.

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


[User] Retrieve all reviews.

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

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

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

[User] Order the output by reply_to_id descending.

[Assistant] SELECT * FROM e-commerce.reviews WHERE edited_at > '2023-01-01' ORDER BY reply_to_id DESC;


[User] List available, created_at, expires_at from products.

[Assistant] SELECT available, created_at, expires_at FROM e-commerce.products;

[User] Get all products from 2023.

[Assistant] SELECT available, created_at, expires_at FROM e-commerce.products WHERE expires_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Group products by msrp and show the max of created_at.

[Assistant] SELECT msrp, MAX(created_at) AS max_created_at FROM e-commerce.products GROUP BY msrp;


[User] Show me expires_at, media_url, id for all products.

[Assistant] SELECT expires_at, media_url, id FROM e-commerce.products;

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

[Assistant] SELECT expires_at, media_url, id FROM e-commerce.products WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Return just 5 rows.

[Assistant] SELECT expires_at, media_url, id FROM e-commerce.products WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 5;


[User] What are the backorder, item_id, msrp of each inventory?

[Assistant] SELECT backorder, item_id, msrp FROM e-commerce.inventory;

[User] Show the results sorted by updated_at ascending.

[Assistant] SELECT backorder, item_id, msrp FROM e-commerce.inventory ORDER BY updated_at ASC;

[User] Can you order these by price ascending?

[Assistant] SELECT backorder, item_id, msrp FROM e-commerce.inventory ORDER BY price ASC;


[User] Show me available, published_at, updated_at for all inventory.

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

[User] Show me inventory with subcategory LIKE 'A%'.

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

[User] What is the count available for each msrp in inventory?

[Assistant] SELECT msrp, COUNT(available) AS count_available FROM e-commerce.inventory GROUP BY msrp;


[User] Show me reply_to_id, user_id, edited_at for all reviews.

[Assistant] SELECT reply_to_id, user_id, edited_at FROM e-commerce.reviews;

[User] Sort the results by edited_at ascending.

[Assistant] SELECT reply_to_id, user_id, edited_at FROM e-commerce.reviews ORDER BY edited_at ASC;

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

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


[User] List likes, reply_to_id, media_url from reviews.

[Assistant] SELECT likes, reply_to_id, media_url FROM e-commerce.reviews;

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

[Assistant] SELECT likes, reply_to_id, media_url FROM e-commerce.reviews WHERE edited_at > '2023-01-01';

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

[Assistant] SELECT likes, reply_to_id, media_url FROM e-commerce.reviews WHERE edited_at > '2023-01-01' ORDER BY reply_to_id DESC;


[User] List all products.

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

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

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

[User] Show the results sorted by available descending.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.patients (
  customer_id integer PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  status character varying(128),
  account_status character varying(256),
  gender character varying(256) NOT NULL,
  api_key char,
  first_name character varying(256),
  billin_id integer -- reference to billing.user_id,
  FOREIGN KEY (billin_id) REFERENCES billing(user_id)
)

CREATE TABLE healthcare.billing (
  user_id integer PRIMARY KEY -- unique identifier,
  joined_at timestamp,
  updated_at date,
  email character varying(256) NOT NULL,
  status text NOT NULL,
  token character varying(64),
  city character varying(128) NOT NULL,
  patient_id integer NOT NULL -- reference to patients.customer_id,
  FOREIGN KEY (patient_id) REFERENCES patients(customer_id)
)

[User] Retrieve all billing.

[Assistant] SELECT * FROM healthcare.billing;

[User] Sort the results by status descending.

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

[User] Show the results sorted by token descending.

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


[User] Show me city, updated_at, token for all billing.

[Assistant] SELECT city, updated_at, token FROM healthcare.billing;

[User] Order the output by joined_at descending.

[Assistant] SELECT city, updated_at, token FROM healthcare.billing ORDER BY joined_at DESC;

[User] Restrict the output to 25 items.

[Assistant] SELECT city, updated_at, token FROM healthcare.billing ORDER BY joined_at DESC LIMIT 25;


[User] Retrieve all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Retrieve account_status, first_name, email, patient_id showing the relationship between patients and billing.

[Assistant] SELECT *, billing.email, billing.patient_id FROM healthcare.patients JOIN healthcare.billing ON patients.billin_id = billing.user_id;

[User] Calculate count of gender for each first_name in patients.

[Assistant] SELECT first_name, COUNT(gender) AS count_gender FROM healthcare.patients GROUP BY first_name;


[User] Retrieve gender, billin_id, last_active for every patient.

[Assistant] SELECT gender, billin_id, last_active FROM healthcare.patients;

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

[Assistant] SELECT gender, billin_id, last_active FROM healthcare.patients WHERE last_active > '2023-12-01';

[User] Order the output by gender ascending.

[Assistant] SELECT gender, billin_id, last_active FROM healthcare.patients WHERE last_active > '2023-12-01' ORDER BY gender ASC;


[User] List api_key, status, first_name from patients.

[Assistant] SELECT api_key, status, first_name FROM healthcare.patients;

[User] Can you order these by first_name ascending?

[Assistant] SELECT api_key, status, first_name FROM healthcare.patients ORDER BY first_name ASC;

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

[Assistant] SELECT api_key, status, first_name FROM healthcare.patients ORDER BY last_active DESC;


[User] List all patients.

[Assistant] SELECT * FROM healthcare.patients;

[User] Show me status, account_status, joined_at, token from patients and their related billing.

[Assistant] SELECT *, billing.joined_at, billing.token FROM healthcare.patients JOIN healthcare.billing ON patients.billin_id = billing.user_id;

[User] Calculate average of billin_id for each gender in patients.

[Assistant] SELECT gender, AVERAGE(billin_id) AS average_billin_id FROM healthcare.patients GROUP BY gender;


[User] Show me api_key, status, gender for all patients.

[Assistant] SELECT api_key, status, gender FROM healthcare.patients;

[User] Retrieve first_name, billin_id, token, patient_id showing the relationship between patients and billing.

[Assistant] SELECT api_key, status, gender, billing.token, billing.patient_id FROM healthcare.patients JOIN healthcare.billing ON patients.billin_id = billing.user_id;

[User] Count the number of patients in each first_name category.

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


[User] What are the last_active, first_name, gender of each patient?

[Assistant] SELECT last_active, first_name, gender FROM healthcare.patients;

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

[Assistant] SELECT last_active, first_name, gender FROM healthcare.patients WHERE last_active >= CURRENT_DATE - INTERVAL '7 days';

[User] Only show the top 15 results.

[Assistant] SELECT last_active, first_name, gender FROM healthcare.patients WHERE last_active >= CURRENT_DATE - INTERVAL '7 days' LIMIT 15;


[User] Retrieve status, last_active, api_key for every patient.

[Assistant] SELECT status, last_active, api_key FROM healthcare.patients;

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

[Assistant] SELECT status, last_active, api_key FROM healthcare.patients WHERE gender LIKE 'A%';

[User] Can you order these by account_status descending?

[Assistant] SELECT status, last_active, api_key FROM healthcare.patients WHERE gender LIKE 'A%' ORDER BY account_status DESC;


[User] Retrieve gender, first_name, api_key for every patient.

[Assistant] SELECT gender, first_name, api_key FROM healthcare.patients;

[User] Get patients that match gender LIKE 'A%'.

[Assistant] SELECT gender, first_name, api_key FROM healthcare.patients WHERE gender LIKE 'A%';

[User] Tally up patients by gender.

[Assistant] SELECT gender, COUNT(*) AS count FROM healthcare.patients GROUP BY gender 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.posts (
  id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  parent_id character varying(256),
  likes character varying(128),
  media_url character varying(128),
  like_id integer NOT NULL -- reference to likes.account_id,
  FOREIGN KEY (like_id) REFERENCES likes(account_id)
)

CREATE TABLE socialmedia.likes (
  account_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  reference_number character varying(64) NOT NULL,
  payee_id varchar NOT NULL,
  user_id character varying(64),
  category varchar NOT NULL,
  balance bigint
)

CREATE TABLE socialmedia.events (
  product_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  published_at date,
  popularity_score character varying(256) NOT NULL,
  name character varying(256),
  backorder character varying(256),
  featured_rank character varying(256)
)

CREATE TABLE socialmedia.comments (
  id integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  text text NOT NULL,
  content varchar,
  thumbnail char,
  author_id character varying(128) NOT NULL -- identifier for author,
  post_id integer -- reference to posts.id,
  FOREIGN KEY (post_id) REFERENCES posts(id)
)

[User] Show me parent_id, updated_at, likes for all posts.

[Assistant] SELECT parent_id, updated_at, likes FROM socialmedia.posts;

[User] Can you order these by like_id descending?

[Assistant] SELECT parent_id, updated_at, likes FROM socialmedia.posts ORDER BY like_id DESC;

[User] Calculate min of parent_id for each like_id in posts.

[Assistant] SELECT like_id, MIN(parent_id) AS min_parent_id FROM socialmedia.posts GROUP BY like_id;


[User] Get post_id, created_at, author_id from all comments.

[Assistant] SELECT post_id, created_at, author_id FROM socialmedia.comments;

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

[Assistant] SELECT post_id, created_at, author_id FROM socialmedia.comments ORDER BY thumbnail DESC;

[User] Show the results sorted by thumbnail descending.

[Assistant] SELECT post_id, created_at, author_id FROM socialmedia.comments ORDER BY thumbnail DESC;


[User] Get all posts.

[Assistant] SELECT * FROM socialmedia.posts;

[User] Sort the results by updated_at descending.

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

[User] Show me count of likes grouped by likes for posts.

[Assistant] SELECT likes, COUNT(likes) AS count_likes FROM socialmedia.posts GROUP BY likes;


[User] Get like_id, parent_id, updated_at from all posts.

[Assistant] SELECT like_id, parent_id, updated_at FROM socialmedia.posts;

[User] Can you order these by parent_id ascending?

[Assistant] SELECT like_id, parent_id, updated_at FROM socialmedia.posts ORDER BY parent_id ASC;

[User] Calculate sum of like_id for each likes in posts.

[Assistant] SELECT likes, SUM(like_id) AS sum_like_id FROM socialmedia.posts GROUP BY likes;


[User] Get all comments.

[Assistant] SELECT * FROM socialmedia.comments;

[User] What content, created_at, updated_at, likes do we have for comments and their associated posts?

[Assistant] SELECT *, posts.updated_at, posts.likes FROM socialmedia.comments JOIN socialmedia.posts ON comments.post_id = posts.id;

[User] Tally up comments by created_at.

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


[User] Show me thumbnail, author_id, text for all comments.

[Assistant] SELECT thumbnail, author_id, text FROM socialmedia.comments;

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

[Assistant] SELECT thumbnail, author_id, text FROM socialmedia.comments WHERE created_at <= CURRENT_DATE - INTERVAL '6 months';

[User] Show the results sorted by created_at ascending.

[Assistant] SELECT thumbnail, author_id, text FROM socialmedia.comments WHERE created_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY created_at ASC;


[User] Get all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

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

[User] Calculate min of thumbnail for each text in comments.

[Assistant] SELECT text, MIN(thumbnail) AS min_thumbnail FROM socialmedia.comments GROUP BY text;


[User] Display all comments.

[Assistant] SELECT * FROM socialmedia.comments;

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

[Assistant] SELECT * FROM socialmedia.comments WHERE created_at > '2023-01-01';

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

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


[User] List media_url, parent_id, likes from posts.

[Assistant] SELECT media_url, parent_id, likes FROM socialmedia.posts;

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

[Assistant] SELECT media_url, parent_id, likes FROM socialmedia.posts ORDER BY media_url DESC;

[User] Show me count of media_url grouped by media_url for posts.

[Assistant] SELECT media_url, COUNT(media_url) AS count_media_url FROM socialmedia.posts GROUP BY media_url;


[User] Show me content, thumbnail, post_id for all comments.

[Assistant] SELECT content, thumbnail, post_id FROM socialmedia.comments;

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

[Assistant] SELECT content, thumbnail, post_id FROM socialmedia.comments WHERE created_at > '2023-01-01';

[User] Restrict the output to 15 items.

[Assistant] SELECT content, thumbnail, post_id FROM socialmedia.comments WHERE created_at > '2023-01-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 socialmedia.followers (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp,
  total numeric NOT NULL,
  payment_method text,
  quantity character varying(256),
  exchange_rate varchar NOT NULL,
  amount numeric,
  customer_id char NOT NULL -- identifier for customer
)

CREATE TABLE socialmedia.users (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp,
  created_at date,
  last_name character varying(256),
  is_active bit,
  website text,
  gender character varying(128),
  api_key varchar NOT NULL
)

CREATE TABLE socialmedia.posts (
  id character varying(64) NOT NULL -- unique identifier,
  updated_at date,
  format char,
  thumbnail character varying(128) NOT NULL,
  image_url character varying(128) NOT NULL,
  score character varying(128),
  author_id character varying(128),
  parent_id char NOT NULL
)

[User] List all users.

[Assistant] SELECT * FROM socialmedia.users;

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

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

[User] Calculate count of gender for each is_active in users.

[Assistant] SELECT is_active, COUNT(gender) AS count_gender FROM socialmedia.users GROUP BY is_active;


[User] List score, updated_at, parent_id from posts.

[Assistant] SELECT score, updated_at, parent_id FROM socialmedia.posts;

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

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

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

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


[User] Display all users.

[Assistant] SELECT * FROM socialmedia.users;

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

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

[User] Calculate sum of last_name for each is_active in users.

[Assistant] SELECT is_active, SUM(last_name) AS sum_last_name FROM socialmedia.users GROUP BY is_active;


[User] Retrieve all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

[User] Group followers by total and show the min of payment_method.

[Assistant] SELECT total, MIN(payment_method) AS min_payment_method FROM socialmedia.followers GROUP BY total;


[User] Show me all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Show me users with is_active = TRUE.

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

[User] Sort the results by is_active ascending.

[Assistant] SELECT * FROM socialmedia.users WHERE is_active = TRUE ORDER BY is_active ASC;


[User] What are the gender, website, is_active of each user?

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

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

[Assistant] SELECT gender, website, is_active FROM socialmedia.users WHERE id LIKE 'A%';

[User] Return just 15 rows.

[Assistant] SELECT gender, website, is_active FROM socialmedia.users WHERE id LIKE 'A%' LIMIT 15;


[User] Display all posts.

[Assistant] SELECT * FROM socialmedia.posts;

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

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

[User] Get count of thumbnail by author_id from posts.

[Assistant] SELECT author_id, COUNT(thumbnail) AS count_thumbnail FROM socialmedia.posts GROUP BY author_id;


[User] Retrieve all posts.

[Assistant] SELECT * FROM socialmedia.posts;

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

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

[User] Can you order these by image_url ascending?

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


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

[User] Sort the results by total descending.

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

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

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


[User] Show me all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Show the results sorted by created_at descending.

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

[User] Sort the results by updated_at ascending.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE government.addresses (
  venue_id varchar PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  location_lon char NOT NULL,
  address_line2 character varying(128) NOT NULL,
  latitude character varying(128)
)

CREATE TABLE government.items (
  sku character varying(64) NOT NULL -- unique identifier,
  published_at timestamp without time zone,
  category character varying(128),
  available varchar NOT NULL,
  description character varying(128),
  addresse_id text NOT NULL -- reference to addresses.venue_id,
  FOREIGN KEY (addresse_id) REFERENCES addresses(venue_id)
)

[User] Show me all items.

[Assistant] SELECT * FROM government.items;

[User] Get all items created yesterday.

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

[User] Show only 100 records.

[Assistant] SELECT * FROM government.items WHERE published_at = CURRENT_DATE - INTERVAL '1 day' LIMIT 100;


[User] What are the published_at, available, sku of each item?

[Assistant] SELECT published_at, available, sku FROM government.items;

[User] Order the output by available ascending.

[Assistant] SELECT published_at, available, sku FROM government.items ORDER BY available ASC;

[User] Sort the results by category ascending.

[Assistant] SELECT published_at, available, sku FROM government.items ORDER BY category ASC;


[User] Show me all items.

[Assistant] SELECT * FROM government.items;

[User] Show me category, sku, address_line2, created_at from items and their related addresses.

[Assistant] SELECT *, addresses.address_line2, addresses.created_at FROM government.items JOIN government.addresses ON items.addresse_id = addresses.venue_id;

[User] Tally up items by category.

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


[User] Retrieve all items.

[Assistant] SELECT * FROM government.items;

[User] Show me items with description LIKE 'A%'.

[Assistant] SELECT * FROM government.items WHERE description LIKE 'A%';

[User] Return just 20 rows.

[Assistant] SELECT * FROM government.items WHERE description LIKE 'A%' LIMIT 20;


[User] Get all items.

[Assistant] SELECT * FROM government.items;

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

[Assistant] SELECT * FROM government.items ORDER BY description ASC;

[User] Show me min of available grouped by published_at for items.

[Assistant] SELECT published_at, MIN(available) AS min_available FROM government.items GROUP BY published_at;


[User] Get all items.

[Assistant] SELECT * FROM government.items;

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

[Assistant] SELECT * FROM government.items WHERE published_at > '2023-01-01';

[User] Only show the top 20 results.

[Assistant] SELECT * FROM government.items WHERE published_at > '2023-01-01' LIMIT 20;


[User] List available, category, sku from items.

[Assistant] SELECT available, category, sku FROM government.items;

[User] Get sku, available, latitude, created_at by joining items with addresses.

[Assistant] SELECT available, category, sku, addresses.latitude, addresses.created_at FROM government.items JOIN government.addresses ON items.addresse_id = addresses.venue_id;

[User] Get sum of category by description from items.

[Assistant] SELECT description, SUM(category) AS sum_category FROM government.items GROUP BY description;


[User] Display all items.

[Assistant] SELECT * FROM government.items;

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

[Assistant] SELECT * FROM government.items WHERE addresse_id LIKE 'A%';

[User] Return just 25 rows.

[Assistant] SELECT * FROM government.items WHERE addresse_id LIKE 'A%' LIMIT 25;


[User] Show me available, sku, category for all items.

[Assistant] SELECT available, sku, category FROM government.items;

[User] Show me available, sku, latitude, address_line2 from items and their related addresses.

[Assistant] SELECT available, sku, category, addresses.latitude, addresses.address_line2 FROM government.items JOIN government.addresses ON items.addresse_id = addresses.venue_id;

[User] Can you order these by published_at descending?

[Assistant] SELECT available, sku, category, addresses.latitude, addresses.address_line2 FROM government.items JOIN government.addresses ON items.addresse_id = addresses.venue_id ORDER BY published_at DESC;


[User] Display all items.

[Assistant] SELECT * FROM government.items;

[User] Show me items with description LIKE 'A%'.

[Assistant] SELECT * FROM government.items WHERE description LIKE 'A%';

[User] Can you order these by category ascending?

[Assistant] SELECT * FROM government.items WHERE description LIKE 'A%' ORDER BY category 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 (
  post_id character varying(64) NOT NULL -- unique identifier,
  edited_at timestamp without time zone,
  image_url character varying(256) NOT NULL,
  description character varying(64) NOT NULL,
  author_id varchar,
  media_url char,
  score char,
  follower_id integer NOT NULL -- reference to followers.person_id,
  FOREIGN KEY (follower_id) REFERENCES followers(person_id)
)

CREATE TABLE socialmedia.groups (
  store_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  parking_available varchar,
  timezone text,
  location_lon character varying(128),
  accessibility character varying(64) NOT NULL
)

CREATE TABLE socialmedia.followers (
  person_id integer PRIMARY KEY -- unique identifier,
  last_active timestamp without time zone,
  birth_date timestamp NOT NULL,
  last_login timestamp without time zone,
  nationality varchar,
  language character varying(256),
  full_name char,
  salt character varying(64),
  password_hash character varying(64),
  group_id text NOT NULL -- reference to groups.store_id,
  FOREIGN KEY (group_id) REFERENCES groups(store_id)
)

[User] List all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] List messages that have edited_at > '2023-01-01'.

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

[User] Get sum of edited_at by edited_at from messages.

[Assistant] SELECT edited_at, SUM(edited_at) AS sum_edited_at FROM socialmedia.messages GROUP BY edited_at;


[User] What are the author_id, image_url, edited_at of each message?

[Assistant] SELECT author_id, image_url, edited_at FROM socialmedia.messages;

[User] Find messages older than 6 months.

[Assistant] SELECT author_id, image_url, edited_at FROM socialmedia.messages WHERE edited_at <= CURRENT_DATE - INTERVAL '6 months';

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

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


[User] Show me all messages.

[Assistant] SELECT * FROM socialmedia.messages;

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

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

[User] Limit the results to 15 rows.

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


[User] Show me all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] List messages with dates created yesterday.

[Assistant] SELECT * FROM socialmedia.messages WHERE edited_at = CURRENT_DATE - INTERVAL '1 day';

[User] What is the sum follower_id for each score in messages?

[Assistant] SELECT score, SUM(follower_id) AS sum_follower_id FROM socialmedia.messages GROUP BY score;


[User] Show me all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] List score, media_url, language, salt for each message along with their follower information.

[Assistant] SELECT *, followers.language, followers.salt FROM socialmedia.messages JOIN socialmedia.followers ON messages.follower_id = followers.person_id;

[User] Calculate min of author_id for each image_url in messages.

[Assistant] SELECT image_url, MIN(author_id) AS min_author_id FROM socialmedia.messages GROUP BY image_url;


[User] List post_id, edited_at, follower_id from messages.

[Assistant] SELECT post_id, edited_at, follower_id FROM socialmedia.messages;

[User] What follower_id, author_id, language, birth_date do we have for messages and their associated followers?

[Assistant] SELECT post_id, edited_at, follower_id, followers.language, followers.birth_date FROM socialmedia.messages JOIN socialmedia.followers ON messages.follower_id = followers.person_id;

[User] Show the results sorted by edited_at ascending.

[Assistant] SELECT post_id, edited_at, follower_id, followers.language, followers.birth_date FROM socialmedia.messages JOIN socialmedia.followers ON messages.follower_id = followers.person_id ORDER BY edited_at ASC;


[User] Show me all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

[Assistant] SELECT * FROM socialmedia.followers WHERE birth_date = CURRENT_DATE - INTERVAL '1 day';

[User] Can you order these by group_id ascending?

[Assistant] SELECT * FROM socialmedia.followers WHERE birth_date = CURRENT_DATE - INTERVAL '1 day' ORDER BY group_id ASC;


[User] Retrieve last_login, group_id, salt for every follower.

[Assistant] SELECT last_login, group_id, salt FROM socialmedia.followers;

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

[Assistant] SELECT last_login, group_id, salt FROM socialmedia.followers ORDER BY nationality DESC;

[User] Show only 5 records.

[Assistant] SELECT last_login, group_id, salt FROM socialmedia.followers ORDER BY nationality DESC LIMIT 5;


[User] List all followers.

[Assistant] SELECT * FROM socialmedia.followers;

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

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

[User] Group followers by password_hash and show the min of last_login.

[Assistant] SELECT password_hash, MIN(last_login) AS min_last_login FROM socialmedia.followers GROUP BY password_hash;


[User] List language, full_name, last_login from followers.

[Assistant] SELECT language, full_name, last_login FROM socialmedia.followers;

[User] Can you order these by birth_date ascending?

[Assistant] SELECT language, full_name, last_login FROM socialmedia.followers ORDER BY birth_date ASC;

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

[Assistant] SELECT language, full_name, last_login FROM socialmedia.followers ORDER BY language DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.grades (
  post_id varchar PRIMARY KEY -- unique identifier,
  edited_at date,
  image_url character varying(64) NOT NULL,
  author_id character varying(128) NOT NULL,
  likes character varying(256) NOT NULL,
  title character varying(64),
  teacher_id text -- reference to teachers.post_id,
  FOREIGN KEY (teacher_id) REFERENCES teachers(post_id)
)

CREATE TABLE education.teachers (
  post_id text PRIMARY KEY -- unique identifier,
  published_at date,
  updated_at date,
  rating character varying(128),
  reply_to_id char -- identifier for reply_to,
  author_id character varying(256),
  grade_id text NOT NULL -- reference to grades.post_id,
  FOREIGN KEY (grade_id) REFERENCES grades(post_id)
)

CREATE TABLE education.assignments (
  id varchar PRIMARY KEY -- unique identifier,
  processed_at date,
  user_id char -- identifier for user,
  verification_status text NOT NULL,
  reference_number character varying(256),
  payee_id character varying(256) NOT NULL,
  grade_id text NOT NULL -- reference to grades.post_id,
  FOREIGN KEY (grade_id) REFERENCES grades(post_id)
)

[User] Get image_url, author_id, title from all grades.

[Assistant] SELECT image_url, author_id, title FROM education.grades;

[User] Order the output by teacher_id descending.

[Assistant] SELECT image_url, author_id, title FROM education.grades ORDER BY teacher_id DESC;

[User] Show me the count of grades grouped by title.

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


[User] Get all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] What payee_id, reference_number, image_url, author_id do we have for assignments and their associated grades?

[Assistant] SELECT *, grades.image_url, grades.author_id FROM education.assignments JOIN education.grades ON assignments.grade_id = grades.post_id;

[User] Show only 50 records.

[Assistant] SELECT *, grades.image_url, grades.author_id FROM education.assignments JOIN education.grades ON assignments.grade_id = grades.post_id LIMIT 50;


[User] Show me grade_id, rating, published_at for all teachers.

[Assistant] SELECT grade_id, rating, published_at FROM education.teachers;

[User] Can you order these by updated_at descending?

[Assistant] SELECT grade_id, rating, published_at FROM education.teachers ORDER BY updated_at DESC;

[User] How many teachers are there per grade_id?

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


[User] Retrieve reply_to_id, author_id, updated_at for every teacher.

[Assistant] SELECT reply_to_id, author_id, updated_at FROM education.teachers;

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

[Assistant] SELECT reply_to_id, author_id, updated_at FROM education.teachers WHERE published_at > '2023-12-01';

[User] Tally up teachers by published_at.

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


[User] Display all grades.

[Assistant] SELECT * FROM education.grades;

[User] Retrieve grades where teacher_id LIKE 'A%'.

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

[User] Show the results sorted by likes descending.

[Assistant] SELECT * FROM education.grades WHERE teacher_id LIKE 'A%' ORDER BY likes DESC;


[User] Get all assignments.

[Assistant] SELECT * FROM education.assignments;

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

[Assistant] SELECT * FROM education.assignments WHERE user_id LIKE 'A%';

[User] Order the output by user_id ascending.

[Assistant] SELECT * FROM education.assignments WHERE user_id LIKE 'A%' ORDER BY user_id ASC;


[User] Show me all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] Find teachers where author_id LIKE 'A%'.

[Assistant] SELECT * FROM education.teachers WHERE author_id LIKE 'A%';

[User] Get count of rating by author_id from teachers.

[Assistant] SELECT author_id, COUNT(rating) AS count_rating FROM education.teachers GROUP BY author_id;


[User] Retrieve reply_to_id, rating, updated_at for every teacher.

[Assistant] SELECT reply_to_id, rating, updated_at FROM education.teachers;

[User] Retrieve published_at, updated_at, edited_at, title showing the relationship between teachers and grades.

[Assistant] SELECT reply_to_id, rating, updated_at, grades.edited_at, grades.title FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.post_id;

[User] Return just 10 rows.

[Assistant] SELECT reply_to_id, rating, updated_at, grades.edited_at, grades.title FROM education.teachers JOIN education.grades ON teachers.grade_id = grades.post_id LIMIT 10;


[User] Retrieve all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] Show the results sorted by reply_to_id descending.

[Assistant] SELECT * FROM education.teachers ORDER BY reply_to_id DESC;

[User] Sort the results by published_at descending.

[Assistant] SELECT * FROM education.teachers ORDER BY published_at DESC;


[User] Retrieve all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

[User] Sort the results by author_id descending.

[Assistant] SELECT * FROM education.teachers WHERE published_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY author_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 music.clients (
  person_id text PRIMARY KEY -- unique identifier,
  created_at timestamp without time zone,
  email character varying(64),
  last_login timestamp without time zone,
  age character varying(256),
  salt character varying(256) NOT NULL,
  display_name varchar,
  venue_id text NOT NULL -- reference to venues.store_id,
  FOREIGN KEY (venue_id) REFERENCES venues(store_id)
)

CREATE TABLE music.venues (
  store_id text PRIMARY KEY -- unique identifier,
  created_at date,
  last_inspected timestamp,
  description character varying(64) NOT NULL,
  coordinates character varying(128),
  longitude varchar NOT NULL,
  payment_id integer NOT NULL -- reference to payments.payment_id,
  FOREIGN KEY (payment_id) REFERENCES payments(payment_id)
)

CREATE TABLE music.payments (
  payment_id integer PRIMARY KEY -- unique identifier,
  processed_at timestamp without time zone,
  created_at date,
  balance numeric(38,14),
  reference_number character varying(64),
  user_id character varying(256) NOT NULL,
  verification_status char NOT NULL,
  invoice_number text,
  venue_id text NOT NULL -- reference to venues.store_id,
  FOREIGN KEY (venue_id) REFERENCES venues(store_id)
)

[User] What are the last_login, venue_id, salt of each client?

[Assistant] SELECT last_login, venue_id, salt FROM music.clients;

[User] List salt, last_login, last_inspected, created_at for each client along with their venue information.

[Assistant] SELECT last_login, venue_id, salt, venues.last_inspected, venues.created_at FROM music.clients JOIN music.venues ON clients.venue_id = venues.store_id;

[User] Group clients by last_login and show the max of email.

[Assistant] SELECT last_login, MAX(email) AS max_email FROM music.clients GROUP BY last_login;


[User] Show me reference_number, balance, created_at for all payments.

[Assistant] SELECT reference_number, balance, created_at FROM music.payments;

[User] Show the results sorted by invoice_number descending.

[Assistant] SELECT reference_number, balance, created_at FROM music.payments ORDER BY invoice_number DESC;

[User] Return just 20 rows.

[Assistant] SELECT reference_number, balance, created_at FROM music.payments ORDER BY invoice_number DESC LIMIT 20;


[User] List all venues.

[Assistant] SELECT * FROM music.venues;

[User] List venues that have last_inspected > '2023-01-01'.

[Assistant] SELECT * FROM music.venues WHERE last_inspected > '2023-01-01';

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

[Assistant] SELECT * FROM music.venues WHERE last_inspected > '2023-01-01' ORDER BY created_at ASC;


[User] Retrieve payment_id, created_at, coordinates for every venue.

[Assistant] SELECT payment_id, created_at, coordinates FROM music.venues;

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

[Assistant] SELECT payment_id, created_at, coordinates FROM music.venues WHERE last_inspected <= CURRENT_DATE - INTERVAL '6 months';

[User] Group venues by coordinates and show the average of created_at.

[Assistant] SELECT coordinates, AVERAGE(created_at) AS average_created_at FROM music.venues GROUP BY coordinates;


[User] Get created_at, display_name, email from all clients.

[Assistant] SELECT created_at, display_name, email FROM music.clients;

[User] Retrieve venue_id, created_at, created_at, longitude showing the relationship between clients and venues.

[Assistant] SELECT created_at, display_name, email, venues.created_at, venues.longitude FROM music.clients JOIN music.venues ON clients.venue_id = venues.store_id;

[User] Get the distribution of clients across different venue_id values.

[Assistant] SELECT venue_id, COUNT(*) AS count FROM music.clients GROUP BY venue_id ORDER BY count DESC;


[User] Get venue_id, salt, created_at from all clients.

[Assistant] SELECT venue_id, salt, created_at FROM music.clients;

[User] Show the results sorted by venue_id ascending.

[Assistant] SELECT venue_id, salt, created_at FROM music.clients ORDER BY venue_id ASC;

[User] Limit the results to 5 rows.

[Assistant] SELECT venue_id, salt, created_at FROM music.clients ORDER BY venue_id ASC LIMIT 5;


[User] Retrieve reference_number, user_id, created_at for every payment.

[Assistant] SELECT reference_number, user_id, created_at FROM music.payments;

[User] List created_at, processed_at, description, last_inspected for each payment along with their venue information.

[Assistant] SELECT reference_number, user_id, created_at, venues.description, venues.last_inspected FROM music.payments JOIN music.venues ON payments.venue_id = venues.store_id;

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

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


[User] Retrieve created_at, venue_id, reference_number for every payment.

[Assistant] SELECT created_at, venue_id, reference_number FROM music.payments;

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

[Assistant] SELECT created_at, venue_id, reference_number FROM music.payments WHERE created_at = CURRENT_DATE - INTERVAL '1 day';

[User] Group payments by user_id and show the min of processed_at.

[Assistant] SELECT user_id, MIN(processed_at) AS min_processed_at FROM music.payments GROUP BY user_id;


[User] Show me verification_status, processed_at, venue_id for all payments.

[Assistant] SELECT verification_status, processed_at, venue_id FROM music.payments;

[User] What processed_at, created_at, last_inspected, longitude do we have for payments and their associated venues?

[Assistant] SELECT verification_status, processed_at, venue_id, venues.last_inspected, venues.longitude FROM music.payments JOIN music.venues ON payments.venue_id = venues.store_id;

[User] Get min of user_id by user_id from payments.

[Assistant] SELECT user_id, MIN(user_id) AS min_user_id FROM music.payments GROUP BY user_id;


[User] Display all clients.

[Assistant] SELECT * FROM music.clients;

[User] Show me age, venue_id, longitude, last_inspected from clients and their related venues.

[Assistant] SELECT *, venues.longitude, venues.last_inspected FROM music.clients JOIN music.venues ON clients.venue_id = venues.store_id;

[User] Sort the results by salt descending.

[Assistant] SELECT *, venues.longitude, venues.last_inspected FROM music.clients JOIN music.venues ON clients.venue_id = venues.store_id 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 restaurant.orders (
  invoice_id text PRIMARY KEY -- unique identifier,
  created_at timestamp,
  processed_at timestamp without time zone,
  delivery_status char,
  discount decimal NOT NULL,
  store_id text NOT NULL -- reference to stores.location_id,
  FOREIGN KEY (store_id) REFERENCES stores(location_id)
)

CREATE TABLE restaurant.stores (
  location_id text PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at date,
  location_lat character varying(256),
  description varchar,
  address_line2 text NOT NULL,
  geo_point char,
  capacity character varying(64),
  order_id text NOT NULL -- reference to orders.invoice_id,
  FOREIGN KEY (order_id) REFERENCES orders(invoice_id)
)

[User] Display all orders.

[Assistant] SELECT * FROM restaurant.orders;

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

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

[User] How many orders are there per processed_at?

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


[User] Get created_at, description, order_id from all stores.

[Assistant] SELECT created_at, description, order_id FROM restaurant.stores;

[User] Find stores created yesterday.

[Assistant] SELECT created_at, description, order_id FROM restaurant.stores WHERE created_at = CURRENT_DATE - INTERVAL '1 day';

[User] Show me the count of stores grouped by geo_point.

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


[User] Show me all stores.

[Assistant] SELECT * FROM restaurant.stores;

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

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

[User] Get the distribution of stores across different address_line2 values.

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


[User] Get all stores.

[Assistant] SELECT * FROM restaurant.stores;

[User] What created_at, location_lat, delivery_status, created_at do we have for stores and their associated orders?

[Assistant] SELECT *, orders.delivery_status, orders.created_at FROM restaurant.stores JOIN restaurant.orders ON stores.order_id = orders.invoice_id;

[User] Get sum of capacity by description from stores.

[Assistant] SELECT description, SUM(capacity) AS sum_capacity FROM restaurant.stores GROUP BY description;


[User] Show me all orders.

[Assistant] SELECT * FROM restaurant.orders;

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

[Assistant] SELECT * FROM restaurant.orders WHERE created_at > '2023-01-01';

[User] What is the min store_id for each delivery_status in orders?

[Assistant] SELECT delivery_status, MIN(store_id) AS min_store_id FROM restaurant.orders GROUP BY delivery_status;


[User] What are the capacity, updated_at, geo_point of each store?

[Assistant] SELECT capacity, updated_at, geo_point FROM restaurant.stores;

[User] Get geo_point, capacity, processed_at, store_id by joining stores with orders.

[Assistant] SELECT capacity, updated_at, geo_point, orders.processed_at, orders.store_id FROM restaurant.stores JOIN restaurant.orders ON stores.order_id = orders.invoice_id;

[User] Order the output by address_line2 descending.

[Assistant] SELECT capacity, updated_at, geo_point, orders.processed_at, orders.store_id FROM restaurant.stores JOIN restaurant.orders ON stores.order_id = orders.invoice_id ORDER BY address_line2 DESC;


[User] What are the created_at, location_lat, description of each store?

[Assistant] SELECT created_at, location_lat, description FROM restaurant.stores;

[User] List location_lat, geo_point, delivery_status, store_id for each store along with their order information.

[Assistant] SELECT created_at, location_lat, description, orders.delivery_status, orders.store_id FROM restaurant.stores JOIN restaurant.orders ON stores.order_id = orders.invoice_id;

[User] Show me the count of stores grouped by geo_point.

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


[User] List order_id, geo_point, address_line2 from stores.

[Assistant] SELECT order_id, geo_point, address_line2 FROM restaurant.stores;

[User] What geo_point, created_at, created_at, delivery_status do we have for stores and their associated orders?

[Assistant] SELECT order_id, geo_point, address_line2, orders.created_at, orders.delivery_status FROM restaurant.stores JOIN restaurant.orders ON stores.order_id = orders.invoice_id;

[User] Limit the results to 20 rows.

[Assistant] SELECT order_id, geo_point, address_line2, orders.created_at, orders.delivery_status FROM restaurant.stores JOIN restaurant.orders ON stores.order_id = orders.invoice_id LIMIT 20;


[User] Retrieve all stores.

[Assistant] SELECT * FROM restaurant.stores;

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

[Assistant] SELECT * FROM restaurant.stores WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Show only 10 records.

[Assistant] SELECT * FROM restaurant.stores WHERE created_at >= CURRENT_DATE - INTERVAL '30 days' LIMIT 10;


[User] Display all stores.

[Assistant] SELECT * FROM restaurant.stores;

[User] Show me location_lat, geo_point, delivery_status, store_id from stores and their related orders.

[Assistant] SELECT *, orders.delivery_status, orders.store_id FROM restaurant.stores JOIN restaurant.orders ON stores.order_id = orders.invoice_id;

[User] Show me sum of capacity grouped by updated_at for stores.

[Assistant] SELECT updated_at, SUM(capacity) AS sum_capacity FROM restaurant.stores GROUP BY updated_at;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.grades (
  id text PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  created_at date,
  likes char,
  format character varying(256),
  media_url character varying(128) NOT NULL,
  body char,
  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,
  last_active timestamp,
  avatar char,
  gender text,
  salt character varying(128),
  country character varying(128) NOT NULL,
  display_name text,
  grade_id text -- reference to grades.id,
  FOREIGN KEY (grade_id) REFERENCES grades(id)
)

CREATE TABLE education.teachers (
  transaction_id character varying(64) NOT NULL -- unique identifier,
  processed_at date,
  cancelled_at date,
  card_type character varying(256),
  user_id character varying(256),
  exchange_rate character varying(64) NOT NULL,
  amount bigint NOT NULL,
  seller_id varchar -- identifier for seller,
  currency character varying(128),
  grade_id text NOT NULL -- reference to grades.id,
  FOREIGN KEY (grade_id) REFERENCES grades(id)
)

[User] Show me all students.

[Assistant] SELECT * FROM education.students;

[User] Order the output by last_active descending.

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

[User] Show the results sorted by last_active ascending.

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


[User] List updated_at, likes, format from grades.

[Assistant] SELECT updated_at, likes, format FROM education.grades;

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

[Assistant] SELECT updated_at, likes, format FROM education.grades WHERE body LIKE 'A%';

[User] How many grades are there per body?

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


[User] Get all students.

[Assistant] SELECT * FROM education.students;

[User] Show the results sorted by grade_id descending.

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

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

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


[User] List currency, transaction_id, processed_at from teachers.

[Assistant] SELECT currency, transaction_id, processed_at FROM education.teachers;

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

[Assistant] SELECT currency, transaction_id, processed_at FROM education.teachers WHERE processed_at > '2023-01-01';

[User] Show the results sorted by user_id ascending.

[Assistant] SELECT currency, transaction_id, processed_at FROM education.teachers WHERE processed_at > '2023-01-01' ORDER BY user_id ASC;


[User] List display_name, salt, country from students.

[Assistant] SELECT display_name, salt, country FROM education.students;

[User] Show the results sorted by grade_id descending.

[Assistant] SELECT display_name, salt, country FROM education.students ORDER BY grade_id DESC;

[User] Only show the top 5 results.

[Assistant] SELECT display_name, salt, country FROM education.students ORDER BY grade_id DESC LIMIT 5;


[User] What are the created_at, likes, student_id of each grade?

[Assistant] SELECT created_at, likes, student_id FROM education.grades;

[User] Get student_id, body, grade_id, avatar by joining grades with students.

[Assistant] SELECT created_at, likes, student_id, students.grade_id, students.avatar FROM education.grades JOIN education.students ON grades.student_id = students.employee_id;

[User] Show the results sorted by media_url ascending.

[Assistant] SELECT created_at, likes, student_id, students.grade_id, students.avatar FROM education.grades JOIN education.students ON grades.student_id = students.employee_id ORDER BY media_url ASC;


[User] Retrieve all students.

[Assistant] SELECT * FROM education.students;

[User] Show me students with last_active > '2023-01-01'.

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

[User] Order the output by display_name ascending.

[Assistant] SELECT * FROM education.students WHERE last_active > '2023-01-01' ORDER BY display_name ASC;


[User] List seller_id, transaction_id, processed_at from teachers.

[Assistant] SELECT seller_id, transaction_id, processed_at FROM education.teachers;

[User] Can you order these by card_type descending?

[Assistant] SELECT seller_id, transaction_id, processed_at FROM education.teachers ORDER BY card_type DESC;

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

[Assistant] SELECT seller_id, transaction_id, processed_at FROM education.teachers ORDER BY seller_id DESC;


[User] Show me all students.

[Assistant] SELECT * FROM education.students;

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

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

[User] Show the results sorted by last_active descending.

[Assistant] SELECT * FROM education.students WHERE grade_id LIKE 'A%' ORDER BY last_active DESC;


[User] Show me processed_at, currency, exchange_rate for all teachers.

[Assistant] SELECT processed_at, currency, exchange_rate FROM education.teachers;

[User] Find teachers from 2023.

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

[User] How many teachers are there per amount?

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE e-commerce.shipping (
  sku text PRIMARY KEY -- unique identifier,
  published_at timestamp,
  updated_at date,
  stock_level text,
  popularity_score text NOT NULL,
  category varchar,
  available varchar,
  quantity varchar,
  order_item_id integer -- reference to order_items.id,
  FOREIGN KEY (order_item_id) REFERENCES order_items(id)
)

CREATE TABLE e-commerce.inventory (
  sku text PRIMARY KEY -- unique identifier,
  published_at timestamp,
  rating character varying(128),
  featured_rank character varying(64),
  popularity_score varchar,
  backorder character varying(64),
  thumbnail_url character varying(64) NOT NULL,
  price integer,
  order_item_id integer NOT NULL -- reference to order_items.id,
  FOREIGN KEY (order_item_id) REFERENCES order_items(id)
)

CREATE TABLE e-commerce.order_items (
  id integer PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  state text NOT NULL,
  email varchar,
  nationality character varying(128),
  inventor_id text -- reference to inventory.sku,
  shippin_id text NOT NULL -- reference to shipping.sku,
  FOREIGN KEY (inventor_id) REFERENCES inventory(sku),
  FOREIGN KEY (shippin_id) REFERENCES shipping(sku)
)

[User] List backorder, order_item_id, rating from inventory.

[Assistant] SELECT backorder, order_item_id, rating FROM e-commerce.inventory;

[User] Show me published_at, rating, state, inventor_id from inventory and their related order_items.

[Assistant] SELECT backorder, order_item_id, rating, order_items.state, order_items.inventor_id FROM e-commerce.inventory JOIN e-commerce.order_items ON inventory.order_item_id = order_items.id;

[User] Calculate max of price for each thumbnail_url in inventory.

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


[User] What are the popularity_score, category, updated_at of each shipping?

[Assistant] SELECT popularity_score, category, updated_at FROM e-commerce.shipping;

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

[Assistant] SELECT popularity_score, category, updated_at FROM e-commerce.shipping WHERE popularity_score LIKE 'A%';

[User] Group shipping by available and show the min of popularity_score.

[Assistant] SELECT available, MIN(popularity_score) AS min_popularity_score FROM e-commerce.shipping GROUP BY available;


[User] What are the popularity_score, updated_at, category of each shipping?

[Assistant] SELECT popularity_score, updated_at, category FROM e-commerce.shipping;

[User] Get stock_level, popularity_score, email, state by joining shipping with order_items.

[Assistant] SELECT popularity_score, updated_at, category, order_items.email, order_items.state FROM e-commerce.shipping JOIN e-commerce.order_items ON shipping.order_item_id = order_items.id;

[User] Return just 20 rows.

[Assistant] SELECT popularity_score, updated_at, category, order_items.email, order_items.state FROM e-commerce.shipping JOIN e-commerce.order_items ON shipping.order_item_id = order_items.id LIMIT 20;


[User] List state, shippin_id, updated_at from order_items.

[Assistant] SELECT state, shippin_id, updated_at FROM e-commerce.order_items;

[User] Find order_items older than 6 months.

[Assistant] SELECT state, shippin_id, updated_at FROM e-commerce.order_items WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months';

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

[Assistant] SELECT state, shippin_id, updated_at FROM e-commerce.order_items WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months' ORDER BY state ASC;


[User] Retrieve all inventory.

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

[User] Show me thumbnail_url, published_at, shippin_id, state from inventory and their related order_items.

[Assistant] SELECT *, order_items.shippin_id, order_items.state FROM e-commerce.inventory JOIN e-commerce.order_items ON inventory.order_item_id = order_items.id;

[User] Tally up inventory by rating.

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


[User] Retrieve popularity_score, thumbnail_url, rating for every inventory.

[Assistant] SELECT popularity_score, thumbnail_url, rating FROM e-commerce.inventory;

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

[Assistant] SELECT popularity_score, thumbnail_url, rating FROM e-commerce.inventory WHERE published_at > '2023-12-01';

[User] Can you order these by thumbnail_url descending?

[Assistant] SELECT popularity_score, thumbnail_url, rating FROM e-commerce.inventory WHERE published_at > '2023-12-01' ORDER BY thumbnail_url DESC;


[User] Show me shippin_id, inventor_id, updated_at for all order_items.

[Assistant] SELECT shippin_id, inventor_id, updated_at FROM e-commerce.order_items;

[User] Can you order these by inventor_id descending?

[Assistant] SELECT shippin_id, inventor_id, updated_at FROM e-commerce.order_items ORDER BY inventor_id DESC;

[User] Only show the top 50 results.

[Assistant] SELECT shippin_id, inventor_id, updated_at FROM e-commerce.order_items ORDER BY inventor_id DESC LIMIT 50;


[User] Display all order_items.

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

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

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

[User] Can you order these by email descending?

[Assistant] SELECT * FROM e-commerce.order_items WHERE inventor_id LIKE 'A%' ORDER BY email DESC;


[User] Get rating, order_item_id, popularity_score from all inventory.

[Assistant] SELECT rating, order_item_id, popularity_score FROM e-commerce.inventory;

[User] Show the results sorted by rating descending.

[Assistant] SELECT rating, order_item_id, popularity_score FROM e-commerce.inventory ORDER BY rating DESC;

[User] Show the results sorted by popularity_score descending.

[Assistant] SELECT rating, order_item_id, popularity_score FROM e-commerce.inventory ORDER BY popularity_score DESC;


[User] Retrieve available, order_item_id, published_at for every shipping.

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

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

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

[User] Show only 25 records.

[Assistant] SELECT available, order_item_id, published_at FROM e-commerce.shipping WHERE quantity LIKE 'A%' LIMIT 25;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE realestate.addresses (
  address_id varchar PRIMARY KEY -- unique identifier,
  created_at date,
  description character varying(64),
  accessibility character varying(256) NOT NULL,
  operating_hours varchar,
  state char,
  postal_code text NOT NULL,
  booking_id integer -- reference to bookings.id,
  customer_id text NOT NULL -- reference to customers.id,
  FOREIGN KEY (booking_id) REFERENCES bookings(id),
  FOREIGN KEY (customer_id) REFERENCES customers(id)
)

CREATE TABLE realestate.bookings (
  id integer PRIMARY KEY -- unique identifier,
  completed_at timestamp,
  payment_method char,
  exchange_rate character varying(256) NOT NULL,
  payment_status character varying(128),
  customer_id text -- reference to customers.id,
  FOREIGN KEY (customer_id) REFERENCES customers(id)
)

CREATE TABLE realestate.customers (
  id varchar PRIMARY KEY -- unique identifier,
  updated_at date,
  created_at date,
  address character varying(256),
  salt character varying(64),
  status char,
  booking_id integer NOT NULL -- reference to bookings.id,
  FOREIGN KEY (booking_id) REFERENCES bookings(id)
)

[User] List all bookings.

[Assistant] SELECT * FROM realestate.bookings;

[User] Order the output by exchange_rate descending.

[Assistant] SELECT * FROM realestate.bookings ORDER BY exchange_rate DESC;

[User] Sort the results by payment_status descending.

[Assistant] SELECT * FROM realestate.bookings ORDER BY payment_status DESC;


[User] Retrieve all bookings.

[Assistant] SELECT * FROM realestate.bookings;

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

[Assistant] SELECT * FROM realestate.bookings WHERE completed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

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

[Assistant] SELECT * FROM realestate.bookings WHERE completed_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' ORDER BY payment_status DESC;


[User] List accessibility, postal_code, state from addresses.

[Assistant] SELECT accessibility, postal_code, state FROM realestate.addresses;

[User] Show me addresses with accessibility LIKE 'A%'.

[Assistant] SELECT accessibility, postal_code, state FROM realestate.addresses WHERE accessibility LIKE 'A%';

[User] Show the results sorted by operating_hours descending.

[Assistant] SELECT accessibility, postal_code, state FROM realestate.addresses WHERE accessibility LIKE 'A%' ORDER BY operating_hours DESC;


[User] What are the salt, booking_id, updated_at of each customer?

[Assistant] SELECT salt, booking_id, updated_at FROM realestate.customers;

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

[Assistant] SELECT salt, booking_id, updated_at FROM realestate.customers WHERE salt LIKE 'A%';

[User] How many customers are there per status?

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


[User] List exchange_rate, payment_method, customer_id from bookings.

[Assistant] SELECT exchange_rate, payment_method, customer_id FROM realestate.bookings;

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

[Assistant] SELECT exchange_rate, payment_method, customer_id FROM realestate.bookings WHERE exchange_rate LIKE 'A%';

[User] Show me the count of bookings grouped by payment_method.

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


[User] Retrieve booking_id, created_at, salt for every customer.

[Assistant] SELECT booking_id, created_at, salt FROM realestate.customers;

[User] Get salt, created_at, payment_method, exchange_rate by joining customers with bookings.

[Assistant] SELECT booking_id, created_at, salt, bookings.payment_method, bookings.exchange_rate FROM realestate.customers JOIN realestate.bookings ON customers.booking_id = bookings.id;

[User] What is the average booking_id for each status in customers?

[Assistant] SELECT status, AVERAGE(booking_id) AS average_booking_id FROM realestate.customers GROUP BY status;


[User] Show me all addresses.

[Assistant] SELECT * FROM realestate.addresses;

[User] Find addresses where operating_hours LIKE 'A%'.

[Assistant] SELECT * FROM realestate.addresses WHERE operating_hours LIKE 'A%';

[User] Show me the count of addresses grouped by operating_hours.

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


[User] Display all bookings.

[Assistant] SELECT * FROM realestate.bookings;

[User] Find bookings where exchange_rate LIKE 'A%'.

[Assistant] SELECT * FROM realestate.bookings WHERE exchange_rate LIKE 'A%';

[User] Show only 10 records.

[Assistant] SELECT * FROM realestate.bookings WHERE exchange_rate LIKE 'A%' LIMIT 10;


[User] List all bookings.

[Assistant] SELECT * FROM realestate.bookings;

[User] List payment_method, customer_id, created_at, updated_at for each booking along with their customer information.

[Assistant] SELECT *, customers.created_at, customers.updated_at FROM realestate.bookings JOIN realestate.customers ON bookings.customer_id = customers.id;

[User] Show only 10 records.

[Assistant] SELECT *, customers.created_at, customers.updated_at FROM realestate.bookings JOIN realestate.customers ON bookings.customer_id = customers.id LIMIT 10;


[User] Get status, address, salt from all customers.

[Assistant] SELECT status, address, salt FROM realestate.customers;

[User] Sort the results by updated_at ascending.

[Assistant] SELECT status, address, salt FROM realestate.customers ORDER BY updated_at ASC;

[User] Count the number of customers in each address category.

[Assistant] SELECT address, COUNT(*) AS count FROM realestate.customers GROUP BY address 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.users (
  customer_id text PRIMARY KEY -- unique identifier,
  joined_at timestamp,
  created_at date,
  status varchar,
  first_name char NOT NULL,
  language char,
  full_name text NOT NULL,
  state character varying(64),
  wallet_id text NOT NULL -- reference to wallets.payment_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(payment_id)
)

CREATE TABLE tradingplatform.wallets (
  payment_id varchar PRIMARY KEY -- unique identifier,
  payment_date timestamp without time zone,
  updated_at date,
  balance smallint,
  reconciliation_status character varying(64) NOT NULL,
  payer_id text,
  credit character varying(256) NOT NULL
)

CREATE TABLE tradingplatform.trades (
  transaction_id integer PRIMARY KEY -- unique identifier,
  cancelled_at timestamp,
  completed_at date,
  user_id character varying(256) NOT NULL -- identifier for user,
  discount smallint NOT NULL,
  quantity character varying(128) NOT NULL,
  wallet_id text -- reference to wallets.payment_id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(payment_id)
)

[User] Retrieve all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

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

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

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

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


[User] What are the discount, cancelled_at, user_id of each trade?

[Assistant] SELECT discount, cancelled_at, user_id FROM tradingplatform.trades;

[User] Show me wallet_id, quantity, payer_id, payment_date from trades and their related wallets.

[Assistant] SELECT discount, cancelled_at, user_id, wallets.payer_id, wallets.payment_date FROM tradingplatform.trades JOIN tradingplatform.wallets ON trades.wallet_id = wallets.payment_id;

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

[Assistant] SELECT discount, cancelled_at, user_id, wallets.payer_id, wallets.payment_date FROM tradingplatform.trades JOIN tradingplatform.wallets ON trades.wallet_id = wallets.payment_id ORDER BY completed_at DESC;


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

[Assistant] SELECT full_name, created_at, status FROM tradingplatform.users;

[User] Show me status, state, payment_date, balance from users and their related wallets.

[Assistant] SELECT full_name, created_at, status, wallets.payment_date, wallets.balance FROM tradingplatform.users JOIN tradingplatform.wallets ON users.wallet_id = wallets.payment_id;

[User] Sort the results by first_name ascending.

[Assistant] SELECT full_name, created_at, status, wallets.payment_date, wallets.balance FROM tradingplatform.users JOIN tradingplatform.wallets ON users.wallet_id = wallets.payment_id ORDER BY first_name ASC;


[User] Retrieve quantity, wallet_id, cancelled_at for every trade.

[Assistant] SELECT quantity, wallet_id, cancelled_at FROM tradingplatform.trades;

[User] Retrieve trades where cancelled_at > '2023-01-01'.

[Assistant] SELECT quantity, wallet_id, cancelled_at FROM tradingplatform.trades WHERE cancelled_at > '2023-01-01';

[User] Show me count of wallet_id grouped by user_id for trades.

[Assistant] SELECT user_id, COUNT(wallet_id) AS count_wallet_id FROM tradingplatform.trades GROUP BY user_id;


[User] List all users.

[Assistant] SELECT * FROM tradingplatform.users;

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

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

[User] Restrict the output to 10 items.

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


[User] What are the full_name, status, first_name of each user?

[Assistant] SELECT full_name, status, first_name FROM tradingplatform.users;

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

[Assistant] SELECT full_name, status, first_name FROM tradingplatform.users WHERE state LIKE 'A%';

[User] Restrict the output to 5 items.

[Assistant] SELECT full_name, status, first_name FROM tradingplatform.users WHERE state LIKE 'A%' LIMIT 5;


[User] List joined_at, full_name, language from users.

[Assistant] SELECT joined_at, full_name, language FROM tradingplatform.users;

[User] Sort the results by first_name descending.

[Assistant] SELECT joined_at, full_name, language FROM tradingplatform.users ORDER BY first_name DESC;

[User] Can you order these by created_at ascending?

[Assistant] SELECT joined_at, full_name, language FROM tradingplatform.users ORDER BY created_at ASC;


[User] Get language, created_at, joined_at from all users.

[Assistant] SELECT language, created_at, joined_at FROM tradingplatform.users;

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

[Assistant] SELECT language, created_at, joined_at FROM tradingplatform.users ORDER BY status DESC;

[User] Can you order these by wallet_id descending?

[Assistant] SELECT language, created_at, joined_at FROM tradingplatform.users ORDER BY wallet_id DESC;


[User] Show me full_name, language, first_name for all users.

[Assistant] SELECT full_name, language, first_name FROM tradingplatform.users;

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

[Assistant] SELECT full_name, language, first_name FROM tradingplatform.users WHERE created_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Can you order these by first_name ascending?

[Assistant] SELECT full_name, language, first_name FROM tradingplatform.users WHERE created_at >= CURRENT_DATE - INTERVAL '30 days' ORDER BY first_name ASC;


[User] Display all trades.

[Assistant] SELECT * FROM tradingplatform.trades;

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

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

[User] Sort the results by discount descending.

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


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE finance.customers (
  customer_id integer PRIMARY KEY -- unique identifier,
  joined_at timestamp without time zone,
  last_active timestamp without time zone,
  bio char,
  timezone char NOT NULL,
  last_login timestamp without time zone,
  is_active boolean -- indicates if active is true,
  account_id integer NOT NULL -- reference to accounts.transaction_id,
  FOREIGN KEY (account_id) REFERENCES accounts(transaction_id)
)

CREATE TABLE finance.accounts (
  transaction_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  user_id text -- identifier for user,
  vendor_id character varying(64) NOT NULL,
  credit character varying(64),
  invoice_number character varying(256),
  debit character varying(256),
  customer_id text
)

[User] Show me all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Get all customers from last week.

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

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

[Assistant] SELECT * FROM finance.customers WHERE joined_at >= CURRENT_DATE - INTERVAL '7 days' ORDER BY timezone ASC;


[User] Show me all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Get all customers from 2023.

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

[User] Show me the count of customers grouped by timezone.

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


[User] Show me last_active, timezone, account_id for all customers.

[Assistant] SELECT last_active, timezone, account_id FROM finance.customers;

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

[Assistant] SELECT last_active, timezone, account_id FROM finance.customers WHERE joined_at > '2023-01-01';

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

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


[User] Get all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Retrieve timezone, is_active, invoice_number, user_id showing the relationship between customers and accounts.

[Assistant] SELECT *, accounts.invoice_number, accounts.user_id FROM finance.customers JOIN finance.accounts ON customers.account_id = accounts.transaction_id;

[User] Limit the results to 50 rows.

[Assistant] SELECT *, accounts.invoice_number, accounts.user_id FROM finance.customers JOIN finance.accounts ON customers.account_id = accounts.transaction_id LIMIT 50;


[User] What are the timezone, account_id, last_active of each customer?

[Assistant] SELECT timezone, account_id, last_active FROM finance.customers;

[User] Get last_login, account_id, invoice_number, created_at by joining customers with accounts.

[Assistant] SELECT timezone, account_id, last_active, accounts.invoice_number, accounts.created_at FROM finance.customers JOIN finance.accounts ON customers.account_id = accounts.transaction_id;

[User] Restrict the output to 25 items.

[Assistant] SELECT timezone, account_id, last_active, accounts.invoice_number, accounts.created_at FROM finance.customers JOIN finance.accounts ON customers.account_id = accounts.transaction_id LIMIT 25;


[User] Display all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Find customers modified within the last hour.

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

[User] What is the average bio for each timezone in customers?

[Assistant] SELECT timezone, AVERAGE(bio) AS average_bio FROM finance.customers GROUP BY timezone;


[User] Retrieve bio, last_active, timezone for every customer.

[Assistant] SELECT bio, last_active, timezone FROM finance.customers;

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

[Assistant] SELECT bio, last_active, timezone FROM finance.customers ORDER BY account_id DESC;

[User] What is the average bio for each account_id in customers?

[Assistant] SELECT account_id, AVERAGE(bio) AS average_bio FROM finance.customers GROUP BY account_id;


[User] Get all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Get timezone, joined_at, created_at, vendor_id by joining customers with accounts.

[Assistant] SELECT *, accounts.created_at, accounts.vendor_id FROM finance.customers JOIN finance.accounts ON customers.account_id = accounts.transaction_id;

[User] Group customers by last_active and show the average of last_active.

[Assistant] SELECT last_active, AVERAGE(last_active) AS average_last_active FROM finance.customers GROUP BY last_active;


[User] List all customers.

[Assistant] SELECT * FROM finance.customers;

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

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

[User] Return just 10 rows.

[Assistant] SELECT * FROM finance.customers WHERE joined_at > '2023-12-01' LIMIT 10;


[User] Get all customers.

[Assistant] SELECT * FROM finance.customers;

[User] Find customers where timezone LIKE 'A%'.

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

[User] Count the number of customers in each last_active category.

[Assistant] SELECT last_active, COUNT(*) AS count FROM finance.customers GROUP BY last_active 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.teachers (
  invoice_id varchar PRIMARY KEY -- unique identifier,
  updated_at timestamp,
  seller_id character varying(256) -- identifier for seller,
  payment_method varchar NOT NULL,
  subtotal bigint
)

CREATE TABLE education.enrollments (
  employee_id character varying(64) NOT NULL -- unique identifier,
  created_at timestamp without time zone,
  joined_at timestamp,
  username character varying(128) NOT NULL,
  last_login timestamp without time zone,
  password_hash varchar NOT NULL,
  membership_level varchar,
  country character varying(256) NOT NULL
)

[User] List employee_id, username, membership_level from enrollments.

[Assistant] SELECT employee_id, username, membership_level FROM education.enrollments;

[User] Get all enrollments older than 6 months.

[Assistant] SELECT employee_id, username, membership_level FROM education.enrollments WHERE last_login <= CURRENT_DATE - INTERVAL '6 months';

[User] Tally up enrollments by joined_at.

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


[User] Show me all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

[User] How many teachers are there per subtotal?

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


[User] Retrieve joined_at, employee_id, last_login for every enrollment.

[Assistant] SELECT joined_at, employee_id, last_login FROM education.enrollments;

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

[Assistant] SELECT joined_at, employee_id, last_login FROM education.enrollments WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] Count the number of enrollments in each password_hash category.

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


[User] Retrieve membership_level, joined_at, employee_id for every enrollment.

[Assistant] SELECT membership_level, joined_at, employee_id FROM education.enrollments;

[User] Show me enrollments with joined_at > '2023-01-01'.

[Assistant] SELECT membership_level, joined_at, employee_id FROM education.enrollments WHERE joined_at > '2023-01-01';

[User] Sort the results by country descending.

[Assistant] SELECT membership_level, joined_at, employee_id FROM education.enrollments WHERE joined_at > '2023-01-01' ORDER BY country DESC;


[User] Retrieve all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

[User] Restrict the output to 5 items.

[Assistant] SELECT * FROM education.teachers WHERE updated_at <= CURRENT_DATE - INTERVAL '6 months' LIMIT 5;


[User] Display all teachers.

[Assistant] SELECT * FROM education.teachers;

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

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

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

[Assistant] SELECT * FROM education.teachers WHERE updated_at > '2023-01-01' ORDER BY subtotal DESC;


[User] Retrieve seller_id, payment_method, updated_at for every teacher.

[Assistant] SELECT seller_id, payment_method, updated_at FROM education.teachers;

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

[Assistant] SELECT seller_id, payment_method, updated_at FROM education.teachers ORDER BY subtotal ASC;

[User] Limit the results to 5 rows.

[Assistant] SELECT seller_id, payment_method, updated_at FROM education.teachers ORDER BY subtotal ASC LIMIT 5;


[User] What are the subtotal, updated_at, payment_method of each teacher?

[Assistant] SELECT subtotal, updated_at, payment_method FROM education.teachers;

[User] Show the results sorted by updated_at ascending.

[Assistant] SELECT subtotal, updated_at, payment_method FROM education.teachers ORDER BY updated_at ASC;

[User] Get count of payment_method by subtotal from teachers.

[Assistant] SELECT subtotal, COUNT(payment_method) AS count_payment_method FROM education.teachers GROUP BY subtotal;


[User] List all teachers.

[Assistant] SELECT * FROM education.teachers;

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

[Assistant] SELECT * FROM education.teachers ORDER BY payment_method DESC;

[User] Limit the results to 10 rows.

[Assistant] SELECT * FROM education.teachers ORDER BY payment_method DESC LIMIT 10;


[User] Display all teachers.

[Assistant] SELECT * FROM education.teachers;

[User] List teachers that have seller_id LIKE 'A%'.

[Assistant] SELECT * FROM education.teachers WHERE seller_id LIKE 'A%';

[User] Show the results sorted by seller_id ascending.

[Assistant] SELECT * FROM education.teachers WHERE seller_id LIKE 'A%' ORDER BY seller_id ASC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE education.enrollments (
  post_id varchar PRIMARY KEY -- unique identifier,
  published_at timestamp,
  image_url character varying(128),
  text character varying(64) NOT NULL,
  body character varying(256),
  attachment_url text,
  assignment_id integer -- reference to assignments.employee_id,
  FOREIGN KEY (assignment_id) REFERENCES assignments(employee_id)
)

CREATE TABLE education.courses (
  id integer PRIMARY KEY -- unique identifier,
  created_at date,
  status character varying(256),
  card_type varchar,
  approval_status varchar,
  discount numeric(38,14) NOT NULL
)

CREATE TABLE education.assignments (
  employee_id integer PRIMARY KEY -- unique identifier,
  updated_at date,
  is_active boolean,
  age character varying(128),
  language char,
  gender text,
  password_hash char,
  last_login timestamp NOT NULL,
  course_id integer -- reference to courses.id,
  enrollment_id text -- reference to enrollments.post_id,
  FOREIGN KEY (course_id) REFERENCES courses(id),
  FOREIGN KEY (enrollment_id) REFERENCES enrollments(post_id)
)

[User] List all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Get attachment_url, assignment_id, course_id, language by joining enrollments with assignments.

[Assistant] SELECT *, assignments.course_id, assignments.language FROM education.enrollments JOIN education.assignments ON enrollments.assignment_id = assignments.employee_id;

[User] Show me the count of enrollments grouped by body.

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


[User] Display all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Show me attachment_url, published_at, updated_at, age from enrollments and their related assignments.

[Assistant] SELECT *, assignments.updated_at, assignments.age FROM education.enrollments JOIN education.assignments ON enrollments.assignment_id = assignments.employee_id;

[User] Only show the top 10 results.

[Assistant] SELECT *, assignments.updated_at, assignments.age FROM education.enrollments JOIN education.assignments ON enrollments.assignment_id = assignments.employee_id LIMIT 10;


[User] Retrieve published_at, attachment_url, text for every enrollment.

[Assistant] SELECT published_at, attachment_url, text FROM education.enrollments;

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

[Assistant] SELECT published_at, attachment_url, text FROM education.enrollments WHERE published_at BETWEEN '2023-01-01' AND '2023-03-31';

[User] Calculate sum of body for each attachment_url in enrollments.

[Assistant] SELECT attachment_url, SUM(body) AS sum_body FROM education.enrollments GROUP BY attachment_url;


[User] Display all enrollments.

[Assistant] SELECT * FROM education.enrollments;

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

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

[User] Show the results sorted by body descending.

[Assistant] SELECT * FROM education.enrollments WHERE published_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY body DESC;


[User] Show me course_id, language, gender for all assignments.

[Assistant] SELECT course_id, language, gender FROM education.assignments;

[User] List assignments that have enrollment_id LIKE 'A%'.

[Assistant] SELECT course_id, language, gender FROM education.assignments WHERE enrollment_id LIKE 'A%';

[User] Order the output by is_active descending.

[Assistant] SELECT course_id, language, gender FROM education.assignments WHERE enrollment_id LIKE 'A%' ORDER BY is_active DESC;


[User] List all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Retrieve age, last_login, created_at, card_type showing the relationship between assignments and courses.

[Assistant] SELECT *, courses.created_at, courses.card_type FROM education.assignments JOIN education.courses ON assignments.course_id = courses.id;

[User] Show me min of age grouped by language for assignments.

[Assistant] SELECT language, MIN(age) AS min_age FROM education.assignments GROUP BY language;


[User] List age, password_hash, language from assignments.

[Assistant] SELECT age, password_hash, language FROM education.assignments;

[User] Sort the results by gender ascending.

[Assistant] SELECT age, password_hash, language FROM education.assignments ORDER BY gender ASC;

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

[Assistant] SELECT age, password_hash, language FROM education.assignments ORDER BY is_active DESC;


[User] List all assignments.

[Assistant] SELECT * FROM education.assignments;

[User] Find assignments where language LIKE 'A%'.

[Assistant] SELECT * FROM education.assignments WHERE language LIKE 'A%';

[User] Restrict the output to 10 items.

[Assistant] SELECT * FROM education.assignments WHERE language LIKE 'A%' LIMIT 10;


[User] List all enrollments.

[Assistant] SELECT * FROM education.enrollments;

[User] Retrieve enrollments where attachment_url LIKE 'A%'.

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

[User] Only show the top 20 results.

[Assistant] SELECT * FROM education.enrollments WHERE attachment_url LIKE 'A%' LIMIT 20;


[User] Show me all assignments.

[Assistant] SELECT * FROM education.assignments;

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

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

[User] Order the output by age ascending.

[Assistant] SELECT * FROM education.assignments WHERE last_login > '2023-12-01' ORDER BY age 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 text PRIMARY KEY -- unique identifier,
  edited_at timestamp,
  author_id varchar NOT NULL -- identifier for author,
  subject text,
  user_id character varying(64) NOT NULL -- identifier for user,
  post_id text NOT NULL -- reference to posts.id,
  FOREIGN KEY (post_id) REFERENCES posts(id)
)

CREATE TABLE socialmedia.events (
  account_id character varying(64) NOT NULL -- unique identifier,
  updated_at timestamp without time zone,
  created_at timestamp,
  notes character varying(256) NOT NULL,
  reconciliation_status text NOT NULL,
  customer_id character varying(128),
  user_id character varying(64),
  category varchar NOT NULL,
  vendor_id varchar -- identifier for vendor
)

CREATE TABLE socialmedia.followers (
  person_id text PRIMARY KEY -- unique identifier,
  created_at date,
  username text,
  first_name varchar,
  nationality character varying(128) NOT NULL
)

CREATE TABLE socialmedia.posts (
  id text PRIMARY KEY -- unique identifier,
  created_at date,
  published_at date,
  tags character varying(64) NOT NULL,
  image_url varchar,
  title text
)

CREATE TABLE socialmedia.users (
  person_id character varying(64) NOT NULL -- unique identifier,
  created_at date,
  last_active date,
  email character varying(64) NOT NULL,
  first_name char NOT NULL,
  timezone character varying(64) NOT NULL,
  password_hash char,
  follower_id text -- reference to followers.person_id,
  FOREIGN KEY (follower_id) REFERENCES followers(person_id)
)

[User] Display all users.

[Assistant] SELECT * FROM socialmedia.users;

[User] Sort the results by person_id ascending.

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

[User] Order the output by created_at ascending.

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


[User] Show me all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] Get all messages from last week.

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

[User] Restrict the output to 50 items.

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


[User] Show me all messages.

[Assistant] SELECT * FROM socialmedia.messages;

[User] List messages that have edited_at > '2023-01-01'.

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

[User] Can you order these by author_id descending?

[Assistant] SELECT * FROM socialmedia.messages WHERE edited_at > '2023-01-01' ORDER BY author_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 government.comments (
  comment_id text PRIMARY KEY -- unique identifier,
  published_at date,
  updated_at timestamp,
  user_id character varying(256) -- identifier for user,
  body character varying(64),
  description varchar NOT NULL,
  thumbnail text,
  visibility varchar,
  keywords character varying(128),
  location_id text -- reference to locations.venue_id,
  FOREIGN KEY (location_id) REFERENCES locations(venue_id)
)

CREATE TABLE government.locations (
  venue_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  created_at date,
  accessibility char,
  address_line2 character varying(256),
  comment_id text -- reference to comments.comment_id,
  FOREIGN KEY (comment_id) REFERENCES comments(comment_id)
)

CREATE TABLE government.payments (
  invoice_id character varying(64) NOT NULL -- unique identifier,
  payment_date date,
  payee_id varchar NOT NULL -- identifier for payee,
  reconciliation_status text NOT NULL,
  vendor_id char -- identifier for vendor,
  payer_id character varying(128) -- identifier for payer,
  category character varying(256),
  balance decimal
)

[User] Get all locations.

[Assistant] SELECT * FROM government.locations;

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

[Assistant] SELECT * FROM government.locations WHERE address_line2 LIKE 'A%';

[User] Tally up locations by address_line2.

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


[User] Retrieve all comments.

[Assistant] SELECT * FROM government.comments;

[User] Show the results sorted by location_id descending.

[Assistant] SELECT * FROM government.comments ORDER BY location_id DESC;

[User] Show only 50 records.

[Assistant] SELECT * FROM government.comments ORDER BY location_id DESC LIMIT 50;


[User] Get all comments.

[Assistant] SELECT * FROM government.comments;

[User] Find comments modified within the last hour.

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

[User] Return just 5 rows.

[Assistant] SELECT * FROM government.comments WHERE updated_at >= CURRENT_TIMESTAMP - INTERVAL '1 hour' LIMIT 5;


[User] What are the published_at, updated_at, location_id of each comment?

[Assistant] SELECT published_at, updated_at, location_id FROM government.comments;

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

[Assistant] SELECT published_at, updated_at, location_id FROM government.comments WHERE description LIKE 'A%';

[User] What is the average description for each body in comments?

[Assistant] SELECT body, AVERAGE(description) AS average_description FROM government.comments GROUP BY body;


[User] Get all comments.

[Assistant] SELECT * FROM government.comments;

[User] List comments with dates from last week.

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

[User] Limit the results to 25 rows.

[Assistant] SELECT * FROM government.comments WHERE published_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 25;