Re: [SQL] Is it This Join Condition Do-Able? Ooh, ouch, blush

2005-08-17 Thread Mischa Sandberg
The Subject says it all. (author beats a hasty retreat). Quoting Dmitri Bichko <[EMAIL PROTECTED]>: > I don't see what the problem is. > Did you mean to insert (3,'C3') into table c, rather than b? > > create temp table a(keyf int, val text); > > create temp table b(keyf int, val text); > > crea

Re: [SQL] Is it This Join Condition Do-Able?

2005-08-17 Thread Mischa Sandberg
Quoting Dmitri Bichko <[EMAIL PROTECTED]>: > How about: > > SELECT a.keyfld, a.foo1, b.foo2, c.foo3 > FROM a > LEFT JOIN b USING(keyfld) > LEFT JOIN c USING(keyfld) ((( See response at end ))) > > -Original Message- > > [mailto:[EMAIL PROTECTED] On Behalf Of Lane Van > Ingen > > Sent: W

Re: [SQL] SQL output

2005-08-15 Thread Mischa Sandberg
Quoting Simon Law <[EMAIL PROTECTED]>: > > CREATE TABLE tablename (field INTERVAL); > INSERT INTO tablename VALUES('3 weeks'); > SELECT field FROM tablename; > | 21 days | > > The output shows up in days or months but not weeks how do i make Internally, INTERVAL is stored as a 12byte tuple

Re: [SQL] How to alias table columns in result?

2005-08-10 Thread Mischa Sandberg
Quoting nori <[EMAIL PROTECTED]>: > Hi, > > If I have: > 1.) table car with columns index and name > 2.) table driver with columns index, name and car_index > > and query: > SELECT d.*, c.* FROM driver as d LEFT OUTER JOIN car AS c ON > d.car_index=c.index; > > How can I get results that have

Re: [SQL] sum but not grouped by?

2005-08-07 Thread Mischa Sandberg
Quoting Henry Ortega <[EMAIL PROTECTED]>: > Is it possible at all to do this without any joins > or subselect? Nope. But I'm curious why you make that a condition? ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an a

Re: [SQL] sum but not grouped by?

2005-08-05 Thread Mischa Sandberg
Quoting Henry Ortega <[EMAIL PROTECTED]>: > I have the ff data: > > id | date | hours > AAA07-01-2005 3 > AAA07-02-2005 4 > BBB07-01-2005 6 > BBB07-02-2005 2 > BBB07-03-2005 7 > > Would it be possible to

Re: [SQL] getting back autonumber just inserted

2005-07-09 Thread Mischa Sandberg
Quoting "jimmy.olsen" <[EMAIL PROTECTED]>: > I don't know how to create a Global Variable in Postgres, but the > idea is > very simple: > 1. Encapsulate the NextVal function in MyNextVal > 2. Set to Global variable with NextVal of the desired sequence > 3. Inspect to value of the global variable (

Re: [SQL] How do write a query...

2005-06-10 Thread Mischa Sandberg
> |From: Alain Reymond [mailto:[EMAIL PROTECTED] > |Sent: Mittwoch, 01. Juni 2005 18:01 > |Subject: [SQL] How do write a query... > | > |I have a table like > |IdNum Date AValue > |1 10 01/01/2005 50 > |2 10 31/05/2005 60 > |3 25

Re: [SQL] How do I quit in the middle of a SQL script?

2005-05-20 Thread Mischa Sandberg
Quoting John DeSoi <[EMAIL PROTECTED]>: > > On May 20, 2005, at 1:22 PM, Wei Weng wrote: > > > Say if I want to add a small snip of code in front of the sql script > > generated by the pg_dump, to check for something then if the condition > > doesn't match, the script terminates right away. (W

[SQL] Doing range-predicates right (correction)

2005-05-08 Thread Mischa Sandberg
A few weeks ago I posted a way to do efficient range predicate joins, given only B-tree indexes. I've since gotten back home and looked at the code I last used. My apologies for an offhand hasty posting. The following is the solution I worked out when I used this method on a large data conversion.

[SQL] HELP: aggregating insert rule for multirow inserts.

2005-05-04 Thread Mischa Sandberg
I'm having a problem with the use of the NEW rowset, in a rule intended to aggregate across inserts. I've never really grokked how NEW and OLD really work, syntactically, other than that they seem to be implicit in every top-level FROM clause, and any mention elsewhere gets an error: '42P01: re

Re: [SQL] Trimming the cost of ORDER BY in a simple query

2005-05-02 Thread Mischa Sandberg
Quoting [EMAIL PROTECTED]: > I have a simple query with a pretty high cost (EXPLAIN ...), and I'm > wondering if I can somehow trim it. > > Query (shows the last 7 dates): > > => SELECT DISTINCT date_part('year', uu.add_date), > date_part('month', > uu.add_date), date_part('day', u

Re: [SQL] weird SQL statement question

2005-04-23 Thread Mischa Sandberg
Quoting Frank Bax <[EMAIL PROTECTED]>: > At 01:55 PM 4/23/05, Tadej Kanizar wrote: > > >Ok, so I installed the latest version of Postresql (8.02) on a WinXP > SP2 > >machine.. > > > >My question is why won't the statement SELECT * FROM table work, > whereas > >the statement SELECT *

Re: [SQL] getting count for a specific querry

2005-04-08 Thread Mischa Sandberg
Quoting Scott Marlowe <[EMAIL PROTECTED]>: > On Fri, 2005-04-08 at 12:08, Joel Fradkin wrote: > > I might have to add a button to do the count on command so they don't get > > the hit. > > I would want it to return the count of the condition, not the currently > > displayed number of rows. > > Ju

Re: [SQL] SQL Question

2004-11-21 Thread Mischa Sandberg
Igor Kryltsov wrote: We have table create table group_facility ( group_id integer not null, facility_id integer not null ) It stores facilities membership in group. For example: "North Region" - facilityA, facilityB I need to extract groups from this table which contain facilityN AND facilityZ and

[SQL] CREATE TRIGGER ... FOR EACH STATEMENT

2004-11-07 Thread Mischa Sandberg
I notice a dearth of description of the FOR EACH STATEMENT flavour of triggers, even though OLD_TABLE and NEW_TABLE are mentioned. After years of Sybase & MSSQL, being able to deal with the entire INSERTED/DELETED rowsets in a trigger, rather than nibbling away row by row, has been a great effici

Re: [SQL] CREATE TRIGGER ... FOR EACH STATEMENT

2004-11-07 Thread Mischa Sandberg
Please ignore this, I just caught up with news in c.d.p.hackers Mischa Sandberg wrote: I notice a dearth of description of the FOR EACH STATEMENT flavour of triggers, even though OLD_TABLE and NEW_TABLE are mentioned. After years of Sybase & MSSQL, being able to deal with the entire INSE

Re: [SQL] Join Table

2004-11-07 Thread Mischa Sandberg
T E Schmitz wrote: On Mon, Nov 01, 2004 at 04:34:32PM +, T E Schmitz wrote: Question: is it necessary/advisable to create an index for the ITEM_FK column? Or is this redundantbecause this column is already one of the PK columns? However, read the "Multicolumn Indexes" section in the "Indexes"

Re: [SQL] olympics ranking query

2004-08-25 Thread Mischa Sandberg
That 'running aggregate' notion comes up quite regularily, and it has a number of nonintuitive holes, to do with what happens when your ordering allows for ties. ASTRID had it, RedBrick SQL had it, the latest MSSQL has it ... not necessarily a recommendation. Tom Lane wrote: David Garamond <[EMAIL

Re: [SQL] Triggers - need help !!!

2004-07-09 Thread Mischa Sandberg
"Richard Huxton" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Pradeepkumar, Pyatalo (IE10) wrote: > > IF UPDATE(CreateTime) THEN > > > > > > END IF; > > > > Is this syntax correct. > > No, and I don't recall seeing anything like it in the manuals. ... and it's always an