--- Michael Glaesemann wrote:

> SELECT DISTINCT ON (phone_number)
>      phone_number, call_duration, id
> FROM calls
> ORDER BY phone_number
>      , call_duration DESC;

Wasn't acquainted with "DISTINCT ON (column)". 
I found it to be many times faster than other suggestions using JOIN.

Cheers,
Fernando.




---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Reply via email to