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.orders (
  id character varying(64) NOT NULL -- unique identifier,
  processed_at timestamp,
  updated_at date,
  status character varying(64) NOT NULL,
  fee char NOT NULL,
  payment_method varchar,
  tax numeric NOT NULL,
  delivery_status character varying(128) NOT NULL,
  user_id character varying(256),
  wallet_id text -- reference to wallets.id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(id)
)

CREATE TABLE tradingplatform.users (
  customer_id integer PRIMARY KEY -- unique identifier,
  created_at timestamp,
  joined_at timestamp without time zone,
  token varchar,
  password_hash text NOT NULL,
  status character varying(128),
  username varchar NOT NULL
)

CREATE TABLE tradingplatform.wallets (
  id varchar PRIMARY KEY -- unique identifier,
  due_date date,
  updated_at timestamp,
  approval_status character varying(64),
  payer_id text,
  exchange_rate varchar
)

[User] Show me all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Order the output by status ascending.

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

[User] Calculate average of updated_at for each processed_at in orders.

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


[User] List processed_at, tax, id from orders.

[Assistant] SELECT processed_at, tax, id FROM tradingplatform.orders;

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

[Assistant] SELECT processed_at, tax, id FROM tradingplatform.orders WHERE processed_at >= CURRENT_DATE - INTERVAL '7 days';

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

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


[User] Retrieve all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Order the output by delivery_status descending.

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

[User] Limit the results to 50 rows.

[Assistant] SELECT * FROM tradingplatform.orders ORDER BY delivery_status DESC LIMIT 50;


[User] Show me processed_at, tax, wallet_id for all orders.

[Assistant] SELECT processed_at, tax, wallet_id FROM tradingplatform.orders;

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

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

[User] Tally up orders by processed_at.

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


[User] Get updated_at, tax, id from all orders.

[Assistant] SELECT updated_at, tax, id FROM tradingplatform.orders;

[User] Get id, updated_at, exchange_rate, payer_id by joining orders with wallets.

[Assistant] SELECT updated_at, tax, id, wallets.exchange_rate, wallets.payer_id FROM tradingplatform.orders JOIN tradingplatform.wallets ON orders.wallet_id = wallets.id;

[User] Group orders by fee and show the count of user_id.

[Assistant] SELECT fee, COUNT(user_id) AS count_user_id FROM tradingplatform.orders GROUP BY fee;


[User] What are the status, tax, delivery_status of each order?

[Assistant] SELECT status, tax, delivery_status FROM tradingplatform.orders;

[User] Find orders from last week.

[Assistant] SELECT status, tax, delivery_status FROM tradingplatform.orders WHERE processed_at >= CURRENT_DATE - INTERVAL '7 days';

[User] Limit the results to 25 rows.

[Assistant] SELECT status, tax, delivery_status FROM tradingplatform.orders WHERE processed_at >= CURRENT_DATE - INTERVAL '7 days' LIMIT 25;


[User] What are the user_id, payment_method, status of each order?

[Assistant] SELECT user_id, payment_method, status FROM tradingplatform.orders;

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

[Assistant] SELECT user_id, payment_method, status FROM tradingplatform.orders WHERE payment_method LIKE 'A%';

[User] Only show the top 100 results.

[Assistant] SELECT user_id, payment_method, status FROM tradingplatform.orders WHERE payment_method LIKE 'A%' LIMIT 100;


[User] Get all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Retrieve status, id, due_date, updated_at showing the relationship between orders and wallets.

[Assistant] SELECT *, wallets.due_date, wallets.updated_at FROM tradingplatform.orders JOIN tradingplatform.wallets ON orders.wallet_id = wallets.id;

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

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


[User] Retrieve all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

[User] Sort the results by delivery_status descending.

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

[User] Sort the results by id ascending.

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


[User] Get all orders.

[Assistant] SELECT * FROM tradingplatform.orders;

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

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

[User] Sort the results by payment_method ascending.

[Assistant] SELECT * FROM tradingplatform.orders WHERE updated_at BETWEEN '2023-01-01' AND '2023-03-31' ORDER BY payment_method 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 banking.payments (
  transaction_id text PRIMARY KEY -- unique identifier,
  created_at date,
  payment_date timestamp,
  invoice_number char,
  currency text,
  exchange_rate char,
  verification_status char,
  description char,
  booking_id text NOT NULL -- reference to bookings.order_id,
  FOREIGN KEY (booking_id) REFERENCES bookings(order_id)
)

CREATE TABLE banking.students (
  person_id text PRIMARY KEY -- unique identifier,
  joined_at date,
  created_at timestamp,
  website character varying(64),
  is_verified boolean NOT NULL,
  gender char NOT NULL,
  membership_level character varying(256) NOT NULL,
  account_status character varying(128) NOT NULL,
  api_key char NOT NULL,
  last_name varchar NOT NULL,
  booking_id text -- reference to bookings.order_id,
  FOREIGN KEY (booking_id) REFERENCES bookings(order_id)
)

CREATE TABLE banking.bookings (
  order_id text PRIMARY KEY -- unique identifier,
  traded_at date,
  processed_at timestamp,
  approval_status character varying(256) NOT NULL,
  tax bigint NOT NULL,
  product_id character varying(256) NOT NULL -- identifier for product,
  payment_method character varying(64) NOT NULL,
  status varchar,
  student_id text -- reference to students.person_id,
  FOREIGN KEY (student_id) REFERENCES students(person_id)
)

[User] Get all payments.

[Assistant] SELECT * FROM banking.payments;

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

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

[User] Get sum of payment_date by invoice_number from payments.

[Assistant] SELECT invoice_number, SUM(payment_date) AS sum_payment_date FROM banking.payments GROUP BY invoice_number;


[User] Get booking_id, payment_date, created_at from all payments.

[Assistant] SELECT booking_id, payment_date, created_at FROM banking.payments;

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

[Assistant] SELECT booking_id, payment_date, created_at FROM banking.payments WHERE description LIKE 'A%';

[User] Show the results sorted by exchange_rate ascending.

[Assistant] SELECT booking_id, payment_date, created_at FROM banking.payments WHERE description LIKE 'A%' ORDER BY exchange_rate ASC;


[User] Show me processed_at, approval_status, tax for all bookings.

[Assistant] SELECT processed_at, approval_status, tax FROM banking.bookings;

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

[Assistant] SELECT processed_at, approval_status, tax FROM banking.bookings WHERE payment_method LIKE 'A%';

[User] Calculate count of product_id for each processed_at in bookings.

[Assistant] SELECT processed_at, COUNT(product_id) AS count_product_id FROM banking.bookings GROUP BY processed_at;


[User] Display all students.

[Assistant] SELECT * FROM banking.students;

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

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

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

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


[User] Get all bookings.

[Assistant] SELECT * FROM banking.bookings;

[User] Get status, student_id, last_name, gender by joining bookings with students.

[Assistant] SELECT *, students.last_name, students.gender FROM banking.bookings JOIN banking.students ON bookings.student_id = students.person_id;

[User] Return just 25 rows.

[Assistant] SELECT *, students.last_name, students.gender FROM banking.bookings JOIN banking.students ON bookings.student_id = students.person_id LIMIT 25;


[User] Get all bookings.

[Assistant] SELECT * FROM banking.bookings;

[User] Get payment_method, status, last_name, is_verified by joining bookings with students.

[Assistant] SELECT *, students.last_name, students.is_verified FROM banking.bookings JOIN banking.students ON bookings.student_id = students.person_id;

[User] Get the distribution of bookings across different tax values.

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


[User] Retrieve all bookings.

[Assistant] SELECT * FROM banking.bookings;

[User] Can you order these by traded_at ascending?

[Assistant] SELECT * FROM banking.bookings ORDER BY traded_at ASC;

[User] Only show the top 50 results.

[Assistant] SELECT * FROM banking.bookings ORDER BY traded_at ASC LIMIT 50;


[User] Display all students.

[Assistant] SELECT * FROM banking.students;

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

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

[User] Sort the results by last_name descending.

[Assistant] SELECT * FROM banking.students WHERE api_key LIKE 'A%' ORDER BY last_name DESC;


[User] Retrieve traded_at, processed_at, student_id for every booking.

[Assistant] SELECT traded_at, processed_at, student_id FROM banking.bookings;

[User] Order the output by payment_method ascending.

[Assistant] SELECT traded_at, processed_at, student_id FROM banking.bookings ORDER BY payment_method ASC;

[User] Show me average of status grouped by student_id for bookings.

[Assistant] SELECT student_id, AVERAGE(status) AS average_status FROM banking.bookings GROUP BY student_id;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.users (
  id varchar PRIMARY KEY -- unique identifier,
  joined_at date,
  last_active timestamp without time zone,
  full_name char,
  display_name character varying(256),
  avatar text,
  first_name char,
  city char,
  log_id text -- reference to logs.user_id,
  FOREIGN KEY (log_id) REFERENCES logs(user_id)
)

CREATE TABLE tradingplatform.wallets (
  id varchar PRIMARY KEY -- unique identifier,
  payment_date date,
  invoice_number char NOT NULL,
  description character varying(64) NOT NULL,
  balance bigint,
  credit character varying(128),
  verification_status char,
  amount bigint,
  debit varchar,
  user_id text -- reference to users.id,
  FOREIGN KEY (user_id) REFERENCES users(id)
)

CREATE TABLE tradingplatform.logs (
  user_id text PRIMARY KEY -- unique identifier,
  updated_at timestamp without time zone,
  website character varying(64),
  avatar varchar NOT NULL,
  password_hash character varying(128),
  wallet_id text NOT NULL -- reference to wallets.id,
  FOREIGN KEY (wallet_id) REFERENCES wallets(id)
)

[User] Get all wallets.

[Assistant] SELECT * FROM tradingplatform.wallets;

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

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

[User] Limit the results to 25 rows.

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


[User] Display all logs.

[Assistant] SELECT * FROM tradingplatform.logs;

[User] Sort the results by website descending.

[Assistant] SELECT * FROM tradingplatform.logs ORDER BY website DESC;

[User] Show me count of password_hash grouped by updated_at for logs.

[Assistant] SELECT updated_at, COUNT(password_hash) AS count_password_hash FROM tradingplatform.logs GROUP BY updated_at;


[User] Retrieve wallet_id, updated_at, website for every log.

[Assistant] SELECT wallet_id, updated_at, website FROM tradingplatform.logs;

[User] Show the results sorted by avatar ascending.

[Assistant] SELECT wallet_id, updated_at, website FROM tradingplatform.logs ORDER BY avatar ASC;

[User] Tally up logs by wallet_id.

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


[User] List all users.

[Assistant] SELECT * FROM tradingplatform.users;

[User] Sort the results by full_name descending.

[Assistant] SELECT * FROM tradingplatform.users ORDER BY full_name DESC;

[User] Return just 5 rows.

[Assistant] SELECT * FROM tradingplatform.users ORDER BY full_name DESC LIMIT 5;


[User] What are the balance, description, credit of each wallet?

[Assistant] SELECT balance, description, credit FROM tradingplatform.wallets;

[User] Order the output by payment_date descending.

[Assistant] SELECT balance, description, credit FROM tradingplatform.wallets ORDER BY payment_date DESC;

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

[Assistant] SELECT balance, description, credit FROM tradingplatform.wallets ORDER BY description ASC;


[User] Get joined_at, city, first_name from all users.

[Assistant] SELECT joined_at, city, first_name FROM tradingplatform.users;

[User] Show me users that were from 2023.

[Assistant] SELECT joined_at, city, first_name FROM tradingplatform.users WHERE last_active BETWEEN '2023-01-01' AND '2023-12-31';

[User] Get sum of log_id by avatar from users.

[Assistant] SELECT avatar, SUM(log_id) AS sum_log_id FROM tradingplatform.users GROUP BY avatar;


[User] List verification_status, description, debit from wallets.

[Assistant] SELECT verification_status, description, debit FROM tradingplatform.wallets;

[User] Find wallets modified within the last hour.

[Assistant] SELECT verification_status, description, debit FROM tradingplatform.wallets WHERE payment_date >= CURRENT_TIMESTAMP - INTERVAL '1 hour';

[User] What is the sum invoice_number for each user_id in wallets?

[Assistant] SELECT user_id, SUM(invoice_number) AS sum_invoice_number FROM tradingplatform.wallets GROUP BY user_id;


[User] Show me password_hash, avatar, updated_at for all logs.

[Assistant] SELECT password_hash, avatar, updated_at FROM tradingplatform.logs;

[User] Can you order these by wallet_id descending?

[Assistant] SELECT password_hash, avatar, updated_at FROM tradingplatform.logs ORDER BY wallet_id DESC;

[User] Tally up logs by password_hash.

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


[User] Get last_active, joined_at, display_name from all users.

[Assistant] SELECT last_active, joined_at, display_name FROM tradingplatform.users;

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

[Assistant] SELECT last_active, joined_at, display_name FROM tradingplatform.users WHERE joined_at >= CURRENT_DATE - INTERVAL '30 days';

[User] Show me max of avatar grouped by joined_at for users.

[Assistant] SELECT joined_at, MAX(avatar) AS max_avatar FROM tradingplatform.users GROUP BY joined_at;


[User] What are the updated_at, website, password_hash of each log?

[Assistant] SELECT updated_at, website, password_hash FROM tradingplatform.logs;

[User] List website, updated_at, verification_status, invoice_number for each log along with their wallet information.

[Assistant] SELECT updated_at, website, password_hash, wallets.verification_status, wallets.invoice_number FROM tradingplatform.logs JOIN tradingplatform.wallets ON logs.wallet_id = wallets.id;

[User] Show me sum of password_hash grouped by website for logs.

[Assistant] SELECT website, SUM(password_hash) AS sum_password_hash FROM tradingplatform.logs GROUP BY website;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE tradingplatform.assets (
  barcode varchar PRIMARY KEY -- unique identifier,
  published_at date,
  expires_at timestamp without time zone,
  description text NOT NULL,
  media_url character varying(64),
  image_url varchar NOT NULL,
  stock_level char NOT NULL,
  views varchar,
  featured_rank character varying(128),
  trade_id text NOT NULL -- reference to trades.id,
  FOREIGN KEY (trade_id) REFERENCES trades(id)
)

CREATE TABLE tradingplatform.trades (
  id text PRIMARY KEY -- unique identifier,
  created_at date,
  subtotal integer,
  product_id character varying(256) -- identifier for product,
  quantity varchar,
  user_id character varying(64) NOT NULL
)

CREATE TABLE tradingplatform.wallets (
  payment_id integer PRIMARY KEY -- unique identifier,
  payment_date date,
  updated_at timestamp without time zone,
  approval_status character varying(128),
  notes character varying(256),
  payee_id character varying(128) NOT NULL,
  asset_id text -- reference to assets.barcode,
  FOREIGN KEY (asset_id) REFERENCES assets(barcode)
)

[User] Retrieve all assets.

[Assistant] SELECT * FROM tradingplatform.assets;

[User] Can you order these by description ascending?

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

[User] Sort the results by featured_rank descending.

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