TRICKY SQL Interview Question | SQL Intermediate Question 20

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

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

  • @snehithasingam9918
    @snehithasingam9918 6 месяцев назад +2

    explanation 👌

  • @MusicalShorts-hn1px
    @MusicalShorts-hn1px 6 месяцев назад

    Thanks for posting the problem along with data set

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

    select top 1 txnmonth, (clothing+electronics+sports) AS amount
    from eshop
    ORDER BY amount DESC;

  • @saib7231
    @saib7231 5 месяцев назад

    Select taxmonth, sum(cast(clothing as int)+cast(electronics as int)+cast(sports as int)) as total_sales
    From eshop
    Group by taxmonth
    order by total_sales desc
    limit 1
    this als works

  • @harshkumargupta1348
    @harshkumargupta1348 6 месяцев назад

    Cant we do this
    Select taxmonth, Max(clothing+electronics+sports)
    From eshop
    Group by 1

    • @saib7231
      @saib7231 5 месяцев назад +1

      no this is syntax wise all
      instead you can use this
      Select taxmonth, sum(cast(clothing as int)+cast(electronics as int)+cast(sports as int)) as total_sales
      From eshop
      Group by taxmonth
      order by total_sales desc
      limit 1