youtube-transcript.ai

SQL Interview Questions and answers Part 1 | SQL Scenario based Interview Question and Answer

Watch with subtitles, summary & AI chat
Add the free Subkun extension — works directly on YouTube.
  • Watch
  • Subtitles
  • Summary
  • Ask AI
Try free →

Aspiring data analysts and SQL developers preparing for technical interviews.

TL;DR

This video explains how to solve a common SQL interview question involving calculating the maximum transaction amount per customer and the ratio of each transaction to that maximum. It demonstrates two methods: using subqueries and common table expressions (CTEs).

Key Takeaways

In This Video

  1. 00:00SQL Interview Questions Part 1

    Introduction to scenario-based SQL interview questions. Covers the first problem statement and its requirements.

  2. 00:22Transaction Table Structure

    Details of the transaction table: customer ID, transaction ID, amount, and date.

  3. 01:07Calculating Maximum Transaction Amount

    Objective is to find the maximum transaction amount per customer ID.

  4. 01:26Calculating Transaction Ratio

    Requirement to calculate the ratio of each transaction amount to the maximum for that customer.

  5. 02:14Solving with Subquery

    Explains how to use a subquery to find the maximum transaction amount and join it back.

  6. 04:21Solving with CTE

    Demonstrates solving the problem using Common Table Expressions (CTEs).

  7. 05:51Conclusion and Next Steps

    Summarizes the two techniques and encourages likes and subscriptions.

Questions & Answers

How to find max transaction amount per customer in SQL?
You can find the maximum transaction amount for each customer by using a subquery or a Common Table Expression (CTE). Group the transaction table by customer ID and select the MAX of the transaction amount.
How to calculate transaction amount ratio to max amount per customer in SQL?
After finding the maximum transaction amount per customer, join this result back to the original transaction table on customer ID. Then, calculate the ratio using the transaction amount and the maximum transaction amount.
What are the two methods to solve this SQL problem?
The problem can be solved using two methods: 1. Using a subquery. 2. Using a Common Table Expression (CTE).
Explain the subquery method for finding max transaction amount.
First, write a subquery to find the maximum transaction amount for each customer ID by grouping. Then, inner join the original transaction table with this subquery on customer ID.
Explain the CTE method for finding max transaction amount.
Create a CTE to store the main transaction table data. Then, create another CTE to find the maximum transaction amount per customer ID by grouping. Finally, join these two CTEs.
What columns are in the transaction table?
The transaction table has four columns: customer ID, transaction ID, transaction amount, and transaction date.

Key Terms

Download or copy the punctuated YouTube transcript (Markdown)

Full Transcript

Loading transcript…

Source

YouTube video. Original: https://www.youtube.com/watch?v=5F3Oa7nky64
Transcript captured and processed by youtube-transcript.ai on 2026-06-29.