[SQL] One Question Answered

2001-01-17 Thread Josh Berkus
Folks- Answered my own question about the backslashes before spaces, in text returned as results from functions: it's a bug in kpsql, one of the interface tools I was using. Somebody might want to forward this to the Interfaces list. -Josh Berkus

[SQL] Re: update help

2001-01-17 Thread Tom Lane
Carolyn Lu Wong <[EMAIL PROTECTED]> writes: > Forgot to mention that I'm using V6.5. Oh. 6.5's support for sub-selects is pretty limited :-(. I think the only way to do it in 6.5 is with a temp table, eg SELECT id, sum(amount) as sum into temp table tt from t2 group by id; update t1 set amount

Re: [SQL] update help

2001-01-17 Thread Josh Berkus
Tom, > UPDATE t1 SET amount = (select sum(b.amount) from t2 b > WHERE t1.id = b.id); Interesting. I'm used to (not necessarily in PGSQL): UPDATE t1 SET amount = t2ttl.totalamount FROM (SELECT sum(amount) as totalamount, id FROM t2 GROUP BY id) t2ttl WHERE t1.id = t2.id Althoug

[SQL] Re: update help

2001-01-17 Thread Carolyn Lu Wong
Forgot to mention that I'm using V6.5. It doesn't seem to like subqueries, got the following error: ERROR: parser: parse error at or near "select" What I really want to do is follows t2: ID Amount --- 1 1 .. 1

[SQL] Re: update help

2001-01-17 Thread Carolyn Lu Wong
This update field with the sum of all amounts in t2. I want to update sum of each individual IDs. Tubagus Nizomi wrote: > > update t1 > set amount = sum(b.amount) > from ts b > where a.id=b.id > > On Thursday 18 January 2001 09:54, Carolyn Wong wrote: > > I'd like to know what's the correct SQ

Re: [SQL] update help

2001-01-17 Thread Tom Lane
Carolyn Wong <[EMAIL PROTECTED]> writes: > I'd like to know what's the correct SQL statement to do the following: > updatet1 a > set a.amount = sum(b.amount) > from t2 b > where a.id = b.id Try UPDATE t1 SET amount = (select sum(b.amount) from t2 b WHERE t1.id = b.id); Or possibly yo

Re: [SQL] update help

2001-01-17 Thread Tubagus Nizomi
update t1 set amount = sum(b.amount) from ts b where a.id=b.id On Thursday 18 January 2001 09:54, Carolyn Wong wrote: > I'd like to know what's the correct SQL statement to do the following: > > updatet1 a > set a.amount = sum(b.amount) > from t2 b > where a.id = b.id

[SQL] update help

2001-01-17 Thread Carolyn Wong
I'd like to know what's the correct SQL statement to do the following: update t1 a set a.amount = sum(b.amount) fromt2 b where a.id = b.id

Re: [SQL] Select 'Sunday' in month ??

2001-01-17 Thread [EMAIL PROTECTED]
E.g. create table mytable (created datetime); insert into mytable values ('01-01-2001'); ... insert into mytable values ('01-31-2001'); select created from mytable where date_part('dow', created) = 7 and date_part('month', created) = 1; Troy > > i want to select date in january where day='S

[SQL] Select 'Sunday' in month ??

2001-01-17 Thread Tubagus Nizomi
i want to select date in january where day='Sunday' any idea ?? please help me Nizomi

[SQL] Re: Boolean and Bit

2001-01-17 Thread Keith Gray
Josh Berkus wrote: > > > The solution to this is not to use BLOBs, but rather to use file system > handles for the location of the binary data on the server. This way, > all you need is DOS-to-UNIX and UNIX-to-DOS translation for the > filesystem handles, something easily accomplished through >

Re: [SQL] RE: Help with query. (*)

2001-01-17 Thread Josh Berkus
Mike, In that case, you want to use this construction: DELETE FROM a WHERE EXISTS ( SELECT 1 FROM b WHERE b.1 = a.1 AND b.2 = a.2 AND b.3 = a.3 ); Of course, a good primary keying system would make this somewhat less complex ...

[SQL] Re: Help with query. (*)

2001-01-17 Thread Ken Corey
[NOTE: I'm a pgsql newbie myself. Take this reply with a large-ish grain of salt!) Shouldn't it be something straightforward like: select a.a, a.b, a.c, ... from a a, b b where a.x = b.x, and a.y = b.y, ... (I'd watch out for too many clauses here...

[SQL] Re: [INTERFACES] outer join in PostgreSql

2001-01-17 Thread Ross J. Reedstrom
On Tue, Jan 16, 2001 at 06:44:18PM +0200, Hannu Krosing wrote: > > To get a feel you could use MS Access visual query builder and then view > the source. > I have not checked it lately, but it very likely produces SQL92 > compliant outer joins. > I fired up MS-Access 97SR1, just to see, and her

[SQL] Re: Yet one more question

2001-01-17 Thread Josh Berkus
Justin, > How do you do the "drop and create" of tables? 1. Save table definition as text. 2. Create a duplicate of the table definition as "temp_table" 3. INSERT all of the table records into the temp_table 4. DROP the existing table 5. Re-CREATE the table with the altered definition. 6. I

Re: [SQL] Re: Boolean and Bit

2001-01-17 Thread Josh Berkus
Josh Berkus wrote: > Well, yes. This is beacause BLOBs are NOT part of the SQL > standard and IMHO a bad idea relationally; thus their > implementation is entirely proprietary to the RDBMS. The > solution is not to use BLOBs. Ooops. Let me re-state: This is because the *implementation* of BL

[SQL] Re: [INTERFACES] outer join in PostgreSql

2001-01-17 Thread Hannu Krosing
Thomas Lockhart wrote: > > Mauricio Hipp Werner wrote: > > > > I need help, which is the symbol used in postgreSql to carry out the outer > > join. > > > > in oracle the is used (+) > > in sybase the is used * and > > in postgreSql? > > The PostgreSQL outer join is accomplished using SQL92 synt

Re: [SQL] sort order with < & > in varchar fields

2001-01-17 Thread Tom Lane
Rolf Johansson <[EMAIL PROTECTED]> writes: > Is there documentation on how >= and <= works with varchar > fields? Does pg count in the "," character or ignore it? That depends. If you compiled with --enable-locale then it's whatever strcoll() says for the locale you are running the postmaster in

[SQL] sort order with < & > in varchar fields

2001-01-17 Thread Rolf Johansson
It is possible to extract rows in a table using SELECT name FROM table WHERE name >= 'Bergman'. The problem I have is that I get names like "Berg, Paul" with this query, and I don't want that. Is there documentation on how >= and <= works with varchar fields? Does pg count in the "," character o

[SQL] speed of recursive queries, 7.1

2001-01-17 Thread Kovacs Zoltan Sandor
I experienced terrible speed decrease with some recursive PLPGSQL functions in 7.1beta3. Has anybody got similar behaviour? Details soon... Zoltan

Re: [INTERFACES] Re: [SQL] improve performance

2001-01-17 Thread Jan Wieck
Hannu Krosing wrote: > Tom Lane wrote: > > > > > > I've heard lots of people want to increase BLCKSZ, but you're the first > > one who ever wanted to reduce it. You sure you want to do this? It's > > going to make the maximum row length uncomfortably short. > > And it may even not work, as some

[SQL] newby question

2001-01-17 Thread Uwe Sander
Hello, does anybody know how to iterate over an array column in a plsql function? We want to do something like begin for i in 0.. loop end loop Thx Uwe