SQL tricky Complex Query | (Reset Running Total When negative) / (Reset based on column value)

Поделиться
HTML-код
  • Опубликовано: 26 сен 2022
  • 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.blogspot.com/2022/09...
    Stackoverflow post for related approach -
    stackoverflow.com/questions/2...
    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.net/qnXYk5
    Beginners to Python Programming
    skillshare.eqcm.net/GjMakm
    Data Science and Business Analytics with Python
    skillshare.eqcm.net/JrM1Aq
    Get 40% OFF of Skillshare with code FLASH40 - October 2022
    skillshare.eqcm.net/c/3299742...
    Data Science Fundamentals with Python and SQL Specialization
    imp.i384100.net/mgVYre
    Python for Everybody Specialization
    imp.i384100.net/DVz7Aj
    Google Data Analytics Professional Certificate
    imp.i384100.net/OR37oQ
    Coursera Plus - Data Science Career Skills
    imp.i384100.net/c/3299742/132...
    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.com/company/know...
    Email - learn@knowstar.org

Комментарии • 23

  • @jockharkness507
    @jockharkness507 3 месяца назад +1

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

  • @designanddecor8964
    @designanddecor8964 Год назад +2

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

  • @kristyowens2284
    @kristyowens2284 Год назад +2

    This is a nice complex scenario. Thanks for sharing.

  • @user-mu1mk3ub6s
    @user-mu1mk3ub6s 6 месяцев назад

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

  • @fatorx495
    @fatorx495 Год назад

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

  • @hv0032113
    @hv0032113 Год назад

    Very good topic. Thanks.

  • @ganeshreddymotakatla6244
    @ganeshreddymotakatla6244 Год назад

    Super explanation...

  • @sravankumar1767
    @sravankumar1767 Год назад

    Nice explanation 👌 👍 👏

  • @harshalpatel3012
    @harshalpatel3012 Год назад

    Nice explantion

  • @fatorx495
    @fatorx495 Год назад

    thank you

  • @riddlex
    @riddlex Год назад

    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