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

КОМЕНТАРІ • 23

  • @hbautomation-io
    @hbautomation-io 6 місяців тому +1

    Thank you SO much. Searched the entire internet for this solution..

  • @fatorx495
    @fatorx495 Рік тому

    wowwww, i love you! I'm from Brazil and i didn't sleep trying to do this!!! THANK YOU!!!!!!!

  • @designanddecor8964
    @designanddecor8964 2 роки тому +2

    These scenarios are very helpful in real life computations. Please share more such scenarios.

  • @RanjayKumarSingh-x8l
    @RanjayKumarSingh-x8l 9 місяців тому

    Your video is super ... I am struggling since 10 days for this concept but you solved it

  • @kristyowens2284
    @kristyowens2284 2 роки тому +2

    This is a nice complex scenario. Thanks for sharing.

  • @harshalpatel3012
    @harshalpatel3012 Рік тому

    Nice explantion

  • @hv0032113
    @hv0032113 2 роки тому

    Very good topic. Thanks.

  • @ganeshreddymotakatla6244
    @ganeshreddymotakatla6244 2 роки тому

    Super explanation...

  • @sravankumar1767
    @sravankumar1767 2 роки тому

    Nice explanation 👌 👍 👏

  • @fatorx495
    @fatorx495 Рік тому

    thank you

  • @riddlex
    @riddlex 2 роки тому

    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.

    • @LearnatKnowstar
      @LearnatKnowstar  Рік тому +1

      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)

  • @tusharkumbhar5051
    @tusharkumbhar5051 Рік тому

    Can you please help me