[SQL] Group by and aggregates

2004-11-04 Thread Michael L. Hostbaek
List, I've got a table looking something like this: my_table some_id int bla bla, partno varchar(100), status varchar(100), cmup numeric(14,2), qty int Here a small sample of contents in my table: some_id partno status cmupqty 1 test1

[SQL] Delayed result from another connection

2004-11-04 Thread SZŰCS Gábor
Dear Gurus, I have a strange scenario that doesn't seem to work flawlessly. I think I can produce a full working example if needed. We use postgresql 7.4.5 It's something like this: %--- cut here ---% CREATE TABLE php_retval(id serial PRIMARY KEY, retval v

Re: [SQL] Group by and aggregates

2004-11-04 Thread Edmund Bacon
Michael L. Hostbaek wrote: List, I've got a table looking something like this: my_table some_id int bla bla, partno varchar(100), status varchar(100), cmup numeric(14,2), qty int My SQL select statement will then group together partno, status and aggregate

Re: [SQL] Group by and aggregates

2004-11-04 Thread Franco Bruno Borghesi
If I understand well, you want the highest cmup for each partno, that is max(cmup) grouped by partno (only). You can achieve this with a subselect, and then you join the results whith the query you already have: SELECT T.partno, T.status, TMP.max_cmup_for_partno, max(T.cmup) AS max_cmup, sum

Re: [SQL] Group by and aggregates

2004-11-04 Thread Michael Fuhr
On Thu, Nov 04, 2004 at 05:54:30PM +0100, Michael L. Hostbaek wrote: > some_id partno status cmupqty > 1 test1 stock 10.00 15 > 2 test2 incoming12.00 10 > 3 test1 incoming15.00 60 > 4 test1 incoming14.00 11 >

Re: [SQL] Group by and aggregates

2004-11-04 Thread Oliver Elphick
On Thu, 2004-11-04 at 16:54, Michael L. Hostbaek wrote: ... > some_id partno status cmupqty > 1 test1 stock 10.00 15 > 2 test2 incoming12.00 10 > 3 test1 incoming15.00 60 > 4 test1 incoming14.00 11 ... > My result

Re: [SQL] Delayed result from another connection

2004-11-04 Thread Tom Lane
=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?= <[EMAIL PROTECTED]> writes: > The php connects to the database and updates retval where id=seq. > It seems to be OK, but the function returns the value of php_retval.retval > _before_ the call. Yes, because your transaction is working with a database snapshot that