Re: [SQL] Subselects to Joins? Or: how to design phone calls database

2011-12-12 Thread Misa Simic
) Then you can join calls to phonenumbers on full number string then join countries on country prefix... Kind Regards, Misa Sent from my Windows Phone From: Mario Splivalo Sent: 10 December 2011 23:27 To: pgsql-sql@postgresql.org Subject: [SQL] Subselects to Joins? Or: how to design phone calls

Re: [SQL] Subselects to Joins? Or: how to design phone calls database

2011-12-10 Thread Viktor Bojović
Hi Mario, over - partition by will help. Iy that syntax is uncomfortable you can use multiple joins, using maximum length or max(prefix::int) but that will slow down the process. select over - partition by is fastest solution i think. On Sat, Dec 10, 2011 at 11:24 PM, Mario Splivalo wrote: > I

[SQL] Subselects to Joins? Or: how to design phone calls database

2011-12-10 Thread Mario Splivalo
I have a table called 'calls' which holds 'call detail records'. Let's assume the table looks like this: CREATE TABLE cdr ( call_id serial, phone_number text ); And I have a table with country call prefixes, that looks like this: CREATE TABLE prefixes ( prefix text,