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-05-12 : 04:24:59
|
| Hi friends can anybody correct the below query:Actually after the group by Zero value should not get display but it is displayed:select comp.cmp_id, acct.account_id, emp.sub_analysis_id, fb.finbook_id, period.period_wid, sum(stg.NetBalance) as Amount from travel_advance_tb stg (nolock) inner join Fin_Collection_company_dim comp (nolock)on stg.company_code = comp.company_code inner join corp_account_dim_tb acct (nolock)on stg.account_code = acct.account_code inner join corp_emp_dim_tb emp (nolock)on stg.company_code = emp.company_codeand stg.sub_analysis_code = emp.sub_analysis_code inner join corp_fb_dim_tb fb (nolock)on stg.company_code = fb.company_codeand stg.fb_id = fb.fb_id inner join sal_period_dim_tb period (nolock)on stg.month_wid=period.month_widwhere stg.sub_analysis_code='1780'group by comp.cmp_id,account_id,sub_analysis_id,finbook_id,period_widhaving sum(stg.NetBalance)!=0output is:cmp_id account_id sub_analysis_id finbook_id period_wid1 1 124 4 35 -6759.000000001 1 124 4 36 -1475.000000001 1 124 4 37 8234.000000001 1 124 4 38 -540.000000001 1 124 4 39 540.000000001 1 124 4 40 -1425.000000001 1 124 4 41 1425.000000001 1 124 4 42 -24018.000000001 1 124 4 43 47018.000000001 1 124 4 44 -23000.000000001 1 124 4 46 -6093.000000001 1 124 4 47 6093.000000001 2 124 4 30 12474.000000001 2 124 4 31 -12474.000000001 3 124 4 37 6695.520000001 3 124 4 38 -7196.000000001 3 124 4 39 500.000000001 3 124 4 41 0.48000000 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-12 : 04:32:22
|
| Didnt get that. DId you mean to say that alst row should not be displayed? The value there is not 0 but you have decimal value.Can you elaborate on what output you're expecting? |
 |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2008-05-12 : 04:34:26
|
yes visakh16 all row should not be displayed when the sum(netbalance)=0quote: Originally posted by visakh16 Didnt get that. DId you mean to say that alst row should not be displayed? The value there is not 0 but you have decimal value.Can you elaborate on what output you're expecting?
|
 |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2008-05-12 : 04:35:31
|
sorry (netbalance)!= 0quote: Originally posted by sent_sara yes visakh16 all row should not be displayed when the sum(netbalance)=0quote: Originally posted by visakh16 Didnt get that. DId you mean to say that alst row should not be displayed? The value there is not 0 but you have decimal value.Can you elaborate on what output you're expecting?
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-12 : 04:37:36
|
quote: Originally posted by sent_sara yes visakh16 all row should not be displayed when the sum(netbalance)=0quote: Originally posted by visakh16 Didnt get that. DId you mean to say that alst row should not be displayed? The value there is not 0 but you have decimal value.Can you elaborate on what output you're expecting?
But its not 0 but you have a decimal value. Are you looking at this?select comp.cmp_id, acct.account_id,emp.sub_analysis_id,fb.finbook_id,period.period_wid,sum(stg.NetBalance) as Amountfrom travel_advance_tb stg (nolock)inner join Fin_Collection_company_dim comp (nolock)on stg.company_code = comp.company_codeinner join corp_account_dim_tb acct (nolock)on stg.account_code = acct.account_codeinner join corp_emp_dim_tb emp (nolock)on stg.company_code = emp.company_codeand stg.sub_analysis_code = emp.sub_analysis_codeinner join corp_fb_dim_tb fb (nolock)on stg.company_code = fb.company_codeand stg.fb_id = fb.fb_idinner join sal_period_dim_tb period (nolock)on stg.month_wid=period.month_widwhere stg.sub_analysis_code='1780'group by comp.cmp_id,account_id,sub_analysis_id,finbook_id,period_widhaving floor(sum(stg.NetBalance)!=0 |
 |
|
|
|
|
|
|
|