forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
48 lines
1.8 KiB
HTML
48 lines
1.8 KiB
HTML
<a name="EN-US_TOPIC_0000001819336209"></a><a name="EN-US_TOPIC_0000001819336209"></a>
|
|
|
|
<h1 class="topictitle1">WITH AS</h1>
|
|
<div id="body8662426"><p id="EN-US_TOPIC_0000001819336209__en-us_topic_0000001706104853_en-us_topic_0000001398422534_p1976018713611">WITH AS is used in GaussDB(DWS) to declare one or more subqueries that can be referenced by name in the main query. It is equivalent to a temporary table. DSC supports this keyword, which is retained in the migration.</p>
|
|
<p id="EN-US_TOPIC_0000001819336209__en-us_topic_0000001706104853_en-us_topic_0000001398422534_p46401768376"><strong id="EN-US_TOPIC_0000001819336209__en-us_topic_0000001706104853_en-us_topic_0000001398422534_b1664013673712">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001819336209__en-us_topic_0000001706104853_en-us_topic_0000001398422534_screen364015611376">with e as (
|
|
select city, sum(population) from t1 group by city
|
|
),
|
|
d as (
|
|
select max(music) as max_music, min(music) as min_music from student
|
|
),
|
|
s as (
|
|
select * from subject
|
|
)
|
|
select * from e;</pre>
|
|
<p id="EN-US_TOPIC_0000001819336209__en-us_topic_0000001706104853_en-us_topic_0000001398422534_p186401060379"><strong id="EN-US_TOPIC_0000001819336209__en-us_topic_0000001706104853_en-us_topic_0000001398422534_b664012693717">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001819336209__en-us_topic_0000001706104853_en-us_topic_0000001398422534_screen96401763378">WITH e AS (
|
|
SELECT
|
|
city, sum(population)
|
|
FROM
|
|
t1
|
|
GROUP BY
|
|
city
|
|
),
|
|
d AS (
|
|
SELECT
|
|
max(music) AS "max_music", min(music) AS "min_music"
|
|
FROM
|
|
student
|
|
),
|
|
s AS (
|
|
SELECT
|
|
*
|
|
FROM
|
|
subject
|
|
)
|
|
SELECT
|
|
*
|
|
FROM
|
|
e;</pre>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_16_0119.html">Table (Optional Parameters and Operations)</a></div>
|
|
</div>
|
|
</div>
|
|
|