我有查询检查一些存在,如:
SELECT CASE WHEN (exists (select * from "Customer" where length(CustomerID) >
0) ) then 1 else 0 end val from dual
我如何知道Customer表的所有记录的字段长度(CustomerID)大于3.如果所有记录的值大于3,则为1或0。
提前致谢。 俊
答案 0 :(得分:3)
这样的东西?
SELECT CASE WHEN MIN(LENGTH(CustomerID)) > 3 THEN 1 ELSE 0 END AS Val
FROM Customer;
答案 1 :(得分:1)
试试这个。
SELECT CASE
WHEN COUNT(CASE
WHEN LENGTH(CustomerID) > 3
THEN 1
END) = COUNT(*)
THEN 1
ELSE 0
END as res
FROM Customer;