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.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Anyone help having command

Author  Topic 

usafelix
Posting Yak Master

165 Posts

Posted - 2014-08-22 : 06:20:35
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
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-22 : 08:25:56
Please post some sample output from your query
Go to Top of Page
   

- Advertisement -