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 |
|
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2010-04-29 : 05:43:05
|
| Dear All,I need to use this query SELECT T1.Hospital_DRG,COUNT(lms_guid) 'Total_Charts_Review' FROM dbo.lmsaccutrend_repository_inpatient t1 INNER JOIN dbo.lmsaccutrend_lookup_inpatient_audit_type as t2 ON t1.audit_type_id = t2.audit_type_id INNER JOIN dbo.lmsaccutrend_lookup_inpatient_chart_status t3 ON t1.inpatient_chart_status = t3.inpatient_chart_status_id GROUP BY T1.Hospital_DRGFor the above query i need to add below to get the details pls help m eNumber_Drg_Inc = count(lms_guid) where chart_code = 'I'Number_Drg_Dec = count(lms_guid) where chart_code = 'D'Potential_Inc_Reim = sum(diff_amount) where chart_code = 'I'Potential_Dec_Reimb = sum(diff_amount) where chart_code = 'D'I need to use Count with where clouse for Chart_code ?? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-29 : 05:49:19
|
Example:Number_Drg_Inc = count(lms_guid) where chart_code = 'I'can maybe done like this:Number_Drg_Inc = sum(case when lms_guid is not null and chart_code = 'I' then 1 else 0 end) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2010-04-29 : 06:07:58
|
| Its returning wrong result set if i use above code.I need to take sume of lms_guid ?? |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-29 : 06:55:53
|
In my example sum() ist getting 1 or 0 to sum, so it is the same result as count().Can you show your executed statement? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|