我只是想知道如果cte也用在sybase中......我知道cte用于sql server ..但不知道它们是否用于sybase ...是否在sybase中使用了CTE?
如果Cte's不用于sybase,是否有任何其他在sybase中的方法,它在sql server中执行CTE ...?
我有像上述查询的::
select CONVERT(VARCHAR(7)
, [startdatetime],111) AS [year-month]
, nm.nameLine1 AS CompanyName
, sum(datediff(hour, startdatetime, enddatetime)) as total
from srl
inner join sr on srl.ServiceRequestId = sr.ServiceRequestId
inner join Name nm
on (sr.clientCustomerId = nm.customerId
and nm.nameTypeId = 'OFICE')
where (startdatetime >= '08-01-2011 00:00:00.000'
and enddatetime <= '10-31-2011 00:00:00.000')
group by CompanyName, [year-month]
order by CompanyName, [year-month]
输出的查询:
year-month CompanyName total
---------- ----------- -----------
2011/08 B 4
2011/09 B 7
2011/10 B 0
2011/08 E 167
2011/09 E 212
2011/10 E 131
2011/08 L 14
2011/09 L 23
2011/10 L 3
2011/08 O 18
2011/09 O 8
2011/10 O 7
2011/08 S 43
2011/09 S 60
2011/10 S 60
我想显示在作为:: 输出的总数(我想要的输出为如下)
year-month CompanyName total companytotals
---------- ----------- ----------- ---------------
2011/08 B 4
2011/09 B 7
2011/10 B 0 11
2011/08 E 167
2011/09 E 212
2011/10 E 131 510
2011/08 L 14
2011/09 L 23
2011/10 L 3 40
2011/08 O 18
2011/09 O 8
2011/10 O 7 33
2011/08 S 43
2011/09 S 60
2011/10 S 60 163
是否有任何方法可以做到这一点......?
在此先感谢..
以上查询是SYBASE! – sonu
我知道;我只添加了一些空格以使其可读。我不知道Sybase,所以我不会对内容发表评论。 – wildplasser
请注意,如果您需要准确的答案,您应该真正指定确切的产品名称和版本,Sybase是一家公司,而不是产品。 – Lucero