SQL Query | How to calculate YTD and MTD totals | Window Functions

preview_player
Показать описание
This video discusses the SQL Query to calculate the YTD and MTD Totals.
It also discusses the importance of window framing in SQL.

Please do not forget to like, subscribe and share.

For enrolling and enquiries, please contact us at
Рекомендации по теме
Комментарии
Автор

Register at the below link to get US $100 off for Coursera Plus membership between Sep 8 - Sep 29, 2022.
The Coursera Plus membership gets you access to unlimited courses and unlimited certifications!

LearnatKnowstar
Автор

Hello mam,
🤔🤔I having a doubt here !!
you told that when calculating YTD / MTD we need to order it by unique column like (order_id),
but it's important to clarify that using order_id for ordering within each year's partition may not guarantee the correct chronological order of orders within that year. If order_id is assigned arbitrarily or does not correspond to the actual date and time of the order, it can lead to inaccurate YTD calculations.
so I think the best way is to order it by order_date instead of order_id.

by the way your explanation is really outstanding 👍👍

Mahesh-sgxz
Автор

Awesome video! This is really helpful for me. Thanks a ton. Keep doing these type of videos more and more.!

rajasekharareddy
Автор

Great explanation. I am using SAP HANA to achieve this, unfortunately, it doesn't allow ROWS or Range Function even though it allows lots of Window Function.

arpitshivhare
Автор

Great way of explanation of whole concept, Thanks for this.

jaideepchauhan
Автор

Hey, Nice video

One qsn, how do u decide/calculate current row in framing?

allaboutdata
Автор

Really good explanation!!!! I love this video

naynayne
Автор

you read my mind or sentiments lol, THANX!

AK-Star
Автор

plz add query for previous year ytd in next column
YTD YTDprevious

AK-Star
Автор

What if we add SalesOrderNumber to order by, does that works the same as adding a ROWS BETWEEN?

lingxu
Автор

Can you write a query of interest projection of daily amount deposit in account but amount is not equal daily

anitamartolia
Автор

Is not the Salesorder number different that has the same order date ? How is that duplicate .. what is the unique row definition there.. could you please elaborate ?

deeppokhrel
Автор

what is the way to handle null values or missing months in windows function

trinadhravada
Автор

I want to make balance as 0 if it ends in negative value, how can I do?? Pls reply

dhinesh
Автор

How to get the database for each and every query your sharing

DeepakPrabhu-ubth
Автор

@2:45 Order by is not mandatory if over clause is there. if order by is not there, we get total sum without any windowing.

sowmithrivinayparavastu
Автор

Can you pls help us to calculate year to month end ?

JupyterBA
Автор

Nice one but plz share sql script to practice

jaitiwari
Автор

Very well explained the window frame options. Waiting for your next video!

kristyowens
Автор

Nicely explained. Keep up the good work

hv