Namastey All,
Welcome to Select Star. Today I am solving a medium level interview question.
We have been provided a table (balance) and we required to find the final amount after each transaction.
Topics covered :
1. Window Function SUM, PARTITION BY and ORDER BY
2. Window Frames : Default FRAME for a SUM window function is range between unbounded preceding and current row.
3. Running SUM (SUM with OVER clause)
4. Difference between RANGE and ROWS : Range considers whatever you mention in ORDER BY clause as one frame however ROWS considers the physical position of rows as frame.
5. CASE statement inside SUM
Related Playlists:
1. Basic SQL Course :
• Basic SQL Course
2. SQL Easy Interview Questions :
• SQL Easy Interview Question
3. SQL Mediun to Hard Level Interview Questions :
• SQL Intermediate to Advanced Interview Que...
If you want me to solve some specific questions, then email me :
ananttnegii@gmail.com
Script for table creation :
create table balance (
customer char(1),
transaction_type varchar(10),
transaction_date date,
amount int);
insert into balance values
('A','Credit','2024-01-01',10000),
('A','Credit','2024-03-01',5000),
('A','Debit','2024-03-05',2000),
('B','Credit','2024-02-01',1000),
('B','Credit','2024-02-01',2000),
('B','Debit','2024-02-03',4000),
('C','Credit','2024-01-15',5000),
('C','Credit','2024-01-22',500);
select * from balance;
Happy Querying
#sql #data #dataanalytics #dataanalyst #analysis #analyst #dataengineers #dataengineering #machinelearning #datascience #datascientist #machinelearningengineer #businessanalyst #businessanalyticsjobs #businessanalytics #sqlserver #sqltips #sqlforbeginners #postgres #postgresql #mssqlserver #mssql #oracle #mysql #mysqltutorials #database #databasedesign #databasemanagement
On this page of the site you can watch the video online Window FRAMES in SQL | Difference in ROWS and RANGE | SQL Intermediate Level Interview Question with a duration of hours minute second in good quality, which was uploaded by the user Select Star 04 August 2024, share the link with friends and acquaintances, this video has already been watched 4,310 times on youtube and it was liked by 105 viewers. Enjoy your viewing!