no of counts from case when [message #608488] |
Thu, 20 February 2014 05:20 |
|
ashwanth77
Messages: 95 Registered: April 2013 Location: India
|
Member |
|
|
select del_point,del_point1,case when del_point=del_point1 then 'true' else 'false',count(*) from tablename;
here i want to find no of true and false counts like true(40),false(50)
|
|
|
Re: no of counts from case when [message #608490 is a reply to message #608488] |
Thu, 20 February 2014 05:25 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
count counts not null values. So have two case statements, one that returns a value for the true condition and one that returns a value for the false condition, count each:
count(case when del_point=del_point1 then 1 end) count_true,
count(case when not del_point=del_point1 then 1 end) count_false
|
|
|
Re: no of counts from case when [message #608499 is a reply to message #608490] |
Thu, 20 February 2014 06:10 |
|
msol25
Messages: 396 Registered: June 2011
|
Senior Member |
|
|
Hi,
Please find the query :
select del_point
,del_point1
,count(case when (case when del_point = del_point1
then 1
else 0
end) = 1
then 1
end
) as true_res,
,count(case when (case when del_point = del_point1
then 1
else 0
end) = 0
then 1
end
) as false_res
,count(1) total_rec
from tablename
group by del_point
,del_point1
[Updated on: Thu, 20 February 2014 06:20] Report message to a moderator
|
|
|
|