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 :
[ Ссылка ]
2. SQL Easy Interview Questions :
[ Ссылка ]
3. SQL Mediun to Hard Level Interview Questions :
[ Ссылка ]
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
Ещё видео!