Re: [SQL] How do I optimize this?

2009-03-17 Thread Wei Weng
I made a mistake in the queries: They should be update T set t1 = b.aa FROM (select COUNT(1) as aa FROM D WHERE D.da = 1) as b where tkey = ; update T set t2 = b.aa FROM (select COUNT(1) as aa FROM D WHERE D.da = 2) as b where tkey = ; ... update T set t10 = b.aa FROM (select COUNT(1) as aa F

[SQL] How do I optimize this?

2009-03-17 Thread Wei Weng
Hi all. I have the following scenario: A table T (int t1; int t2; ... int t10; int tkey) A table D (int da; int db), And I have the following query update T set t1 = b.aa FROM (select COUNT(1) as aa FROM D WHERE D.da = ) as b where tkey = ; update T set t2 = b.aa FROM (select COUNT(1) as aa FR

[SQL] join

2009-03-17 Thread Ivan Sergio Borgonovo
I'm trying to get rid of the side effect of the left join catalog_promosimple That means I'm expecting at least one row no matter if there is an entry in left join catalog_promosimpleitem but I don't want "duplicates" from catalog_promosimple create table catalog_promosimple ( PromoSimpleID in

Re: [SQL] Exclude fields from SELECT command

2009-03-17 Thread Steve Midgley
At 05:20 PM 3/16/2009, pgsql-sql-ow...@postgresql.org wrote: In-Reply-To: <1992170861895942...@unknownmsgid> References: <1992170861895942...@unknownmsgid> Date: Mon, 16 Mar 2009 22:45:54 +0100 Message-ID: <162867790903161445i78127316s1c0deb3bec0e1...@mail.gmail.com> Subject: Re: Exclude fields

Re: [SQL] Methods declaration

2009-03-17 Thread Tom Lane
> Is it possible to do the same with postgreSql? No, but you can overload function names in Postgres, which can provide a lot of the same notational conveniences. regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subs

Re: [SQL] SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps

2009-03-17 Thread Richard Huxton
Srikanth wrote: > Dear all, > > I have a table that records User Login Sessions with two timestamp fields. > Basically Start of Session and End of a Session (start_ts and end_ts). Each > row in the table identifies a session which a customer has used. > > Data from the table (session): >

[SQL] SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps

2009-03-17 Thread Srikanth
Dear all, I have a table that records User Login Sessions with two timestamp fields. Basically Start of Session and End of a Session (start_ts and end_ts). Each row in the table identifies a session which a customer has used.  Data from the table (session): -  custo

Re: [SQL] diff b/w varchar(N) & text

2009-03-17 Thread Frank Bax
sathiya psql wrote: Is there any big difference between selecting the data type as varchar(N) and text. What is the difference of it when seeing from the performance side ? Check the manual. There is no difference! http://www.postgresql.org/docs/8.3/static/datatype-character.html -- Sent

Re: [SQL] Exclude fields from SELECT command

2009-03-17 Thread sathiya psql
In what way it is devil Clarifications. .. > I know better solution. Use only thin tables. Wide tables are devil. :) >

[SQL] diff b/w varchar(N) & text

2009-03-17 Thread sathiya psql
Hi., Is there any big difference between selecting the data type as varchar(N) and text. What is the difference of it when seeing from the performance side ? I know that, when we know that the number of character will not exceed N, we can use the varchar as datatype. If we dont know we can use th

[SQL] Methods declaration

2009-03-17 Thread Gianvito Pio
Hello, I've just started working with ordbms. I'm searching for differences between postgresql and oracle... Btw, I've found it's possible to declare a method for a specific type in oracle...so if I create a type MyType, I can associate it also a method MyMethodusing the costructors: CREATE T