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
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Anyone help having command
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

usafelix
Posting Yak Master

Hong Kong
103 Posts

Posted - 08/22/2014 :  06:20:35  Show Profile  Reply with Quote
I am writing this query but cannot show the grand total in last column ? May be i am wrong using the having command , Anyone can help edit this query and Thanks

----------------------------------------------------------
SELECT
isnull(xsodetail.memono,'') as memo,
CONVERT(varchar(13), xsodetail.createdatetime, 121) + ':00' as reportdate,
isnull(fl_one_piece_mask_master.who_in_charge,'') as who,
isnull(fl_one_piece_mask_master.description,'') as description,
isnull(xsodetail.sku,'') as sku,

case when xsodetail.shopcode is null
then ' Total'
else
'Shop '+xsodetail.shopcode end as shop,
sum(xsodetail.salesqty) as qty,
Sum(xsodetail.actualsalesamt) AS SalesAmount

FROM xsodetail
inner join fl_one_piece_mask_master on fl_one_piece_mask_master.sku= xsodetail.sku

WHERE xsodetail.txdate = Convert(varchar, GETDATE(),112)-3 and xsodetail.actualsalesamt>0
GROUP BY CONVERT(varchar(13), xsodetail.createdatetime, 121),
fl_one_piece_mask_master.who_in_charge,
fl_one_piece_mask_master.description,
xsodetail.shopcode,
xsodetail.memono,
xsodetail.sku,
xsodetail.actualsalesamt
having sum(xsodetail.actualsalesamt)>0

gbritton
Flowing Fount of Yak Knowledge

1443 Posts

Posted - 08/22/2014 :  08:25:56  Show Profile  Reply with Quote
Please post some sample output from your query
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.03 seconds. Powered By: Snitz Forums 2000