This happens to you just because MySQL breaks the logic of SQL.
Let's say we have table emp:
id ename dept
1 mark 10
2 John 10
3 Mary 10
4 Jane 20
and the query:
select dept, ename
from emp
group by dept;
you'll get what?
You should get two lines, because there are two departments, but the query ask for ename. For 20 is clear but for 10 the engine should return what?
It shoud return an error. Can't guess what ename to give.
Oracle shoot an error - your error, but MySQL gets an ename(not guaranteed which).
That's missleading and may conduct bugs.
Correct queries would be:
select dept, max(ename) --the latest, alaphabeticaly
from emp
group by dept;
and
--all enames and groups
select dept, ename
from emp
group by dept, ename;
After you correct this part, you'll have to resolve the
COUNT(*) over() AS rowcount
part. In oracle, AFAIK, you can't mix analytic functions with group by queries.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…