I have an error in my query. Here is the query:
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
And here is the error message:
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
Can anyone see it where my error is? I appreciate it. This is alos part of a lager program hence the java tag.
GROUP BYdoesn’t have an order. You need to sort withORDER BY.