below is the code which i am trying but its is giving blank . I need to insert this result as a row in another table, as it is giving blank due to which i am not able insert it into another table . Can someone please suggest how to replace that count result '' with 0
Select case when (count(ID) is Null ) OR (count( ID) ='' )
then 0 else cast((count( ID)) as varchar(50)) end as Total
from Temp1
where
quarter in ('202203','202204')
group by ID , Quarter having count(ID) >1
CodePudding user response:
CodePudding user response:
You can use something like this:
Select case when (ISNULL(count(ID),0))
then 0 else cast((count( ID)) as varchar(50))
end as Total
from Temp1
where quarter in ('202203','202204')
group by ID, Quarter
having count(ID) >1