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 |
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2008-04-03 : 07:37:14
|
Hi ,account_desc_out,Analysis_Desc_out,Sub_Analysis_Desc_out,debit_out, credit_out,sub_Analysis_Code_out,Analysis_Code_out -----------------------------------------------11066-0001-01 GEN 6633 0.00000000 160.00000000 6633 GEN11066-0001-01 GEN 6633 160.00000000 0.00000000 6633 GENWhen i run the below query the o/p is comming as above:actually no record should come bcz debit amt and credit amt should knock off .can anyone correct the below query:select account_code_desc as 'Account_Desc_out',analysis_code_Desc as 'Analysis_Desc_out',subanalysis_code_desc as 'Sub_Analysis_Desc_out',case when drcr_flag='dr' then sum(isnull(base_amount,0)) else 0.00 end as 'debit_out',case when drcr_flag='cr' then sum(isnull(base_amount,0)) else 0.00 end as 'credit_out',subanalysis_code as 'sub_Analysis_Code_out',analysis_code as 'Analysis_Code_out'from Analysis_stg_tb as stg with (NOLOCK)where subanalysis_code_desc='6633-Goverdhan S'group by subanalysis_code,analysis_code,account_code_desc,analysis_code_desc,subanalysis_code_desc,drcr_flaghaving sum(case when drcr_flag='cr' then isnull(base_amount,0) else 0.00 end) - sum(case when drcr_flag='dr' then isnull(base_amount,0) else 0.00 end)<>0order by Account_Desc_out,Analysis_Desc_out,Sub_Analysis_Desc_out |
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-04-03 : 07:49:21
|
quote: Originally posted by sent_sara Hi ,account_desc_out,Analysis_Desc_out,Sub_Analysis_Desc_out,debit_out, credit_out,sub_Analysis_Code_out,Analysis_Code_out -----------------------------------------------11066-0001-01 GEN 6633 0.00000000 160.00000000 6633 GEN11066-0001-01 GEN 6633 160.00000000 0.00000000 6633 GENWhen i run the below query the o/p is comming as above:actually no record should come bcz debit amt and credit amt should knock off .can anyone correct the below query:select account_code_desc as 'Account_Desc_out',analysis_code_Desc as 'Analysis_Desc_out',subanalysis_code_desc as 'Sub_Analysis_Desc_out',sum(case when drcr_flag='dr' then isnull(base_amount,0) else 0.00 end) as 'debit_out',sum(case when drcr_flag='cr' then isnull(base_amount,0) else 0.00 end) as 'credit_out',subanalysis_code as 'sub_Analysis_Code_out',analysis_code as 'Analysis_Code_out'from Analysis_stg_tb as stg with (NOLOCK)where subanalysis_code_desc='6633-Goverdhan S'group by subanalysis_code,analysis_code,account_code_desc,analysis_code_desc,subanalysis_code_desc,drcr_flaghaving sum(case when drcr_flag='cr' then isnull(base_amount,0) else 0.00 end) - sum(case when drcr_flag='dr' then isnull(base_amount,0) else 0.00 end)<>0order by Account_Desc_out,Analysis_Desc_out,Sub_Analysis_Desc_out
try thatEm |
|
|
|
|
|
|
|