我有这个 SQL 查询,
select * from (select * from .......) as a
where 1 = case when CountOfInnerSelect = 1 Then 1 ELSE ............
是否有可能我可以在外部 SELECT 中获得内部选择的计数?
我有这个 SQL 查询,
select * from (select * from .......) as a
where 1 = case when CountOfInnerSelect = 1 Then 1 ELSE ............
是否有可能我可以在外部 SELECT 中获得内部选择的计数?
是的 :
select * from (select count(0) as cnt from .......) as a
where 1 = case when a.cnt = 1 Then 1 ELSE ............
您WHERE Clause
没有多大意义,因为它在这里像过滤器一样应用。(即;类似于WHERE myCount = 1
)
SELECT * FROM
(SELECT c1,c2,c3,..,Cn,COUNT(*) AS myCount
FROM YourTable
GROUP BY c1,c2,c3,..,Cn
) A
WHERE 1 = CASE myCount WHEN 1 THEN 1 ELSE... END