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.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2007-01-08 : 08:00:37
|
madhavi writes "Hello Guru,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 pwhere p.id=pr.providerid group by p.name,pr.preauthstatus with cubeORDER BY p.namehere accepted,rejected,pending are the values in preauthstatus table. This query is used for preparing REPORTS.I'm getting query output like this ..........HOSPITAL ACCEPTED PENDING REJECTED TOTALAsian Heart Institute 134 NULL NULL 134Asian Heart Institute NULL NULL 4 4Balaji Hospital 61 NULL NULL 61Balaji Hospital NULL 1 NULL 1Balaji Hospital NULL NULL 1 1Bombay Hospital 298 NULL NULL 298Bombay Hospital NULL 6 NULL 6Bombay Hospital NULL NULL 56 56BSES MGH Hospital 26 NULL NULL 26BSES MGH Hospital NULL 1 NULL 1BSES MGH Hospital NULL NULL 1 1Cumballa Hill Hospital 29 NULL NULL 29Cumballa Hill Hospital NULL NULL 2 2Godrej Hospital 28 NULL NULL 28Godrej Hospital NULL NULL 2 2Gurunanak Hospital (Bandra) 102 NULL NULL 102Gurunanak Hospital (Bandra) NULL 7 NULL 7Gurunanak Hospital (Bandra) NULL NULL 20 20Inlaks General Hospital 95 NULL NULL 95Inlaks General Hospital NULL NULL 3 3Joy Hospital 41 NULL NULL 41Joy Hospital NULL NULL 5 5Life Line Hospital 224 NULL NULL 224Life Line Hospital NULL 1 NULL 1Life Line Hospital NULL NULL 3 3Prince Aly Khan 30 NULL NULL 30Prince Aly Khan NULL 4 NULL 4Prince Aly Khan NULL NULL 4 4 NULL 10Sushrut Hospital 95 NULL NULL 95Sushrut Hospital NULL NULL 10 10Tata Memorial Hospital 3 NULL NULL 3Tata Memorial Hospital NULL 1 NULL 1Wockhardt Hospital 188 NULL NULL 188Wockhardt Hospital NULL 6 NULL 6Wockhardt Hospital NULL NULL 22 22But i want like this......... Accepted Rejected Pending Total Accepted Rejected Pending TotalAadhar Nursing Home 4 0 3 7 2 0 0 2Apurva Heart and Critical Care,Dhule 3 0 0 3 0 0 0 0Arneja Heart Institute 12 0 0 12 8 0 0 8Ashwini Hospital,Jalgaon 27 0 0 27 10 0 0 10Ashwini hospital,Solapur 5 6 0 11 21 13 1 35Asian Heart Institute 5 0 0 5 2 0 0 2Bahekar Nursing Home 0 0 1 1 5 0 0 5Bhagwati Hospital,Badlapur 0 1 0 1 0 0 0 0Bhaktivedanta Hospital 1 0 0 1 0 0 0 0Bibekar Hospital 1 1 0 2 0 0 0 0Bombay Hospital & Medical Research Centre 15 6 1 22 7 2 1 10City Medical Centre 2 0 0 2 1 0 0 1Chatrapati Shahu Hospital,Gangakhed 0 0 0 0 1 0 0 1Chopda Medicare & Research Centre Pvt. Ltd. 4 0 0 4 3 0 0 3Deenanath Mangeshkar Hospital 42 6 0 48 11 1 0 12Deepak Hospital 24 1 0 25 12 0 0 12Desai Accident and General Hospital,Bhosari 0 1 0 1 1 0 0 1Deshmukh Hospital 1 0 0 1 0 0 0 0Deshpande Hospital ,Ahmednagar 16 0 0 16 9 0 0 9Dhanvantari Hospital,Kulgaon,badlapur 1 0 0 1 0 0 0 0Dhanvantari Fracture, Orthopaedic & Arthroscopy Centre, Kolhapur 3 0 0 3 1 0 0 1Dhirubhai Ambani Hospital,Lodhivali 1 0 0 1 1 0 0 1Doshi Nursing Home 4 1 0 5 6 1 0 7Dr K G Deshpande Memorial Centre,Nagpur 2 0 0 2 0 0 0 0Dr Kamat's Hospital 0 1 0 1 0 0 0 0Dr Kunnure Hospital 1 0 0 1Dr Nalavade Hospital 1 0 0 1 0 0 0 0Dr Murkey Aayushkam Bal Rugnalaya 2 0 0 2 2 3 0 5Dr Raghoji Kidney Hospital & Research Centre 15 2 0 17 5 1 0 6Dr S.B. Gugale Memorial Hospital 5 1 1 7 1 1 0 2" |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-08 : 08:37:44
|
How are we supposed to know how to break up the sums in the first example?Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|