SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 compute sum result cannot show in report,how to
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

usafelix
Yak Posting Veteran

Hong Kong
86 Posts

Posted - 08/23/2014 :  08:46:25  Show Profile  Reply with Quote
Everybody know how to display sql compute sum command their result in amount and qty in report?

I am try this query is successful show the total amount and qty in studio management server and show in screen. But run this query on report is without to show last column of qty and amount, why ?

------------------------------------------------------------
select
xsodetail.shopcode,xsodetail.memono,xsodetail.txdate,
xsodetail.sku,xsoheader.depositamt,xsopayment.paymentcode,xsopayment.paymentamt,
xsodetail.itemamt,xsodetail.salesqty

from xsoheader
inner join xsodetail on xsoheader.shopcode + xsoheader.memono = xsodetail.shopcode + xsodetail.memono
inner join xsopayment on xsoheader.shopcode + xsoheader.memono = xsopayment.shopcode + xsopayment.memono
where (xsodetail.sku = 'L000254' or xsodetail.sku='L000256') and xsoheader.voidflag='N' and xsodetail.txdate = CONVERT(varchar(100), GETDATE(), 112)
compute sum(xsopayment.paymentamt) , sum(xsodetail.salesqty)

bitsmed
Constraint Violating Yak Guru

390 Posts

Posted - 08/23/2014 :  12:20:20  Show Profile  Reply with Quote
Probably because the way you join. Try this:
select d.shopcode
      ,d.memono
      ,d.txdate
      ,d.sku
      ,h.depositamt
      ,p.paymentcode
      ,p.paymentamt
      ,d.itemamt
      ,d.salesqty 
  from xsoheader as h
       inner join xsodetail as d
               on d.shopcode=h.shopcode
              and d.memono=h.memono
       inner join xsopayment as p
               on p.shopcode=h.shopcode
              and p.memono=h.memono
 where d.sku in ('L000254','L000256')
   and h.voidflag='N'
   and d.txdate=convert(varchar(100),getdate(),112)
 compute sum(p.paymentamt)
        ,sum(d.salesqty)
Go to Top of Page

usafelix
Yak Posting Veteran

Hong Kong
86 Posts

Posted - 08/23/2014 :  13:35:19  Show Profile  Reply with Quote
Thanks so much ! you are big help to me !!!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000