Hi,<br /><br />I needed ROW_NUMBER() in PostGresql and I did find the 'temporary sequence' method as a workaround and i
thinkit at least gets the job done relatively well, ... so no problems there. <br /><br />Its just that from a
usabilitypoint of view, isn't it better that we provide some kind of an aliasing mechanism here that allows a new user
to(unknowingly but) implicitly use a temporary sequence rather than make him use SubQuery with a COUNT(*) and a
comparisonoperator (with disastrous performance) instead ?? <br /><br />So for a new user :<br /><br />A query such as
this:<br /><br /> SELECT ROW_NUMBER() AS row_number , a, b, c<br /> FROM table<br /> WHERE table_id =
973<br/> ORDER BY record_date;<br /><br />is internally interpreted by the planner as : <br /><br /> CREATE
TEMPSEQUENCE rownum; <br /><br /> SELECT nextval('rownum') AS row_number , t.a, t.b, t.c<br /> FROM (<br />
SELECT a, b, c<br /> FROM table<br /> WHERE table_id = 973<br /> ORDER BY record_date<br />
)t;<br /><br /> DROP SEQUENCE rownum;<br /><br /> <br clear="all" />Any ideas ?<br />(Of what I remember, I think
tillrecently PostgreSql internally replaced 'MAX(x)' queries with a 'ORDER BY x DESC LIMIT 1' implicitly)<br /><br
/>--<br/>Robins