I am porting a MySQL query to Oracle.
INSERT INTO
"stagedInserts" ("systemId", "timestamp")
SELECT
:systemId AS "systemId", "d"."time" AS "timestamp"
FROM
"data" "d"
WHERE
"d"."systemId" = :systemId
GROUP BY
TRUNC("d"."time"/900)
The GROUP BY is intended to be the equivalent of "time" DIV 900
in MySQL, to ensure that we end up with only one timestamp for each 15 minute (900 second) interval.
The above query results in ORA-00979: not a GROUP BY expression
.
However, if I add the GROUP to the SELECT so we end up with:
SELECT
:systemId AS "systemId", "d"."time" AS "timestamp", TRUNC("d"."time"/900)
It results in: ORA-00913: too many values
.
How can I resolve this issue?