这是我的查询:为什么我的查询不起作用?
SELECT [MsgType],sr.ServiceName,content,COUNT(*) AS Occurrence
FROM [VSReceiveSend].[dbo].[ReceiveBuffer] rb
INNER JOIN dbo.Services sr ON rb.ServiceCode=sr.Code
where MsgType is not null and MsgType = 2
group by MsgType,CONTEnt, sr.ServiceName
order by COUNT(*) DESC
UNION
SELECT [MsgType],sr.ServiceName,content,COUNT(*) AS Occurrence
FROM [VSReceiveSend].[dbo].ReceivedSMS rb
INNER JOIN dbo.Services sr ON rb.ServiceCode=sr.Code
where MsgType is not null and MsgType = 2
group by MsgType,CONTEnt, sr.ServiceName
order by COUNT(*) DESC
SQL给我这个错误:Incorrect syntax near the keyword 'UNION'
!问题是什么?
你想达到什么目的?看起来像一个相当广泛的查询? – 2014-09-22 10:36:23
你在'UNION'关键字之前不能有'ORDER BY'子句 – 2014-09-22 10:36:56
@JohnWoo如何在这个查询中使用UNION? – pejman 2014-09-22 10:48:04