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

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

48.688 Lượt nghe
SQL CTEs (Common Table Expressions) - Why and How to Use Them
📝 Get my free SQL Cheat Sheets: https://databasestar.mykajabi.com/lpkj-sql-cheat-sheets/?video=ZaFMM-vNlvc 🎓 Master SQL Fundamentals: https://databasestar.mykajabi.com/sql-simplified/?video=ZaFMM-vNlvc SQL CTEs, or Common Table Expressions, are a helpful feature in SQL. They can help you clean up a query and make it easier to read, and are available in many vendors including Oracle, SQL Server, MySQL, and Postgres. In this video, you’ll learn what a CTE is, why you would want to use one, see an example of transforming a query to use a CTE, and see the benefits of a CTE. Timestamps: 00:00 What is a CTE? 01:13 Our sample data 01:51 Create a CTE 04:38 Benefits of using CTEs 06:27 CTE vs Temp Table Links: Script on GitHub for sample data and SQL query: https://github.com/bbrumm/databasestar/blob/main/posts/cte_sample_data_mysql.sql