SQL TUTORIAL - CTEs Part 2

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

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

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

    1. I think that @Year could be TINYINT, just like @Quarter. Minor quibble, of course.
    2. At first viewing, it is somewhat jarring to see you make errors., then have to go back and correct them later. But then we get to view the debugging process, which is also valuable.
    Thank you for posting your content. It is helpful. Keep it up, Brad!

    • @BeardedDevData
      @BeardedDevData  Год назад +1

      Could use SMALLINT but not TINYINT, range is only up to 255.

    • @houstonvanhoy2198
      @houstonvanhoy2198 Год назад +1

      @@BeardedDevData Right. Thank you. (Formerly bearded dude.)

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

    13:34 Is there a business reason or a technical reason for not writing the calculation as
    "(Total_Pay * 0.05) AS Bonus"? It obtains the same result that your version obtains. Your version is probably clearer, and easier to follow, which is probably the point. TIA.

    • @BeardedDevData
      @BeardedDevData  Год назад +1

      No, your way is perfectly fine, it's just one of those things when you look back and think, it would be less code to just to do it that way.

  • @johnconnor9787
    @johnconnor9787 5 лет назад +6

    Please, make a video on nested queries (subqueries) and co-related queries and recursive queries

  • @ashkrv123
    @ashkrv123 2 года назад +2

    YOU ARE THE BEST SIR... i wish i have a member like you in my team...great clarity in concepts..
    idk why you stopped making videos!!!

    • @BeardedDevData
      @BeardedDevData  2 года назад +3

      Thanks so much, I will actually be working on some videos this weekend that should be up next week.

  • @CaribouDataScience
    @CaribouDataScience 2 года назад +1

    It works, nested CTEs actually work:
    WITH CTE1 AS
    (
    SELECT
    CAST(AVG([Sales])as int) as company_avg
    FROM Orders
    )
    , CTE2 AS
    (
    -- Average sales by customer
    SELECT
    [Customer ID],
    CAST(AVG(Sales) as int) as customer_avg
    FROM Orders
    GROUP BY [Customer ID]
    )
    -- Which customer average sales is equal company average sales
    SELECT
    [Customer ID],
    customer_avg,
    company_avg
    FROM CTE1, CTE2
    WHERE customer_avg = company_avg;

    • @BeardedDevData
      @BeardedDevData  2 года назад +1

      Did I mention that they didn't or are you just confirming that you are using them? Your comment has just thrown me a little 🤔

    • @CaribouDataScience
      @CaribouDataScience 2 года назад +1

      @@BeardedDevData I am just confirming that you are using them. :)

    • @BeardedDevData
      @BeardedDevData  2 года назад

      Fantastic

  • @deeptigupta6251
    @deeptigupta6251 4 года назад +2

    HI Dev..
    Your videos are very informative.But there's only one problem I am facing to follow you along that is how to get this CTE dataset.

    • @BeardedDevData
      @BeardedDevData  4 года назад +1

      Hi, thanks for the comment, unfortunately I no longer have the data but you can try with a database like AdventureWorks and I will give assistance if you need it. I make sure my latest videos include code to allow viewers to follow along.

  • @houstonvanhoy7767
    @houstonvanhoy7767 Год назад +1

    Brad: We're still looking for CTEs Part 3. Recursive CTEs?
    TIA. 👍

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

      That's a great idea, unfortunately other commitments are taking my time at the moment but I hope to be back soon.