Re: [SQL] Odd PL/PgSQL Error -- relation "X" does not exist when using index expression

2007-02-17 Thread Bruce Momjian
Michael Fuhr wrote: > On Thu, Feb 08, 2007 at 10:32:25AM -0500, Tom Lane wrote: > > My advice is not to try to execute multiple commands in the same EXECUTE > > string --- if we were going to do anything to "fix" this, I think it > > would be along the lines of enforcing that advice. Trying to mak

Re: [SQL] sub-limiting a query

2007-02-17 Thread Louis-David Mitterrand
On Sat, Feb 17, 2007 at 07:21:40PM +0100, M.P.Dankoor wrote: > Louis-David Mitterrand wrote: > > > I thought of another solution, actually it's of those top n query tricks > that I picked up somewhere, can't remember > where. > Assuming that your table is called shows, the following query should

Re: [SQL] sub-limiting a query

2007-02-17 Thread M.P.Dankoor
Louis-David Mitterrand wrote: Hello, I've got a table of shows with different types (movie, theater, ballet,etc.) and I am looking for a select that can return the 10 last entered shows AND at most 2 of each type. Is that possible in one query? The table looks basically like: created_on

Re: [SQL] sub-limiting a query

2007-02-17 Thread Andreas Kretschmer
Louis-David Mitterrand <[EMAIL PROTECTED]> schrieb: > ballet,etc.) and I am looking for a select that can return the 10 last > entered shows AND at most 2 of each type. Is that possible in one query? A similar question i found in the archive and there are a couple of answers: (for the second par

Re: [SQL] sub-limiting a query

2007-02-17 Thread M.P.Dankoor
Louis-David Mitterrand wrote: Hello, I've got a table of shows with different types (movie, theater, ballet,etc.) and I am looking for a select that can return the 10 last entered shows AND at most 2 of each type. Is that possible in one query? The table looks basically like: created_on

Re: [SQL] ordering of selected rows from an ordered subselect

2007-02-17 Thread Tom Lane
"Rajesh Kumar Mallah" <[EMAIL PROTECTED]> writes: > select id , name , expensive_func(name) from > ( select id , name from tab order by c1 desc limit 15) as foo ; > is it guaranteed that the final result is order by c1 ? The sub-select's output will be emitted in the specified order.

Re: [SQL] ordering of selected rows from an ordered subselect

2007-02-17 Thread Andrew Sullivan
On Sat, Feb 17, 2007 at 03:02:06PM +0530, Rajesh Kumar Mallah wrote: > > select id , name , expensive_func(name) from >( select id , name from tab order by c1 desc limit 15) as foo ; > > is it guaranteed that the final result is order by c1 ? No, because expensive_func(name) might d

Re: [SQL] sub-limiting a query

2007-02-17 Thread A. Kretschmer
am Sat, dem 17.02.2007, um 13:56:35 +0100 mailte Louis-David Mitterrand folgendes: > Hello, > > I've got a table of shows with different types (movie, theater, > ballet,etc.) and I am looking for a select that can return the 10 last > entered shows AND at most 2 of each type. Is that possible

[SQL] sub-limiting a query

2007-02-17 Thread Louis-David Mitterrand
Hello, I've got a table of shows with different types (movie, theater, ballet,etc.) and I am looking for a select that can return the 10 last entered shows AND at most 2 of each type. Is that possible in one query? The table looks basically like: created_on | timestamp without tim

[SQL] ordering of selected rows from an ordered subselect

2007-02-17 Thread Rajesh Kumar Mallah
Hi, we know that rows in a table are not stored in any particular order and explicit order by clause is required to get data in any particular order. but does it apply to select queries from ordered subselects also ? eg select id , name , expensive_func(name) from ( select id , name f