Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Preparing Reports in sql server

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-01-08 : 08:00:15
Madhavi writes "hello sir,


select
p.name as hospital,
'accepted'=case when pr.preauthstatus=1 then count(pr.preauthstatus) end ,
'pending'=case when pr.preauthstatus=2 then count(pr.preauthstatus) end,
'rejected'=case when pr.preauthstatus=3 then count(pr.preauthstatus) end,
'Total'=count(pr.preauthstatus)
from preauthorization pr,provider p
where p.id=pr.providerid
group by p.name,pr.preauthstatus
ORDER BY p.name



hospitalname accepted pending rejected
Asian Heart Institute 134 NULL NULL 134
Asian Heart Institute NULL NULL 4 4
Balaji Hospital 61 NULL NULL 61
Balaji Hospital NULL 1 NULL 1
Balaji Hospital NULL NULL 1 1
Bombay Hospital 298 NULL NULL 298
Bombay Hospital NULL 6 NULL 6
Bombay Hospital NULL NULL 56 56
BSES MGH Hospital 26 NULL NULL 26
BSES MGH Hospital NULL 1 NULL 1
BSES MGH Hospital NULL NULL 1 1
Cumballa Hill Hospital 29 NULL NULL 29
Cumballa Hill Hospital NULL NULL 2 2
Godrej Hospital 28 NULL NULL 28
Godrej Hospital NULL NULL 2 2
Gurunanak Hospital (Bandra) 102 NULL NULL 102
Gurunanak Hospital (Bandra) NULL 7 NULL 7
Gurunanak Hospital (Bandra) NULL NULL 20 20
Inlaks General Hospital 95 NULL NULL 95
Inlaks General Hospital NULL NULL 3 3
Joy Hospital 41 NULL NULL 41
Joy Hospital NULL NULL 5 5
Life Line Hospital 224 NULL NULL 224
Life Line Hospital NULL 1 NULL 1
Life Line Hospital NULL NULL 3 3
Sushrut Hospital 95 NULL NULL 95
Sushrut Hospital NULL NULL 10 10
Tata Memorial Hospital 3 NULL NULL 3
Tata Memorial Hospital NULL 1 NULL 1
Wockhardt Hospital (Mumbai) 188 NULL NULL 188
Wockhardt Hospital (Mumbai) NULL 6 NULL 6
Wockhardt Hospital (Mumbai) NULL NULL 22 22



But i want providername only once in query and corresponding count of preauths .
In this query,i'm getting values in different lines.

Thanks in advance."
   

- Advertisement -