【发布时间】:2017-03-08 13:44:43
【问题描述】:
我想按日期对表格进行排序,但我的查询显示错误:
ORDER BY 子句在视图、内联函数、派生表、子查询和公用表表达式中无效,除非还指定了 TOP、OFFSET 或 FOR XML。
我的查询:
select intervaldate, [M1], [M2], [M3], [M4], [M5], [M6], [M7], [M8]
from
(select intervaldate,amount, name from (Select tSystem.Name, IntervalCount.IntervalDate,
sum(case when CounterName = 'Prod' then calculationUnits else 0 end) as Amount from IntervalCount, tsystem where
IntervalCount.intervaldate between '2017-03-06 00:00:00.000' and '2017-03-08 00:00:00.000' and IntervalCount.systemid =tsystem.id
group by tSystem.Name, IntervalCount.Intervaldate
order by IntervalCount.Intervaldate asc
) as T3) as T1
pivot
(sum (amount)
for name in ([M1], [M2], [M3], [M4], [M5], [M6], [M7], [M8])
) as t2
如何按 IntervalDate 订购?
【问题讨论】:
-
您使用的是哪个 DBMS?
标签: sql