Hello I have this query :
SELECT DISTINCT a.id, a.runcd,
(SELECT SUM(b.CALVAL) FROM GRS b
WHERE b.PCode=11000
AND a.id = b.id
AND a.runcd=b.runcd) AS qval
FROM GRS a
WHERE a.crt = k04
Is this the same one like :
SELECT a.id, a.runcd,
(SELECT SUM(b.CALVAL) FROM GRS b
WHERE b.PCode=11000
AND a.id = b.id
AND a.runcd=b.runcd) AS qval
FROM GRS a
WHERE a.crt = k04
GROUP BY id,runcd
So far this returns the same result but I dunno if this is the right alternative or not. Thank You!
For this particular query they will always behave exactly the same, regardless of DB vendor (at least I cannot think of any issues with this query using mysql, sql server, postgres or oracle).