You can use NOT EXISTS
SELECT
DISTINCT T.doc_no
FROM tbl T
WHERE NOT EXISTS
(
SELECT
1
FROM tbl TT
WHERE TT.doc_status = 0
AND TT.doc_no = T.doc_no
)
Note: I guess doc_status
can hold value either 0/1
. If this is the case then no need to filter with doc_status = 1
outside.
OR you can use NOT IN
SELECT
DISTINCT T.doc_no
FROM tbl T
WHERE T.doc_no NOT IN
(
SELECT
TT.doc_no
FROM tbl TT
WHERE TT.doc_status = 0
)
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.