WITH T AS
(SELECT * FROM A),
T1 AS (SELECT b.* FROM B JOIN T ON b.id = t.id),
T2 AS (SELECT c.*
FROM C JOIN T1 ON t1.id = c.id)
SELECT *
FROM T2;
1. Explain the purpose of each Common Table Expression
(CTE) in the query.
2. What is the final result of the query, and how does it
relate to the tables a, b, and c?
3. If table a has 100 rows, table b has 50 rows, and
table c has 30 rows, what can you infer about the number of rows returned by
the final SELECT statement? Assume there are matching IDs in the joins.
4. How would the query change if you wanted to select
only specific columns from t2 instead of all columns?
Test scenarios:
A |
B |
C |
Output |
Data |
No Data |
No Data |
|
Data Available, |
No Data |
|
|
Matched Data with B |
|
||
No Matched Data with B |
|
||
Matched Data |
No Data |
|
|
Matched Data with B |
|
||
No Matched Data with B |
|
||
No Data |
No Data |
No Data |
|
Data Available |
No Data |
|
|
Matched Data with B |
|
||
No Matched Data with B |
|
0 Comments
Thanks for your message.