Window FRAMES in SQL | Difference in ROWS and RANGE | SQL Intermediate Level Interview Question

Publicado em: 04 Agosto 2024
no canal de: Select Star
4,310
105

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


Nesta página do site você pode assistir ao vídeo on-line Window FRAMES in SQL | Difference in ROWS and RANGE | SQL Intermediate Level Interview Question duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Select Star 04 Agosto 2024, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 4,310 vezes e gostou 105 espectadores. Boa visualização!