WITH t(num) AS (SELECT MAX(stok) FROM cd)
WITH y AS (SELECT cdno FROM cd,t WHERE cd.stok IN (t.num))
select * from y
I have this code thread. But is is not correct, I have some mistakes. I do not why please help .
When I am using with line 1 and select * from t
is working but in this type that's not working .
You cannot have two CTE's (Common Table Expression) after another like this. If you to define two CTE, you need to use this syntax:
WITH t(num) AS
(
SELECT MAX(stok)
FROM cd
), y AS
(
SELECT cdno
FROM cd, t
WHERE cd.stok IN (t.num)
)
SELECT *
FROM y
You can chain multiple CTE's after one another by separating them with a comma ,
and just leaving out the WITH
keyword for the subsequent CTE's.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.