El 07/10/2016, a las 19:20, JORGE MALDONADO <jorgemal1960@gmail.com> escribió:Let´s say that I have the following simple SELECT statement:SELECT first, id FROM customers ORDER BY firstThis would result in something like this:Charles C1001John A3021Kevin F2016Paul N4312Steve J0087Is it possible to include a "field" in the SELECT such that it represents the position of each record?For example, I need to get a result like this:1 Charles C10012 John A30213 Kevin F20164 Paul N43125 Steve J0087Respectfully,Jorge MaldonadoHi:If you need the order in the result (not physically) can try this code:SELECT (SELECT COUNT(*) FROM customers o WHERE (o.first = c.first) and (o.id = c.id)) AS position, c.first, c.id FROM customers c order by c.firstHope this help,Best regards.
Let´s say that I have the following simple SELECT statement:SELECT first, id FROM customers ORDER BY firstThis would result in something like this:Charles C1001John A3021Kevin F2016Paul N4312Steve J0087Is it possible to include a "field" in the SELECT such that it represents the position of each record?For example, I need to get a result like this:1 Charles C10012 John A30213 Kevin F20164 Paul N43125 Steve J0087Respectfully,Jorge Maldonado
pgsql-sql by date:
Соглашаюсь с условиями обработки персональных данных