SQL tricky Complex Query | (Reset Running Total When negative) / (Reset based on column value)
Вставка
- Опубліковано 14 жов 2024
- In this tutorial, we discuss two tricky scenarios and write SQL Complex Queries to reset running total.
Scenario 1 - Reset when running total is negative
Scenario 2 - Reset based on a column value
The practice data and SQL statements are available here -
know-star.blogs...
Stackoverflow post for related approach -
stackoverflow....
How to calculate running total?
• SQL Query | How to cal...
How to install SQL Server for practice?
• How to install SQL Ser...
Check out the complete list of SQL Query Interview Questions -
• SQL Query Interview Qu...
Best Data Science / Analytics / SQL courses
Learn SQL Basics for Data Science Specialization
imp.i384100.ne...
Beginners to Python Programming
skillshare.eqc...
Data Science and Business Analytics with Python
skillshare.eqc...
Get 40% OFF of Skillshare with code FLASH40 - October 2022
skillshare.eqc...
Data Science Fundamentals with Python and SQL Specialization
imp.i384100.ne...
Python for Everybody Specialization
imp.i384100.ne...
Google Data Analytics Professional Certificate
imp.i384100.ne...
Coursera Plus - Data Science Career Skills
imp.i384100.ne...
Please do not forget to like, subscribe and share.
For enrolling and enquiries, please contact us at
Website - knowstar.org/
Instagram - / learn.knowstar
Facebook - / knowstartrainings
Linkedin - www.linkedin.c...
Email - learn@knowstar.org
Thank you SO much. Searched the entire internet for this solution..
Glad it was helpful
wowwww, i love you! I'm from Brazil and i didn't sleep trying to do this!!! THANK YOU!!!!!!!
Thank you so much for your kind words.
These scenarios are very helpful in real life computations. Please share more such scenarios.
Thank you
Your video is super ... I am struggling since 10 days for this concept but you solved it
Glad it was helpful.
This is a nice complex scenario. Thanks for sharing.
Thank you
Nice explantion
Thank You
Very good topic. Thanks.
🙏
Super explanation...
Glad it was helpful 🙏
Nice explanation 👌 👍 👏
🙏
thank you
Thank you for your support
I was asked a question where I have to show only those product_id, product_name where there a constant growth in sales_amount each year. If there is a decline in sales in any year, it shouldn't be included in the output. Let's say the data is from 2011 to 2021. Need to know the approach for this question.
You can first calculate the YoY growth for each product in a CTE. Then you can filter on products for which there is a negative growth in any of the years.
In the last step, Select all products where product NOT IN ( the products returned in the negative growth scenario)
Can you please help me