Res: [SQL] Finding all tables that have foreign keys referencing a table

2008-11-07 Thread paulo matadr
Try this select table_schema, table_name from information_schema.columns where table_schema not in ('information_schema','pg_catalog') and column_name = '?' De: Andreas Joseph Krogh <[EMAIL PROTECTED]> Para: pgsql-sql@postgresql.org Enviadas: Quinta-feira, 6 de N

[SQL] sum timestamp result in hours

2008-11-07 Thread paulo matadr
Select sum(age(rgat.rgat_tmencerramento, rgat.rgat_tmregistroatendimento)) from atendimentopublico.registro_atendimento rgat inner join cadastro.localidade loca on loca.loca_id=rgat.loca_id inner join atendimentopublico.solicitacao_tipo_especificacao step on step.step_id=rgat.step_id where date(rg

Re: [SQL] sum timestamp result in hours

2008-11-07 Thread Scott Marlowe
On Fri, Nov 7, 2008 at 9:36 AM, paulo matadr <[EMAIL PROTECTED]> wrote: > I change form to create query but basically need > sum(rgat.rgat_tmencerramento - rgat.rgat_tmregistroatendimento) = result in > hours > sumary: > rgat.rgat_tmencerrament = timestamp column > gat.rgat_tmregistroatendimento =

Res: [SQL] sum timestamp result in hours

2008-11-07 Thread paulo matadr
I change form to create query but basically need sum(rgat.rgat_tmencerramento - rgat.rgat_tmregistroatendimento) = result in hours sumary: rgat.rgat_tmencerrament = timestamp column gat.rgat_tmregistroatendimento = timestamp column De: Osvaldo Kussama <[EM

Re: [SQL] need help in building a query

2008-11-07 Thread Devil™ Dhuvader
its like sum up entries of each user in order table backwards (i.e from last entry to the first) and find the entry that has sum > $500. If there is some user who didnt even make 500 till now in my shop return the first date of transaction/order. ex: Orders(order_id, user_id, amount_paid, create_t

[SQL] Creating input/output_functions

2008-11-07 Thread Markus Schatten
Is there a way to create custom type input/output functions for user-defined types in some other language except C (e.g. plythonu)? Best regards -- Markus Schatten, MSc Faculty of Organization and Informatics Varaždin, Croatia http://autopoiesis.foi.hr -- Ova poruka poslana je s CARNeto

Re: Res: [SQL] Finding all tables that have foreign keys referencing a table

2008-11-07 Thread Andreas Joseph Krogh
On Friday 07 November 2008 15:15:49 paulo matadr wrote: > Try this > > select table_schema, table_name > from information_schema.columns > where table_schema not in > ('information_schema','pg_catalog') > and column_name = '?' AFAICS this lists all tables which have a column named '?', which is n

Re: Res: [SQL] Finding all tables that have foreign keys referencing a table

2008-11-07 Thread Tom Lane
Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > AFAICS this lists all tables which have a column named '?', which is not what > I'm after. I'm after listing all columns referencing a certain column as a > FOREIGN KEY. Should be possible to dredge that out of pg_constraint ... about like this:

Re: Res: [SQL] Finding all tables that have foreign keys referencing a table

2008-11-07 Thread Andreas Joseph Krogh
On Friday 07 November 2008 21:09:33 Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > AFAICS this lists all tables which have a column named '?', which is not > > what I'm after. I'm after listing all columns referencing a certain column > > as a FOREIGN KEY. > > Should be p

Re: Res: [SQL] Finding all tables that have foreign keys referencing a table

2008-11-07 Thread Tom Lane
Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > Needless to say that it would be nice if this information was available in > the information_schema, I'm probably not the only one spending lots of time > in there. It's probably not in in the standard, but i would be a nice > PG-extention to al

Resp.: [SQL] need help in building a query

2008-11-07 Thread Osvaldo Kussama
2008/11/7, Devil™ Dhuvader <[EMAIL PROTECTED]>: > its like sum up entries of each user in order table backwards (i.e from last > entry to the first) and find the entry that has sum > $500. > If there is some user who didnt even make 500 till now in my shop return the > first date of transaction/ord

Re: [SQL] need help in building a query

2008-11-07 Thread Frank Bax
Devil™ Dhuvader wrote: its like sum up entries of each user in order table backwards (i.e from last entry to the first) and find the entry that has sum > $500. If there is some user who didnt even make 500 till now in my shop return the first date of transaction/order . ex: Orders(order_id,