Reputation: 33974
I have this SQL Query,
select * from (select * from .......) as a
where 1 = case when CountOfInnerSelect = 1 Then 1 ELSE ............
Is it possible I can get Count of inner select inside the outer SELECT?
Upvotes: 1
Views: 779
Reputation: 33809
Your WHERE Clause
does not make much sense as it is applied like a filter here. (ie; similar to 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
Upvotes: 1
Reputation: 7214
Yes :
select * from (select count(0) as cnt from .......) as a
where 1 = case when a.cnt = 1 Then 1 ELSE ............
Upvotes: 1