How To Write SQL Server Queries Correctly: Case Expressions

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

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

  • @corykeilig5183
    @corykeilig5183 2 дня назад +1

    Erik is a genius !

  • @MercyFromOverwatch2
    @MercyFromOverwatch2 3 дня назад +4

    Happy new year keric

  • @CindyofTheShire
    @CindyofTheShire 3 дня назад +1

    How did i never realize this and it was in front of my face 🤦‍♀️. I am loving this series btw.

    • @ErikDarlingData
      @ErikDarlingData  3 дня назад

      Awesome! Glad you’re enjoying it! Hopefully no surgery required.

    • @CollinReinking
      @CollinReinking 2 дня назад

      this series is great.

  • @BrandonChampion
    @BrandonChampion 3 дня назад +1

    Most of the other database engines have procedure languages that include CASE STATEMENTS (a version of IF / ELSE control flow statements), but I really wish they didn't. Every time I've seen one in the wild it's a mess to comprehend and maintain.

    • @ErikDarlingData
      @ErikDarlingData  2 дня назад

      Well, are you talking about SWITCH style statements or something else? I'd be curious of they have similar short circuit oddities.

  • @vasylpavuk391
    @vasylpavuk391 3 дня назад +1

    Thank you for the nice article. But I saw even worse:
    join predicates with a "case" statement and table rows are joined (or not) based on the result of the "when" condition 😋that contains variables and column names

    • @ErikDarlingData
      @ErikDarlingData  3 дня назад +1

      That is bad yes. One might wonder just how much can be tolerated.

  • @AttilaJakusovszky
    @AttilaJakusovszky 3 дня назад +1

    Thanks for explaining and giving a fix too.
    I have a question, you mentioned earlier that partitioning tables are not giving performance boost as expected. What do you suggest, how can I iterate a big table over? When preparing data from it, the whole table can easily fill the temp tablespace, that is why I needed to put row numbers on it. I create a temp table containing PK and I row numbers, and joining that back to the original table to iterate over it. But that looks like an overkill.

    • @ErikDarlingData
      @ErikDarlingData  2 дня назад

      I don't really understand the question here. Iterating over a table to do what?

  • @FlaggedStar
    @FlaggedStar 3 дня назад +2

    Erik always tells us to not look into the armpit. He's fooling us. Under the armpit is the source of his power! True SQL ability is but a sniff away!