Use Window Frames Like a PRO | SQL Intermediate Level Question

Veröffentlicht am: 10 August 2024
auf dem Kanal: Select Star
168
12

Namastey All,

Welcome to Select Star. Today I am solving a medium level interview question.

We have been provided monthly sales and we are required to find :
1. Amount for the month
2. Total SUM till last month
3. Percentage

Topics covered :

1. Window Function SUM (RUNNING SUM)

2. Window Frames : ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING

3. GROUP BY

4. Aggregate function : SUM

5. OVER clause

6. ORDER BY

7. How to avoid LAG window function

8. COALESCE function

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 Transactions (TransactionDate DATE, Amount int);

INSERT INTO Transactions VALUES
('2023-01-01', 15000),
('2023-01-15', 17000),
('2023-02-08', 18000),
('2023-02-25', 20000),
('2023-02-28', 21000),
('2023-03-15', 24000),
('2023-04-10', 25000),
('2023-04-15', 30000),
('2023-05-01', 25500),
('2023-05-12', 20500),
('2023-05-18', 30500),
('2023-06-15', 31500),
('2023-07-01', 40500),
('2023-07-21', 45500),
('2023-08-15', 50500),
('2023-08-25', 30500),
('2023-09-29', 28000),
('2023-09-30', 78000),
('2023-10-01', 44000),
('2023-10-12', 66000),
('2023-10-15', 27000),
('2023-11-13', 57000),
('2023-12-01', 15000),
('2023-12-13', 24000);

select * from Transactions;

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


Auf dieser Seite können Sie das Online-Video Use Window Frames Like a PRO | SQL Intermediate Level Question mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Select Star 10 August 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 168 Mal angesehen und es wurde von 12 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!