课程: Intermediate SQL for Data Scientists
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Challenge: Rewriting a complex query to use CTEs - SQL教程
课程: Intermediate SQL for Data Scientists
Challenge: Rewriting a complex query to use CTEs
(upbeat electronic music) - [Instructor] In this challenge, we're going to be given a query with a subquery in the where clause, and I'd like you to write an equivalent query that uses a common table expression instead of a subquery. Let's take a look at the query we're going to start with. So in this case, we have a select statement where we're working with salaries, and the data_sci.employees table, and we're also working the company_regions table. So the query that we have is to select the sum of the salary and then round the average of the salary to two decimal places, query that from the data_sci.employees table, where the region_id is in a result set where we select the id from the data_sci.company_regions, where the region_name is like east. It has somewhere in that in the name, the pattern E-A-S-T. So the challenge is to re-write that as a query that uses common table expressions instead of a subquery.
内容
-
-
-
-
-
-
-
-
(已锁定)
Introducing common table expressions (CTEs)3 分钟 21 秒
-
(已锁定)
Multiple table common table expressions6 分钟 33 秒
-
(已锁定)
Hierarchical tables4 分钟 25 秒
-
(已锁定)
Recursive common table expressions3 分钟 35 秒
-
(已锁定)
Challenge: Rewriting a complex query to use CTEs1 分钟 4 秒
-
(已锁定)
Solution: Rewriting a complex query to use CTEs33 秒
-
(已锁定)
-
-
-