-1

I have following table structure

TicketID    Status  Duration
-----------------------------
1234           8        2
1233           8       10
1232           4        5
1231           8       12
1230           4       50
  • status 8 means Closed
  • status 4 means Open

It is required to have output in following way. Please do the need ful. If possible I wanted it in a single sql query.

Please help me to produce output in following way.

Row     Closed (sum)    Open(Sum)
---------------------------------
   1       24              55

2 Answers2

0
select 1 as row, 
       sum(case when status = 8 then 1 else 0 end) as closed,
       sum(case when status = 4 then 1 else 0 end) as open
from your_table
juergen d
  • 201,996
  • 37
  • 293
  • 362
0
select 
1 as Row,
sum(case when Status=8 then 1 else 0 end  ) as Closed_Sum,
sum(case when Status=4 then 1 else 0 end  ) as Open_Sum
  from 
Mytable 
Dgan
  • 10,077
  • 1
  • 29
  • 51