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 |
|
murgodrudra
Starting Member
1 Post |
Posted - 2012-05-28 : 03:26:55
|
| select sum(No_of_study)as Ct from financeOutsourcingDetails where mod_name ='ct' and hosp_name='Ramesh Hospital'select hosp_name as hosp,sum(No_of_study)as Mri,sum(tot_amt) as total_amount from financeOutsourcingDetails where mod_name ='mri' group by Hosp_namei want output like belowhosp_name , No_of_mri ,no_of_ct, Total_amtSugana hospital 28 34 150000Rudra |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-05-28 : 03:57:18
|
[code]select hosp_name as hosp, sum(No_of_study)as Mri, (select sum(No_of_study)as Ct from financeOutsourcingDetails where mod_name ='ct' and hosp_name='Ramesh Hospital') as no_of_ct sum(tot_amt) as total_amount from financeOutsourcingDetails where mod_name ='mri' group by Hosp_name[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-28 : 13:23:15
|
this maybe?select hosp_name as hosp, sum(case when mod_name ='mri' then No_of_study end) as Mri, sum(case when mod_name ='ct' then No_of_study end) as no_of_ct, sum(tot_amt) as total_amount from financeOutsourcingDetails group by Hosp_name ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-05-30 : 03:28:59
|
quote: Originally posted by visakh16 this maybe?select hosp_name as hosp, sum(case when mod_name ='mri' then No_of_study end) as Mri, sum(case when mod_name ='ct' then No_of_study end) as no_of_ct, sum(tot_amt) as total_amount from financeOutsourcingDetails group by Hosp_name ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Yes. Also add where condition hosp_name='Ramesh Hospital'MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-30 : 15:37:35
|
shouldbe inside i guessselect hosp_name as hosp, sum(case when mod_name ='mri' then No_of_study end) as Mri, sum(case when mod_name ='ct' and hosp_name='Ramesh Hospital' then No_of_study end) as no_of_ct, sum(tot_amt) as total_amount from financeOutsourcingDetails group by Hosp_name ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|