No video

SQL Query | Compare monthly sales with previous month, same month previous year, first month of year

  Рет қаралды 49,818

Learn at Knowstar

Learn at Knowstar

Күн бұрын

In this video, we write a SQL to compare monthly sales -
1) With previous month
2) same month previous year
3) first month of year
Check out the complete list of SQL Query Interview Questions -
• SQL Query Interview Qu...
Please do not forget to like, subscribe and share.
For enrolling and enquiries, please contact us at
Website - knowstar.org/
Facebook - / knowstartrainings
Linkedin - www.linkedin.c...
Email - learn@knowstar.org

Пікірлер: 64
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Are you interested in attending an online SQL training course? We have received a few inquiries and are now planning one on 18 and 19 September 2021. This will be a 10 hours instructor led training covering SQL concepts as well as practical SQL query writing. The training cost is USD 100. If you are interested, please register here - forms.gle/y2U2eKmShq6JUnc29 Thank you 🙂
@mihirforyou3531
@mihirforyou3531 3 жыл бұрын
Mam what are the topics will be covered?
@NareskanthM
@NareskanthM Ай бұрын
thanks sister ! very easy to understand !
@LearnatKnowstar
@LearnatKnowstar 18 күн бұрын
Glad it was helpful!
@tlubaina
@tlubaina 2 жыл бұрын
You just saved my semester! Thanks
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Thank you
@chandudevarapu1578
@chandudevarapu1578 3 жыл бұрын
Thank you mam... Nice explained pls upload more videos like that... I will refer my friends also this type of scenarios very useful for us
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thanks so much. Do make sure that you and your friends subscribe to the channel 🙂
@surajpatil3579
@surajpatil3579 2 жыл бұрын
Thanks mam, splendid explanation keep making content like this!!
@NareskanthM
@NareskanthM 2 ай бұрын
Great Explanation !
@mummz3371
@mummz3371 2 жыл бұрын
I love watching your content because of the practical examples you use, thank you ❤️
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Thank you
@MokshDrar
@MokshDrar Жыл бұрын
@@LearnatKnowstar Thanks maam you are very smart
@pravinm1490
@pravinm1490 10 ай бұрын
very nicely explained
@LearnatKnowstar
@LearnatKnowstar 10 ай бұрын
Thank you so much 🙂
@deepthimurali962
@deepthimurali962 Жыл бұрын
Can you suggest how to use lag and offset if we want to compare Jan-Feb 2022 vs Jan-Feb 2023. I basically want to sum both jan and feb and compare the growth Thanks for this!
@mihirforyou3531
@mihirforyou3531 3 жыл бұрын
Thank you Mam ... very useful.. nicely explained ☺️
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you so much!
@jashanpreetsingh4750
@jashanpreetsingh4750 2 жыл бұрын
Thanks a lot . Exactly solved the query i was having.
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Thank you 🙏
@pravinm1490
@pravinm1490 10 ай бұрын
Nicely explained
@LearnatKnowstar
@LearnatKnowstar 10 ай бұрын
Thank you so much 🙂
@saktibiswal6445
@saktibiswal6445 Жыл бұрын
Awesome explanation of LAG & OFFSET. Thanks!!
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Glad it was helpful!
@ajeshrajan8079
@ajeshrajan8079 Жыл бұрын
Good explanation
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Thank you
@brianducharme3418
@brianducharme3418 2 жыл бұрын
Thank you so very much!!
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Glad it helped!
@nikolaybaranov2213
@nikolaybaranov2213 2 жыл бұрын
Great explanation of how window functions work!
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Thank you
@Regc10
@Regc10 Жыл бұрын
This is amazing helped me alot.
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Glad it was helpful.
@thatssodinesh7857
@thatssodinesh7857 Жыл бұрын
You're great! Thank you so much
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Thank you!
@BGK8
@BGK8 3 жыл бұрын
Excellent video series. Take a bow!! Could you please make something like this in Stored procs, performance tuning concepts
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thanks so much. Sure, we will be posting videos on advanced topics in near future.
@kesavanandt1195
@kesavanandt1195 2 жыл бұрын
Good explanation madam...thank you very much. And mam, what modification is to be done in this query to get the next month sales.??
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Thank you. You can use the LEAD function instead of the LAG function
@pupu41784
@pupu41784 2 жыл бұрын
Thank you so much. I needed this! :D
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Glad it was helpful.
@jadeldeek5100
@jadeldeek5100 2 жыл бұрын
is possible to have monthly figures or yearly figures by columns not by row as your example? YEAR 1, YEAR 2 OR JAN, FEB , MARS ....
@Tech2BI
@Tech2BI 3 жыл бұрын
As long as it's 2017 or higher versions we have functions for the same scenarios for previous versions like 2012 or 2008 r2 do you have any solution for this?
@satyapalrawat7857
@satyapalrawat7857 Жыл бұрын
Hi - this is very helpful. But what if there is a month missing in the last year data ?
@oladman9058
@oladman9058 11 ай бұрын
Wow!
@jonnybrooks97
@jonnybrooks97 Жыл бұрын
How can you drill down into specific columns with this, for example if you wanted to look at month on month changes for each store or region?
@tigerdataimarticus7088
@tigerdataimarticus7088 2 жыл бұрын
I have a query: if current month total production from 1st date to current date then how can we calculate previous month production total with current month date range
@sivachaitanya6330
@sivachaitanya6330 Жыл бұрын
month(date) inside lag() function is throwing error says month should not be here in mysql ................what is the solution.........lag(sum(amount),Month(date))-------------->ERRor?????????????????
@balamuralibattala3283
@balamuralibattala3283 Жыл бұрын
Hi everyone,How to find the company that has growth in three successive years.pls provide solution for it
@rohitwaregaonkar3703
@rohitwaregaonkar3703 Жыл бұрын
Write a stored procedure that accepts the month and year as inputs Please help
@ankurranjan3218
@ankurranjan3218 2 жыл бұрын
Let suppose Data does not have consecutive months data. For example I am having 2020-01 and 2020-06 data only then If I am comparing with previous month using LAG then it will not be correct, right? As it will compare June from Jan but I wanted to compare only June from May. How to proceed for this type of scenrio.
@pranavnair8977
@pranavnair8977 2 жыл бұрын
use cross join
@arfathth5176
@arfathth5176 2 жыл бұрын
Can i know the recommended on other customer sql query
@vinaymaddi4801
@vinaymaddi4801 2 жыл бұрын
Can anyone explain the last scenario month(orderdate)-1 is taken for offset. How is that.
@vinayv1940
@vinayv1940 2 жыл бұрын
Hi , How about compare day wise sales with previous year day wise sales. ie; compare 29/9/2021 to 29/9/2022
@pradeepvaka2545
@pradeepvaka2545 2 жыл бұрын
In the offset use year instead of month Lag(sum(sales) , year(orderdate))
@gowthamev8745
@gowthamev8745 2 жыл бұрын
How to calculate interview in sql for example:- customer placed an order, we have to find the customer who placed an order more than 1 within 7 days
@gelectiusdroid4147
@gelectiusdroid4147 2 жыл бұрын
I can tell you
@advancewebdevelopment9802
@advancewebdevelopment9802 Жыл бұрын
There are 897 days in query. How to get results by year months days in same query
@gmocore
@gmocore 2 жыл бұрын
tnks !!! I
@ganeshkharad
@ganeshkharad 2 жыл бұрын
why use lag??? what if the data for a few months in a year are absent ???
@RAJUBHAI-ww7em
@RAJUBHAI-ww7em 9 ай бұрын
Yeah that's my issue too
@smritichauhan6006
@smritichauhan6006 8 ай бұрын
such a ridiculous way of teaching
Just Give me my Money!
00:18
GL Show Russian
Рет қаралды 685 М.
Get 10 Mega Boxes OR 60 Starr Drops!!
01:39
Brawl Stars
Рет қаралды 19 МЛН
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 3,8 МЛН
Learn SQL + Database Concepts in 20 Minutes
24:34
Chandoo
Рет қаралды 51 М.
SQL Query | How to calculate YTD and MTD totals | Window Functions
16:01
Learn at Knowstar
Рет қаралды 41 М.
SQL Query | How to find Maximum of multiple columns | Values
8:00
Learn at Knowstar
Рет қаралды 112 М.
SQL performance tuning and query optimization using execution plan
49:23
Just Give me my Money!
00:18
GL Show Russian
Рет қаралды 685 М.