SQL CTEs (Common Table Expressions) - Why and How to Use Them

Поділитися
Вставка
  • Опубліковано 29 лис 2024

КОМЕНТАРІ • 33

  • @DatabaseStar
    @DatabaseStar  4 дні тому

    Want to easily remember the SQL commands for your database? Get my free SQL Cheat Sheets here: www.databasestar.com/get-sql-cheat-sheets/?

  • @Grond73
    @Grond73 Рік тому +11

    This is such a clear, concise explanation for CTEs. Thank you so much!!!

  • @ministerbo3025
    @ministerbo3025 Рік тому +2

    You know how to break this down so anyone (I'm 70) can learn. I will be back to your site to learn & grow. Thank you for sharing. East Coast Sr

  • @apamwamba
    @apamwamba 2 місяці тому +1

    The idea behind CTE is very clear and you have explained it very well. It just becomes tricky when this concept of recursion comes in.. Otherwise very good job done!!

    • @DatabaseStar
      @DatabaseStar  2 місяці тому

      Thanks! Yes, it is trickier with a recursive CTE.

  • @andynelson2340
    @andynelson2340 2 роки тому +4

    Amazing. A+ explanation. My only feedback might be in your first example show the results of the subquery first, then show the whole query second. Cheers!

    • @DatabaseStar
      @DatabaseStar  2 роки тому

      Thanks! That's a good point, I'll keep that in mind for future videos.

  • @Bktargetter
    @Bktargetter Місяць тому +2

    What is the difference between CTE and procedures?

    • @DatabaseStar
      @DatabaseStar  28 днів тому +2

      CTE is a feature where you give a name to a subquery to use in that query. A procedure or stored procedure is an object created on the database that can run a query or do more complex things involving variables and logic.
      A CTE does not create a database object, and a stored procedure is an object.
      A CTE exists only for a single query, and a stored procedure can be used in many places.

  • @diamondsandlipgloss
    @diamondsandlipgloss 5 місяців тому +1

    this really helped me learn about CTEs, so thank you very much!!! Now I just need to learn what "recursive" means and find your video on hierarchical queries.

    • @DatabaseStar
      @DatabaseStar  5 місяців тому

      Glad it was helpful! I can make a video about recursive in the future.

  • @jeremynx
    @jeremynx 3 місяці тому

    Thanks, very helpful

  • @GDchanaka-he7qr
    @GDchanaka-he7qr Рік тому +1

    great explanation. Love it.

  • @siddharthapenchala8146
    @siddharthapenchala8146 2 роки тому +1

    Good Explanation.
    Sir, Kindly make a video on Recursive Subquery Factoring in oracle. Thank you!

    • @DatabaseStar
      @DatabaseStar  2 роки тому

      Thanks! Sure I can make a video on that.

  • @felipetaborda5943
    @felipetaborda5943 Рік тому +1

    Thanks. Great video!

  • @hasanmougharbel8030
    @hasanmougharbel8030 2 роки тому

    hello there, god bless your efforts..I have a simple enquiry as new sql learner.
    How are CTEs different from temporary tables?
    Thanks for taking care of this.

    • @DatabaseStar
      @DatabaseStar  2 роки тому +2

      Thanks! I cover the difference between CTEs and Temp Tables in this video.

  • @vivekkumarmishra2433
    @vivekkumarmishra2433 2 роки тому

    please make a sequence of video play list

    • @DatabaseStar
      @DatabaseStar  2 роки тому

      I've got a few playlists on my channel, which I am always adding to.

  • @MuhammadFahreza
    @MuhammadFahreza 5 місяців тому

    What is temp table ? does it mean View Table ?

    • @DatabaseStar
      @DatabaseStar  5 місяців тому

      It’s a table you can create to store data that you can refer to later. It’s like a view but it stores data and only exists for the duration of your session.

  • @tamiratabebe6623
    @tamiratabebe6623 2 місяці тому

    Thank so mach to day is Ethiopia new year that means 2017.

  • @MiningForPies
    @MiningForPies Рік тому +1

    A CTE cannot have indexes and constraints *beyond what already exists*

  • @alaeeddinehajji
    @alaeeddinehajji 2 роки тому

    Great