-1

I just need an help on making an query work.

I wanted To get the records for an all users whose total cdr seconds is >= 2400 (40 minutes)

SELECT SUM(TIME_TO_SEC(cdr.duration)) AS secsUsed 
FROM cdr 
WHERE SUM(TIME_TO_SEC(cdr.duration))>=2400 
GROUP BY ownerpin 
ORDER BY secsUsed DESC

i found that aggregate function usage like above will not work!

is there any way that i could get the logic work !!

4

1 回答 1

1

将条件从WHEREtoHAVING子句移动:

select ownerpin,
       SUM(TIME_TO_SEC(cdr.duration)) as secsUsed 
from cdr 
group by ownerpin 
HAVING SUM(TIME_TO_SEC(cdr.duration))>=2400 
order by secsUsed desc ;
于 2013-02-21T08:18:21.670 回答