Given the following tables:
tableA(v1,v2)
tableB(v3,v4)
tableC(v5,v6)
I want to write a query like the following one:
SELECT MAX(v1)
FROM tableA
WHERE v2 IN (SELECT v3
FROM tableB
WHERE v4 IN (SELECT v5
FROM tableC
)
)
GROUP BY v6
Is something like this possible only by using IN?? I know how to write it by using JOINs between my three tables but I don't want to use JOINs.
No, it's not possible to do this without using JOIN
(at least in MS-SQL).
Expressions in the GROUP BY clause can contain columns of the tables, derived tables or views in the FROM clause. The columns are not required to appear in the SELECT clause list.
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.