03Explorer
Technical User
I want to use one query to generate this type of data from one table.
Phone Number #calls Avg_Duration(sec)
xxx-xxx-xxxx 1,234 12.34
yyy-yyy-yyyy 12,032 9.03
zzz-zzz-zzzz 435 13.45
Am I trying to do something completely wrong with my Sub Select statements which call for the table and element in the external Select Statment?
Phone Number #calls Avg_Duration(sec)
xxx-xxx-xxxx 1,234 12.34
yyy-yyy-yyyy 12,032 9.03
zzz-zzz-zzzz 435 13.45
Code:
SELECT Distinct
c.phoneNumber,
(SELECT count(distinct ID) FROM call WHERE PhoneNumber = c.PhoneNumber) #calls,
(SELECT AVG( duration ) FROM call WHERE PhoneNumber = c.PhoneNumber) AVG_Duration(sec)
FROM
Call c
GROUP BY
1,
2,
3
ORDER BY
1 ASC
Am I trying to do something completely wrong with my Sub Select statements which call for the table and element in the external Select Statment?