0

我的查询中有错误。这是查询:

select HourTime, count(*) from
(
select substring(time,1,2) as HourTime, count(*) as ActivityCount
from htmp_cs368 a
group by HourTime
)htmp
union
(
select substring(time,1,2) as HourTime, count(*) as ActivityCount
from atmp_cs368 a
group by HourTime
)atmp
group by HourTime DESC

这是错误消息:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that        corresponds to your MySQL server version for the right syntax to use near 'atmp
group by HourTime DESC' at line 12

谁能看到我的错误在哪里?我很感激。这也是大型程序的一部分,因此是 java 标记。

4

2 回答 2

7

GROUP BY没有订单。您需要使用ORDER BY.

GROUP BY HourTime 
ORDER BY HourTime DESC
于 2012-12-02T21:43:01.627 回答
1

我想你的意思是:

...
group by HourTime
order by HourTime desc
于 2012-12-02T21:44:43.237 回答