easy

Orders Above Average Amount

You are working as a Data Engineer for a FinTech platform that processes customer transactions. The analytics team wants to identify transactions that are higher than the overall average transaction amount.

You are given the following table:

transactions

  • transaction_id (INT) – Unique identifier for each transaction

  • account_id (INT) – Identifier for the customer account

  • transaction_date (DATE) – Date of the transaction

  • amount (NUMERIC) – Transaction amount

Task:

Write a SQL query to return all transactions where the amount is greater than the average transaction amount across all transactions.

Expected Output:

  • transaction_id

  • account_id

  • amount

The result should include only transactions above the average amount.

1
2
3
4
5
Preparing...
Orders Above Average Amount

You are working as a Data Engineer for a FinTech platform that processes customer transactions. The analytics team wants to identify transactions that are higher than the overall average transaction amount . You are given the following table: transactions transaction_id (INT) – Unique identifier for each transaction account_id (INT) – Identifier for the customer account transaction_date (DATE) – Date of the transaction amount (NUMERIC) – Transaction amount Task: Write a SQL query to return all transactions where the amount is greater than the average transaction amount across all transactions . Expected Output: transaction_id account_id amount The result should include only transactions above the average amount.

Table Setup (SQL Schema)

-- DDL: Create table
CREATE TABLE transactions (
    transaction_id INT PRIMARY KEY,
    account_id INT,
    transaction_date DATE,
    amount NUMERIC
);

-- DML: Insert sample data
INSERT INTO transactions (transaction_id, account_id, transaction_date, amount) VALUES
(1, 201, '2024-01-01', 100.00),
(2, 202, '2024-01-02', 250.00),
(3, 201, '2024-01-03', 75.00),
(4, 203, '2024-01-04', 300.00),
(5, 204, '2024-01-05', 150.00),
(6, 202, '2024-01-06', 200.00),
(7, 205, '2024-01-07', 50.00),
(8, 203, '2024-01-08', 400.00),
(9, 204, '2024-01-09', 120.00),
(10, 205, '2024-01-10', 180.00);
Home Videos Quiz Blog