Interview Query

Count Transactions

Have you seen this question before?

Let’s say you work at Amazon. With the annual_payments table below, answer the following three questions via SQL queries and output them as a table with the answers to each question.

  1. How many total transactions are in this table?
  2. How many different users made transactions?
  3. How many transactions listed as "paid" have an amount greater or equal to 100?
  4. Which product made the highest revenue? (use only transactions with a "paid" status)



annual_payments table

Column Type
amount FLOAT
created_at DATETIME
status VARCHAR
user_id INTEGER
amount_refunded FLOAT
product VARCHAR
last_updated DATETIME


Column Type
question_id INTEGER
answer FLOAT
Next question: Density to Cumulative
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query