ORA-00979: not a GROUP BY clause for Oracle, but not valid for MySQL in the context of difference in clauses

I ran this query in Oracle

select studentid, attndmark
from attendance_master m,
     attendance_detail d
where m.attnid = d.attendid
group by studentid

and got the error:

ORA-00979: not a GROUP BY expression

The error is OK, and I know the question about the list of columns in the select clause. But a similar query is valid in MySQL.

SELECT aff.akey, username
FROM `affiliates` aff,
     affstats ast
WHERE aff.akey = ast.akey
group by aff.akey

I need a query trick that can work on both Oracle / Mysql and MSSQL.

What could be the trick?

+4
source share
1 answer

MySQL , SQL ( ). SELECT, GROUP BY. , "" .

, JOIN. :

SELECT aff.akey, MAX(username)
FROM affiliates aff JOIN
     affstats ast 
     ON aff.akey=ast.akey
GROUP BY aff.akey;

.

+7

Source: https://habr.com/ru/post/1619049/


All Articles