what i basically want to do is: compute the difference of to attributes and then get the row with the biggest difference.
So, here is what i tried:
SELECT caller_aor, (end_time - start_time) as duration
FROM cdrs
GROUP BY caller_aor
HAVING duration = (SELECT MAX(end_time - start_time) FROM cdrs);
duration in the HAVING clause gives an error but i cant figure out what i have to do there.
Help is appreciated.
You don’t want
GROUP BYandHAVING(they are only used when aggregating columns).You want a simple
WHERE: