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 |
usafelix
Posting Yak Master
165 Posts |
Posted - 2014-09-03 : 02:53:36
|
Ahyone can help to edit this query , it have problem in sum(salesqty) is not within the time range,thus the salesqty is sum of other time range wrong, how I can to solve it ?SELECT CASE WHEN a.shopcode IS NULL THEN 'No More - One Piece Mask' WHEN a.shopcode IS NOT NULL AND a.sku IS NULL THEN 'End *** ' ELSE ' ' + a.shopcode END shopcode, a.createdatetime, a.memono, a.sku, sum(a.salesqty), a.actualsalesamt FROM xsodetail a, singlepiecemask b where Convert(varchar, GETDATE(),112) = a.txdate and datepart(hh,getdate()) = DATEPART(hour, a.createdatetime) and b.sku = a.sku GROUP BY GROUPING SETS((a.shopcode),(a.shopcode,a.sku,a.memono,a.createdatetime,a.salesqty,a.actualsalesamt),()) |
|
viggneshwar
Yak Posting Veteran
86 Posts |
Posted - 2015-01-09 : 00:57:32
|
If you are writing query to group by Hour then in group by also you should use DATEPART(hour, a.createdatetime) instead of just createdatetimeRegardsViggneshwar A |
|
|
|
|
|
|
|