LeetCode Medium 1193 Interview SQL Question with Detailed Explanation

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • Question: leetcode.com/p...
    In this video I solve and explain a medium difficulty leetcode SQL question using MySQL query. This question has been asked in Apple, Facebook, Amazon, Google, Adobe, Microsoft, Adobe interviews or what we popularly call FAANG interviews.
    I explain the related concept as well. This question includes points to keep in mind to develop SQL queries.
    LeetCode is the best platform to help you enhance your skills, expand your knowledge and prepare for technical interviews.
    If you found this helpful, Like and Subscribe to the channel for more content.
    #LeetCodeSQL #FAANG #SQLinterviewQuestions

ความคิดเห็น • 14

  • @gajendragada_dynamites
    @gajendragada_dynamites ปีที่แล้ว +5

    This is the most underrated channel of you tube in linkedin also everyone is busy in praising Sumit mittal sir only ,i will proudly say i have learnt SQL from this channel

    • @EverydayDataScience
      @EverydayDataScience  ปีที่แล้ว

      Thanks for such kind words 😊 Glad that this channel has been helpful for you.

  • @rohitbatra8396
    @rohitbatra8396 ปีที่แล้ว +1

    This is really underrated channel, I wish you get huge amount of subscribers in coming days. I am solving a lot of SQL questions now days and If I get stuck somewhere I type that leetcode number and in that search list I always choose your video to watch. Hats off :)

  • @tejaswaniguttula5961
    @tejaswaniguttula5961 4 หลายเดือนก่อน

    Thanks a lot sir.
    When i solved it by myself. I failed in test case bur with your explanation it was done ✅ sir. Thank you so much sir

    • @EverydayDataScience
      @EverydayDataScience  4 หลายเดือนก่อน

      Glad that you found the video useful 😊

  • @alfabinomial6183
    @alfabinomial6183 ปีที่แล้ว

    in your video u have taught us how to think and how to solve the problem !! best tutorial ever on Database management system !

  • @saisushanthdurvasulabitsian
    @saisushanthdurvasulabitsian 2 ปีที่แล้ว

    thank you @Everyday Data Science for the video , very useful, one small change we could do to make it compact is that we could use the month alias in the group by clause instead of repeating the year month extraction logic as follows:
    select DATE_FORMAT(trans_date,'%Y-%m') as month
    , country
    , count(id) as trans_count
    , sum(case
    when state = "approved" then 1
    else 0 end) as approved_count
    , sum(amount) as trans_total_amount
    , sum(case
    when state = "approved" then amount
    else 0 end) as approved_total_amount
    from Transactions
    group by month,country
    please review and let me know your thoughts , thanks

    • @ekosetiawan_indo
      @ekosetiawan_indo 2 ปีที่แล้ว

      hmm, what if there is data from different year but same month, will this query working?

    • @saisushanthdurvasulabitsian
      @saisushanthdurvasulabitsian 2 ปีที่แล้ว

      @@ekosetiawan_indo thanks for the question , yes we are asked to group by year_month in the question which is unique for a given month and year and we are extracting that part here and the query works! pls let me know if it dint work for you or any issue you faced , thanks

  • @rishikaverma9846
    @rishikaverma9846 9 หลายเดือนก่อน

    why does my code show this error? You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') as approved_total_amount
    from Transactions
    group by date_format(trans_date, '' at line 2
    select date_format(trans_date, '%Y-%m') as month, country,count(id) as trans_count, sum (case when state='approved' then 1 else 0 end) as approved_count, sum(amount) as trans_total_amount, sum(case when state='approved' then anount else 0) as approved_total_amount
    from Transactions
    group by date_format(trans_date, '%Y-%m'), country

    • @EverydayDataScience
      @EverydayDataScience  9 หลายเดือนก่อน

      I guess this is because you haven’t ended the case when statement. It should be:
      …, sum(case when state=‘approved’ then amount else 0 END) as approved_total_amount…..
      Try it and let me know if this works 😊

  • @manojyadav6967
    @manojyadav6967 ปีที่แล้ว

    count() only count the non-null values only.just for info

  • @sumans6033
    @sumans6033 5 หลายเดือนก่อน

    Year is not getting