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 |
Nav522
Starting Member
27 Posts |
Posted - 2009-10-01 : 20:12:52
|
I am having trouble in finding out how to modify this TSQL procedure .Recovery amount in the Current procedure i am having is taking only ALLOCATION_CHECK_AMOUNT when C.Code(Code is coming from RECOVERY_TYPE table) is equal to '50','51' and '52'. My requirement is to add the RETAINED_BY_CLIENT in this current procedure which is Coming from the CASH_RECEIPT table i.e same table where ALLOCATION_CHECK_AMOUNT is also coming from. Finally i have to Sum both ALLOCATION_CHECK_AMOUNT and RETAINED_BY_CLIENT eventually giving the total amount i.e.GrossRecoverynoncash column in my report. I have no clue how to do this in this procedure. Any help is kindly appreciated.I am using ALLOCATION_CHECK_AMOUNT in the CASE statement, Can i use a SUM inside a CASE statement?Thanks,open c_reportcontrolfetch next from c_reportcontrol into @v_client,@v_spool_level,@bucket1,@label1,@bucket2,@label2,@bucket3,@label3,@bucket4,@label4while @@fetch_status = 0beginif @v_spool_level ='C'beginexecute @v_id = getclientid @v_clientselect @v_name = name from client where client_id = @v_iddeclare c_caseinformation cursor forselect a.case_id,legacy_case_id,patient_name,a.trv_policy_id,a.trv_event_id,/*recovery_amount, */fee_schedule,c.code,case c.code when '97' then recovery_amountwhen '17' then recovery_amountwhen '50' then ALLOCATION_CHECK_AMOUNTwhen '51' then ALLOCATION_CHECK_AMOUNTwhen '52' then ALLOCATION_CHECK_AMOUNTend,hri_fee,isnull(convert(numeric(18,2), admin_fee), 0),taxes,group_idfrom cases a,cash_receipt b,recovery_type cwhere a.case_id = b.case_idand a.client_id = @v_idand b.recovery_date >= @start_dateand b.recovery_date <= @end_dateand b.recovery_type_id = c.recovery_type_idand c.code in ('97','17', '50', '51', '52')end |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-10-02 : 07:54:44
|
isnt it just a matter of replacing ALLOCATION_CHECK_AMOUNT by ALLOCATION_CHECK_AMOUNT + RETAINED_BY_CLIENT in above case staement? |
|
|
|
|
|
|
|