Re: [SQL] SELECT: retrieve only 2 rows next to known row

2005-09-13 Thread Marcin Piotr Grondecki
uot;<'d') ORDER BY ("val") DESC LIMIT 1) ORDER BY ("val"); Effect: id | val +- 3 | c 1 | d 5 | e As desired. Now we can change field/s to watch values for (we were looking into "val", now we'd like to do same work on "id"). (SELECT * FROM "foo" WHERE ("id">='5') ORDER BY ("id") LIMIT 2) UNION ALL (SELECT * FROM "foo" WHERE ("id"<'5') ORDER BY "id" DESC LIMIT 1) ORDER BY ("id"); It gives: id | val +- 4 | a 5 | e 6 | g Once again result as expected in our dreams! :]]] Change table into desired one, change ordering into desired one and... your problem'll be solved, I hope... :]? regards -- Marcin Piotr Grondecki pgpG5iHUzmcVy.pgp Description: PGP signature

Re: [SQL] SELECT with Function

2004-10-03 Thread Marcin Piotr Grondecki
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paulo Nievierowski wrote: | PS: Excuses my poor english. Your english is excellent. MY is poor!! | I create plpgsql function "myfunc(integer)" thats returns of type | record with values from table X (the function decides what record must | be select). T