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

Publicado el: 04 agosto 2024
en el 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


En esta página del sitio puede ver el video en línea Window FRAMES in SQL | Difference in ROWS and RANGE | SQL Intermediate Level Interview Question de Duración hora minuto segunda en buena calidad , que subió el usuario Select Star 04 agosto 2024, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 4,310 veces y le gustó 105 a los espectadores. Disfruta viendo!