Re: [SQL] Refactored queries needing validation of syntactic equivalence

2007-10-16 Thread Richard Huxton
Mike Adams wrote: So. The first query should pull all 'MOM' records that have one or more corresponding, and possibly orphaned, unassigned receiving records belonging to the same po_cd and item_cd. The second query should pull all unassigned, and possibly orphaned receiving records that have

[SQL] Inconsistent sql result

2007-10-16 Thread Patrick De Zlio
Hi listers, As a PG administrator, I'm trying to read technical data from pg_class table to monitor tables and indexes space. We are running a quite big postgres platform, with multiple databases, multiples schemes in each database, and hundreds tables. When I run the attach python script, I get

Re: [SQL] Inconsistent sql result

2007-10-16 Thread Gerardo Herzig
Patrick De Zlio wrote: Hi listers, As a PG administrator, I'm trying to read technical data from pg_class table to monitor tables and indexes space. We are running a quite big postgres platform, with multiple databases, multiples schemes in each database, and hundreds tables. When I run the a

[SQL] Having difficulty writing a "best-fit" query..

2007-10-16 Thread Jamie Tufnell
Hi list, I have a many-to-many relationship between movies and genres and, in the link table I have a third field called which orders the "appropriateness" of the relations within each movie. For example: movie_id, genre_id, relevance (i've used movie/genre titles for clarity here, but in realit

Re: [SQL] Having difficulty writing a "best-fit" query..

2007-10-16 Thread Rodrigo De León
On 10/16/07, Jamie Tufnell <[EMAIL PROTECTED]> wrote: > I'm taking a subset of all my genres, and I want to get ONE row for each > movie in the subset alongside its most appropriate genre (whichever has the > highest relevance). In other words, the best fit. You didn't provide the expected output

Re: [SQL] Having difficulty writing a "best-fit" query..

2007-10-16 Thread Richard Broersma Jr
--- Jamie Tufnell <[EMAIL PROTECTED]> wrote: > movie_id, genre_id, relevance (i've used movie/genre titles for clarity > here, but in reality they're id's) > > beverly hills cop, action, 2 > beverly hills cop, comedy, 1 > the heartbreak kid, comedy, 2 >

Re: [SQL] Having difficulty writing a "best-fit" query..

2007-10-16 Thread Michael Glaesemann
On Oct 16, 2007, at 12:14 , Richard Broersma Jr wrote: the only difference was that he was modeling employees and skillsets. IIRC, the terminology for the improved model was the "full disjuctive" model. Off chance, might the full disjunction work be relevant here? http://pgfoundry.org/pr

[SQL] what's wrong with my date comparison?

2007-10-16 Thread Tena Sakai
Hi Everybody, I have a table with a column of timestamp type. It is known to postgres like this: name| character varying | not null value | character varying | not null datecreated | timestamp without time zone | not null when I do query select

Re: [SQL] what's wrong with my date comparison?

2007-10-16 Thread Tena Sakai
Oooops! I got it. I was missing quotes. It must have evaluated 2007-10-02 and used it as a numerical constant 1995. Sorry about commotion. Tena -Original Message- From: [EMAIL PROTECTED] on behalf of Tena Sakai Sent: Tue 10/16/2007 10:57 AM To: pgsql-sql@postgresql.org Subject: [SQL] w

Re: [SQL] what's wrong with my date comparison?

2007-10-16 Thread Andrew Sullivan
On Tue, Oct 16, 2007 at 10:57:03AM -0700, Tena Sakai wrote: > select name, value, datecreated >from mytable > where datecreated > 2007-10-02; ^^ 2007-10-02 is an arithmetic expression equivalent to 1995. I think what you want is WHERE datecreated >

Re: [SQL] what's wrong with my date comparison?

2007-10-16 Thread Michael Glaesemann
On Oct 16, 2007, at 12:57 , Tena Sakai wrote: select name, value, datecreated from mytable where datecreated > 2007-10-02; where datecreated > '2007-10-02' 2007-10-02 = 1995. # select current_date < 2007-10-31 as arithmetic_comparison, current_date < '2007-10-31' as date_comparison;

Re: [SQL] what's wrong with my date comparison?

2007-10-16 Thread Tom Lane
"Tena Sakai" <[EMAIL PROTECTED]> writes: > I was missing quotes. > It must have evaluated 2007-10-02 and used it as a > numerical constant 1995. Actually, what you got was a *textual* comparison between '1995' and the timestamp converted to text, which makes even less sense. FWIW, as of PG 8.3 yo