我正在尝试根据房间号码将结果分组。这个查询给出了我想要的结果,但我想订购结果。
报告的最新结果
Date Room Boxes Kilos
12/12/2013 01 153 487.79
12/12/2013 02 64 254.11
12/12/2013 03 101 163.23 Etc etc
我有多达12个房间,他们大致分组用于团队目的。所以我想按照以下顺序在报告中提供房间: -
3
6
8
2
9
12
4
10
11
1
5
7
他们出来的那一刻
1
2
3
4
5
6
7
8
9
10
11
12
这是用于提取数据的Sql。
SELECT Pickerid AS Id, Pickername AS Name, ROUND(SUM(totalweighta),2) AS TotalWeight, SUM(totalweighta)/SUM(pickerhours) AS HourlyRate, sum(boxcount) AS Boxes, sum(AvgBox) AS AvgBoxWeight, SUM(pickerhours) AS Hours
FROM (SELECT pickerid,currentdate,pickerhours,pickername,ROUND(SUM(currentweight),2) AS totalweighta, count(*) AS BoxCount, avg(currentweight) as AvgBox, SUM(pickerhours) AS Pickerhoursa
FROM mergeddatabase
GROUP BY pickerid,currentdate,pickerhours,pickername) AS [%$##@_Alias]
WHERE ((currentdate between [Enter first date:] AND [Enter last date:]) and (pickerhours > 0.1) and (pickerid <> 36) and (pickerid <> 67))
GROUP BY pickerid, pickername
ORDER BY 4 DESC;
提前致谢.. 标记
答案 0 :(得分:0)
如果您按特定顺序需要它并且该顺序不会经常更改,那么您将创建一个包含所需顺序的新表。然后,您将编写一个新查询,将您现有的查询用作源和新表。然后你将这两个表作为该查询的一部分加入,它应该按照所需的顺序给你结果。