Re: [SQL] How to cast, if type has spaces in the name

2007-07-26 Thread A. Kretschmer
am Thu, dem 26.07.2007, um 0:33:09 -0700 mailte Bryce Nesbitt folgendes: > How do I specify a cast, if the type name has spaces? foo::integer is > easy, > but foo::'timestamp without time zone' is more murky. Hehe, it works without the ', see: test=# select '2007-01-01'::timestamp without tim

Re: [SQL] Join question

2007-07-26 Thread Paul Lambert
Phillip Smith wrote: Whoops, I forgot the JOIN conditions! Fixed below -Original Message- From: Phillip Smith [mailto:[EMAIL PROTECTED] Sent: Friday, 27 July 2007 11:47 To: 'pgsql-sql@postgresql.org' Subject: RE: [SQL] Join question This might give you a starting point if I understan

[SQL] Join question

2007-07-26 Thread Paul Lambert
I have a database in a parts sales environment that I am having a little difficulty with a join query - trying to figure out which way to join things. I have a parts_invoice_header table, containing the header record for each invoice. I have a parts_invoice_lines table, containing the parts de

Re: [SQL] unique index on fields with possible null values

2007-07-26 Thread Tom Lane
Dmitry Ruban <[EMAIL PROTECTED]> writes: > I'm trying to find a solution for unique index on fields with possible > null values. You appear to be hoping that a unique index would constrain a column to contain at most one null entry. It doesn't work like that, and I strongly urge you to reconsider

Re: [SQL] Join question

2007-07-26 Thread Phillip Smith
Whoops, I forgot the JOIN conditions! Fixed below -Original Message- From: Phillip Smith [mailto:[EMAIL PROTECTED] Sent: Friday, 27 July 2007 11:47 To: 'pgsql-sql@postgresql.org' Subject: RE: [SQL] Join question This might give you a starting point if I understand you correctly... SELE

Re: [SQL] Join question

2007-07-26 Thread Phillip Smith
This might give you a starting point if I understand you correctly... SELECT h.invoice_number, h.customer, l.item, l.amount FROMlines AS l JOINheaders AS h UNION SELECT h.invoice_number, h.customer, s.item, s.amount FROMsundries AS

[SQL] problem join

2007-07-26 Thread chester c young
having problem joining these correctly: schedule - cal_id references calendar not null - usr_id references users not null = unique( calZ_id, usr_id ) - result_no not null activity - cal_id references calendar not null - usr_id references users not null = unique( cal_id, usr_id ) - from_ts timesta

[SQL] unique index on fields with possible null values

2007-07-26 Thread Dmitry Ruban
Hello pgsql-sql, I'm trying to find a solution for unique index on fields with possible null values. Example table: CREATE TABLE test ( a integer NOT NULL, b integer NULL ); As long as unique index can't check if there are records with null values i found the only one solution for this proble

Re: [SQL] How to cast, if type has spaces in the name

2007-07-26 Thread Stephan Szabo
On Thu, 26 Jul 2007, Bryce Nesbitt wrote: > How do I specify a cast, if the type name has spaces? foo::integer is > easy, > but foo::'timestamp without time zone' is more murky. foo::timestamp without time zone should work (no quotes). Another alternative if you don't like the way that looks is

[SQL] Tunning PostgreSQL performance for views on Windows

2007-07-26 Thread Ranieri Mazili
Hello, I'm developing a BI and as database it's using postgresql 8.2, how data are very detailed, I'm creating a view to consolidate the most important data, but the performance of view is very poor, 1 minute to perform more or less without where clause. I need to know how I can increase the perf

[SQL] How to cast, if type has spaces in the name

2007-07-26 Thread Bryce Nesbitt
How do I specify a cast, if the type name has spaces? foo::integer is easy, but foo::'timestamp without time zone' is more murky. In my case I have a table, and a view. For no apparent reason the table has timestamp without time zone, but I need timestamp with time zone. I'm using "select column

Re: [SQL] How to cast, if type has spaces in the name

2007-07-26 Thread A. Kretschmer
am Thu, dem 26.07.2007, um 0:33:09 -0700 mailte Bryce Nesbitt folgendes: > How do I specify a cast, if the type name has spaces? foo::integer is > easy, > but foo::'timestamp without time zone' is more murky. Use timestamp instead ;-) Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/4

Re: [SQL] The nested view from hell - Restricting a subquerry

2007-07-26 Thread Bryce Nesbitt
One down. Total runtime of the simplest query went from 34661.572 ms to .634 ms (45,000 times faster). stage=> explain analyze select * from eg_order_summary_view where invoice_id=1432655; QUERY PLAN