Re: [SQL] Constraint exclusion

2007-06-21 Thread Fernando Hevia
I see. Thanks for the tip. Regards, Fernando. -Mensaje original- De: Tom Lane [mailto:[EMAIL PROTECTED] Enviado el: Miércoles, 20 de Junio de 2007 19:37 Para: Fernando Hevia CC: 'PostgreSQL SQL List' Asunto: Re: [SQL] Constraint exclusion "Fernando Hevia" <[EMAIL PROTECTED]> writes: >

Re: [SQL] join problem

2007-06-21 Thread Ragnar
On fim, 2007-06-21 at 08:46 -0500, A. R. Van Hook wrote: > if I query for the total deposit using >select sum(deposit) >from invoice >where cusid = 2128" > > I also get 1179.24, also the correct amount > > > If I try an inclusive query using the following: > select > sum(i

Re: [SQL] Subquery problems

2007-06-21 Thread Masaru Sugawara
On Tue, 19 Jun 2007 09:17:22 -0300 Ranieri Mazili <[EMAIL PROTECTED]> wrote: Hi, This reply is not accurate, but I think there are helpful hints. -- Masaru Sugawara select C.id_production_area, B.id_machine_type, A.h_month as month, max(A.n) as div_mes, cast((sum(A.qty_employees_t

[SQL] join problem

2007-06-21 Thread A. R. Van Hook
I have three tables relating to purchases invoice - transaction data (customer id, deposit. etc) invoiceitems - purachace items detail cai - customer data if I query for the total charges using select sum(rowtot + tax) from invoiceitems where ivid in (select ivi

Re: [NOVICE] [SQL] Select last there dates

2007-06-21 Thread Loredana Curugiu
Thank you for documentation. Best regards, Loredana

Re: [SQL] Select last there dates

2007-06-21 Thread Loredana Curugiu
I think there might be a small typo though. The left-join is to: (select uid, phone_numer, datum from t2 order by 2 ) Probably want to order by "datum DESC" too, to ensure you get the latest dates for each telnum. yes, I also observed this, so I have add to my query. Thank you for your ex

Re: [SQL] Select last there dates

2007-06-21 Thread A. Kretschmer
am Thu, dem 21.06.2007, um 16:00:05 +0300 mailte Loredana Curugiu folgendes: > So Andreas, would you please give some more explanations > on your solution? I didn't work with functions and aggregate till > now. I will try it, but i'm not a nativ english speaker and thats why i have some problems.

Re: [SQL] Select last there dates

2007-06-21 Thread Richard Huxton
Loredana Curugiu wrote: Richard, Andreas, thank you very much for your solutions. I took a look on both solutions, but I choosed Andreas's solution because is shorter :) Not to mention clever, exploiting the fact that we know the length of a text-representation of three comma-separated dates.

Re: [SQL] Results per letter query

2007-06-21 Thread Dani Castaños
A. Kretschmer escribió: am Thu, dem 21.06.2007, um 12:59:05 +0200 mailte Dani Castaños folgendes: change the generate_series(65,90) to generate_series(32,90) Andreas With only changing 65 to 32: ERROR: invalid regular expression: parentheses () not balanced I think, it could

Re: [SQL] Select last there dates

2007-06-21 Thread Loredana Curugiu
Richard, Andreas, thank you very much for your solutions. I took a look on both solutions, but I choosed Andreas's solution because is shorter :) So Andreas, would you please give some more explanations on your solution? I didn't work with functions and aggregate till now. I don't understand ho

Re: [SQL] Results per letter query

2007-06-21 Thread A. Kretschmer
am Thu, dem 21.06.2007, um 12:59:05 +0200 mailte Dani Castaños folgendes: > >change the generate_series(65,90) to generate_series(32,90) > > > > > >Andreas > > > With only changing 65 to 32: > > ERROR: invalid regular expression: parentheses () not balanced > > I think, it could be a problem

Re: [SQL] Results per letter query

2007-06-21 Thread Dani Castaños
am Thu, dem 21.06.2007, um 12:42:52 +0200 mailte Dani Castaños folgendes: test=*# select chr(x), count(1) from generate_series(65,90) x, w where upper(substring (w.t from 1 for 1)) ~ chr(x) group by 1; chr | count -+--- T | 1 B | 1 F | 2 (3 rows) Andreas

Re: [SQL] Results per letter query

2007-06-21 Thread A. Kretschmer
am Thu, dem 21.06.2007, um 12:42:52 +0200 mailte Dani Castaños folgendes: > >test=*# select chr(x), count(1) from generate_series(65,90) x, w where > >upper(substring (w.t from 1 for 1)) ~ chr(x) group by 1; > > chr | count > >-+--- > > T | 1 > > B | 1 > > F | 2 > >(3 row

Re: [SQL] Results per letter query

2007-06-21 Thread Dani Castaños
Hi! I'm trying to build a query to get if there is an occurrence for a field for each alphabetical letter. My first thought to know it was to do something like: SELECT COUNT(field) FROM table WHERE UPPER( field ) LIKE UPPER( 'A%' ) LIMIT 1; SELECT COUNT(field) FROM table WHERE UPPER( field

Re: [SQL] Results per letter query

2007-06-21 Thread A. Kretschmer
am Thu, dem 21.06.2007, um 11:10:02 +0200 mailte Dani Castaños folgendes: > Hi! > > I'm trying to build a query to get if there is an occurrence for a field > for each alphabetical letter. > My first thought to know it was to do something like: > > SELECT COUNT(field) FROM table WHERE UPPER( fi

Re: [SQL] Select last there dates

2007-06-21 Thread A. Kretschmer
am Thu, dem 21.06.2007, um 11:18:13 +0300 mailte Loredana Curugiu folgendes: > Hello again, > > I have the following two tables: > > Table 1: > uid | phone_number | > -+--- >8 | +40741775621 | >8 | +40741775622 | >8 | +40741775623 | >9 | +407417756

[SQL] Results per letter query

2007-06-21 Thread Dani Castaños
Hi! I'm trying to build a query to get if there is an occurrence for a field for each alphabetical letter. My first thought to know it was to do something like: SELECT COUNT(field) FROM table WHERE UPPER( field ) LIKE UPPER( 'A%' ) LIMIT 1; SELECT COUNT(field) FROM table WHERE UPPER( field )

Re: [SQL] Select last there dates

2007-06-21 Thread Richard Huxton
Loredana Curugiu wrote: My task is to create a query which for a given uid returns all values for phone_number column from table1 and last three values of date column from table2. For example, if uid=8 the query should return: phone_number |date ---+ +4074177

[SQL] Select last there dates

2007-06-21 Thread Loredana Curugiu
Hello again, I have the following two tables: Table 1: uid | phone_number | -+--- 8 | +40741775621 | 8 | +40741775622 | 8 | +40741775623 | 9 | +40741775621 | 9 | +40741775622 | 9 | +40741775623 | 10 | +40741775621 | 10 | +40741775622 | 10 | +4074177562