Hi. What if i want to set to null the moving average with not enough rows... Like in your example the first two rows?
@LearnatKnowstar2 жыл бұрын
This is a great question. Thank you for mentioning this scenario. You can use RowNumber function to calculate the Row Numbers and start the calculation only from the 3rd row. You can use CASE or IFF to perform this check - Please see example below - IIF(ROW_NUMBER() OVER(PARTITION BY FA.CurrencyKey ORDER BY DateKey)>=3,AVG(EndofDayRate) OVER (PARTITION BY FA.CurrencyKey ORDER BY DateKey ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) , NULL) AS _3DAYROLLINGAVG
@terryh5582 жыл бұрын
Good job on your videos. I keep looking for more! As to the Moving Average of a Stock or Currency a) it should not start computing anything until you have number of days = moving average length, b) you do NOT want to fill in missing dates because (barring data errors) those are days when the market is closed like Sat/Sun/Holidays. Those days are just ignored. We could row_number the data, oldest data first, and use that to put NULL into the first 13 days if your MA length = 14. I seem to recall seeing a graphing feature in SSMS. If so, I'd like to see how to put this same data into a graph.
@LearnatKnowstar2 жыл бұрын
Thank you for sharing this. These insights really help all of us learn and grow. 👍
@payalia08 Жыл бұрын
Just got this task for my job thanks in advance😄
@LearnatKnowstar Жыл бұрын
Hope it helped
@vpnath752 жыл бұрын
Very informative! I would also be interested in seeing an explanation for the exponential moving average. Thanks!
@LearnatKnowstar2 жыл бұрын
Thank you. We will posting the video in exponential rolling average soon 👍
@aduvalasatheeshkumar48402 жыл бұрын
Great Explanation...! Can you tell me a logic to get the previous row value if the curent row field is empty. Thanks ...!
@LearnatKnowstar2 жыл бұрын
Thank you. You can get previous rows with lag function. If the row is entirely missing, you would first need to create a dummy record for the missing row.
@samuelfsdev2 жыл бұрын
It's a greate content! These videos reawaken my interest in database management.
@LearnatKnowstar2 жыл бұрын
Glad these are useful. Thanks 🙏
@diydecor26532 жыл бұрын
Simple and easy to understand
@LearnatKnowstar2 жыл бұрын
Thank you 🙏
@VinayKumar-lb3lq2 жыл бұрын
Hi, can u pls make videos on recursive querys from start to end.
@LearnatKnowstar2 жыл бұрын
Yes sure. We are planning a series on SQL/DB concepts soon and these topics will be covered there. 👍