Re: [SQL] SEVEN cross joins?!?!?

2005-10-11 Thread Greg Patnude
Aha ! A gamer... playing with armor and hit points and things -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Frank Bax Sent: Tuesday, October 11, 2005 1:06 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] SEVEN cross joins?!?!? At 08:29 AM 10/1

Re: [SQL] pg, mysql comparison with "group by" clause

2005-10-11 Thread Stephan Szabo
On Tue, 11 Oct 2005, Rick Schumeyer wrote: > I'm not sure what I was thinking, but I tried the following query in pg: > > SELECT * FROM t GROUP BY state; > > pg returns an error. > > Mysql, OTOH, returns the first row for each state. (The first row with > "AK", the first row with "PA", etc.) > >

Re: [SQL] question re. count, group by, and having

2005-10-11 Thread Muralidharan Ramakrishnan
Hi     Logically HAVING is executed after the GROUP BY and it must contain only the columns in the GROUP BY or aggregated function.   select state, count(state) as c from t group by state having c > 5   The above query grouped only on state and HAVING can be used only with the column state or the

Re: [SQL] pg, mysql comparison with "group by" clause

2005-10-11 Thread Anthony Molinaro
You're 100% correct, this is a bug in mysql. Sadly, they tout this as a feature! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rick Schumeyer Sent: Tuesday, October 11, 2005 5:12 PM To: pgsql-sql@postgresql.org Subject: [SQL] pg, mysql comparison with "

Re: [SQL] pg, mysql comparison with "group by" clause

2005-10-11 Thread Scott Marlowe
On Tue, 2005-10-11 at 16:12, Rick Schumeyer wrote: > I'm not sure what I was thinking, but I tried the following query in pg: > > SELECT * FROM t GROUP BY state; > > pg returns an error. > > Mysql, OTOH, returns the first row for each state. (The first row with > "AK", the first row with "PA",

[SQL] pg, mysql comparison with "group by" clause

2005-10-11 Thread Rick Schumeyer
I'm not sure what I was thinking, but I tried the following query in pg: SELECT * FROM t GROUP BY state; pg returns an error. Mysql, OTOH, returns the first row for each state. (The first row with "AK", the first row with "PA", etc.) I'm no SQL expert, but it seems to me that the pg behavior

Re: [SQL] SEVEN cross joins?!?!?

2005-10-11 Thread Frank Bax
At 08:29 AM 10/11/05, Richard Huxton wrote: Frank Bax wrote: I have a table with only 434 rows in it. Two important columns are "itemid" and "locn". Each item must be in one of seven locations. We need to create a "combo" by selecting one item from each of seven locations; then determine w

Re: [SQL] ichar

2005-10-11 Thread Richard Huxton
Judith Altamirano Figueroa wrote: I moved from postgres 7.0.2 to 8.0.1, If you only have one compatability problem, I'd be surprised. in the 7.0.2 version I process the next query, and it succeed: select ichar(letra_ascii) || '-' || substr('0' ||num_factura,length (num_factura)+1,5) as f

Re: [SQL] Returning NULL results?

2005-10-11 Thread Richard Huxton
Mario Splivalo wrote: Of course, if it returns no rows, I'm presented with an error, saying: ERROR: record "rec" has no field "_qv" This is logical. My question would be is there a way around this withouth first doing SELECT COUNT(*) FROM tmbBids WHERE ..., and then if COUNT(*) is zero THEN b

Re: [SQL] ichar

2005-10-11 Thread Tom Lane
Judith Altamirano Figueroa <[EMAIL PROTECTED]> writes: > ERROR: not exist the function ichar(integer) [ digs in archives... ] Looks like we renamed ichar() to chr() quite some time ago. regards, tom lane ---(end of broadcast)

Re: [SQL] Difference from average

2005-10-11 Thread Richard Huxton
Neil Saunders wrote: Hi all, I'm developing a property rental database. One of the tables tracks the price per week for different properties: CREATE TABLE "public"."prices" ( "id" SERIAL, "property_id" INTEGER, "start_date" TIMESTAMP WITHOUT TIME ZONE, "end_date" TIMESTAMP WITHOUT TIME

[SQL] Returning NULL results?

2005-10-11 Thread Mario Splivalo
_SQL := 'SELECT TmessageId FROM tmpBids WHERE TphoneNumber = ' || quote_literal(phoneNumber) || ' AND Tbid = ' || aBid; FOR rec IN EXECUTE _SQL LOOP bidCount := rec._qv; END LOOP; This works ok as long as the SELECT query returns rows. Of course, if it returns multiple rows bidCo

[SQL] ichar

2005-10-11 Thread Judith Altamirano Figueroa
I moved from postgres 7.0.2 to 8.0.1, in the 7.0.2 version I process the next query, and it succeed: select ichar(letra_ascii) || '-' || substr('0' ||num_factura,length (num_factura)+1,5) as factura from facturas but in 8.0.1 it outputs the next error: ERROR: not exist the function ichar(

Re: [SQL] question re. count, group by, and having

2005-10-11 Thread Tom Lane
"Rick Schumeyer" <[EMAIL PROTECTED]> writes: > Is this a bug or a feature? I'm not sure why I can use 'c' in the order by > clause but not the having clause. pg is much happier with the full "having > count(state) > 5". Actually, referring to any of the output columns in any of the modifier clau

[SQL] Difference from average

2005-10-11 Thread Neil Saunders
Hi all, I'm developing a property rental database. One of the tables tracks the price per week for different properties: CREATE TABLE "public"."prices" ( "id" SERIAL, "property_id" INTEGER, "start_date" TIMESTAMP WITHOUT TIME ZONE, "end_date" TIMESTAMP WITHOUT TIME ZONE, "price" DOUBLE

Re: [SQL] question re. count, group by, and having

2005-10-11 Thread Sean Davis
On 10/11/05 8:50 AM, "Rick Schumeyer" <[EMAIL PROTECTED]> wrote: > The following query returns an error ("column c does not exist") in pg 8.0.3: > > > > (The column 'state' is the two letter abbreviation for a US state) > > > > -- get the number of rows for each state; list in descending ord

[SQL] question re. count, group by, and having

2005-10-11 Thread Rick Schumeyer
The following query returns an error (“column c does not exist”) in pg 8.0.3:   (The column ‘state’ is the two letter abbreviation for a US state)   -- get the number of rows for each state; list in descending order; include only states with at least 6 rows select state, count(state) a

Re: [SQL] SEVEN cross joins?!?!?

2005-10-11 Thread Richard Huxton
Frank Bax wrote: I have a table with only 434 rows in it. Two important columns are "itemid" and "locn". Each item must be in one of seven locations. We need to create a "combo" by selecting one item from each of seven locations; then determine which "combo" is the "best" according to our a

[SQL] SEVEN cross joins?!?!?

2005-10-11 Thread Frank Bax
I have a table with only 434 rows in it. Two important columns are "itemid" and "locn". Each item must be in one of seven locations. We need to create a "combo" by selecting one item from each of seven locations; then determine which "combo" is the "best" according to our analysis (see below