In article <20060814162836.58963.qmail@web31811.mail.mud.yahoo.com>,
Richard Broersma Jr <rabroersma@yahoo.com> writes:
> I am curious, can you calculate something like this using only sql? Or you you need to employee a
> procedural language like plpsgql?
You could use something like
SELECT (SELECT count(*) FROM tbl t2 WHERE t2.id < t1.id), whatever
FROM tbl t1
but correlated subqueries are slow; thus incrementing the counter in
the application would be faster for huge reports.