Re: [SQL] Quick question re foreign keys.

2007-10-24 Thread Nis Jørgensen
D'Arcy J.M. Cain skrev: > On Wed, 24 Oct 2007 11:00:47 +0800 > Paul Lambert <[EMAIL PROTECTED]> wrote: >> It's marked not null as a result of being part of the primary key for >> that table which I can't really get around. >> >> I can get away with not having the foreign key though, so I'll have t

Re: [SQL] Table transform query

2007-09-19 Thread Nis Jørgensen
Rodrigo De León skrev: > On 9/18/07, Philippe Lang <[EMAIL PROTECTED]> wrote: >> ... into this: >> >> >> serial dateL dateR >> >> 1 1 2 >> 1 4 >> 2 1 2 >> 3 1 3 >> 4 2 3 >> 5 3 > > SELECT t1.serial, t1.DATE AS datel,

Re: [SQL] Migration from SQLite Help (Left Join)

2007-07-29 Thread Nis Jørgensen
Mitchell Vincent skrev: > SELECT c.customer_id as customer_id,c.customer_number as customer_number, > c.customer_name as customer_name,c.customer_status as > customer_status,cat.category_name as category_name, > c.bill_state as bill_state, coalesce(ctots.balance_due, 0.00) as > balance FROM custome

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

2007-07-23 Thread Nis Jørgensen
Gregory Stark skrev: >> 1. Look up all order_ids for which (order_id,my_invoice_id) appear in >> eg_orders >> >> 2. Find all rows (in both branches of the UNION) with these id_s >> >> 3. Group the rows, and calculate max(invoice_id) >> >> 4. Filter the result rows on max(invoice_id) = my_invoice_i

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

2007-07-22 Thread Nis Jørgensen
Gregory Stark skrev: > Nis Jørgensen <[EMAIL PROTECTED]> writes: > >> Well, the query can be satisfied by looking only at the rows with an >> order_id matching the invoice_id given. The condition that this is the >> largest invoice in the group then needs to

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

2007-07-22 Thread Nis Jørgensen
Tom Lane skrev: >> PG apparently is not smart enough to recognize that the >> result of a max must be one of the values of the column (meaning that it >> can use an index) > > That's because it can't. As written, the query demands sums over groups > that *include* a specific invoice_id --- but e

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

2007-07-22 Thread Nis Jørgensen
Bryce Nesbitt skrev: > I've got a legacy app with a hefty performance problem. The basic > problem is stupid design. It takes 10-15 seconds of CPU time to look up > an invoice. > Basically it's trying to mash up extra columns on an otherwise simple > query, and those extra columns are subtotals.

Re: [SQL] Converting from MS Access field aliases

2007-07-12 Thread Nis Jørgensen
Tom Lane skrev: > This is not an "extension", it is *directly* contrary to both the letter > and spirit of the SQL standard. I can hardly believe that M$ did that > ... oh, actually, I can entirely believe it. The OP has a serious > problem of vendor lockin now, and that's exactly what M$ wants.

Re: [SQL] Informix Schema -> PostgreSQL ?

2007-07-03 Thread Nis Jørgensen
Adam Tauno Williams skrev: >> pg_dump dbname -s -t tableorindexname > > [Also an Informix DBA] Is there a way to tweak the output of pg_dump > when used in this manner to omit the verbose commentary. > > $ pg_dump OGo -s -t enterprise pg_dump OGo -s -t enterprise | grep -v '^--$' Nis --