amazon logo
Amazon· BIE 1

Amazon BIE 1 interview SQL question and answer

Posted
7 Apr 2025
258 reads

Summary

I had an interview for a BIE 1 role at Amazon where I was asked two specific SQL questions, which I have provided along with my answers.

How it went

Question 1

month            revenue
2001-01-01         650
2001-02-01        1200
2001-03-01         100
2001-04-01        1100
.
.
.
.2020-12-01       5000

Write SQL query to get the running total of the revenue to get below desired output: With Year and revenue and running total of revenue

Answer

SELECT 
    YEAR(month) AS Year,
    Revenue,
    SUM(revenue) OVER (ORDER BY YEAR(month)) AS Running_Total
FROM Table
ORDER BY YEAR(month);

Question 2

Given EMPLOYEES table with 3 columns: EMPLID, EMP_NAME, SUPERVISOR_ID.

Write a query to return the following columns for every employee: name of the employee and name of the employee's supervisor.

Answer

SELECT E.EMP_NAME,
        S.EMP_NAME
FROM EMPLOYEES E
LEFT JOIN EMPLOYEES S
 ON E.SUPERVISOR_ID = S.EMPLID;

Questions asked (2)

  1. 01

    SQL Running Total of Revenue by Year

    Other

    Given a table with month and revenue columns:

    month            revenue
    2001-01-01         650
    2001-02-01        1200
    2001-03-01         100
    2001-04-01        1100
    .
    .
    .
    .2020-12-01       5000
    

    Write an SQL query to get the running total of the revenue, displaying Year, Revenue, and Running_Total.

  2. 02

    SQL Self-Join for Employee and Supervisor Names

    Other

    Given an EMPLOYEES table with three columns: EMPLID, EMP_NAME, SUPERVISOR_ID.

    Write a query to return the following columns for every employee: the name of the employee and the name of the employee's supervisor.

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Amazon recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!