In article <20060814162836(dot)58963(dot)qmail(at)web31811(dot)mail(dot)mud(dot)yahoo(dot)com>,
Richard Broersma Jr <rabroersma(at)yahoo(dot)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.