2
I have a question: How do I know how many records you have before a selected value.
For example:
Select * from cidades where nome= 'SAO PAULO' ORDER BY nome
Assuming that the cities table has 500 records and I searched for SAO PAULO, I want to know how many cities there are before SAO PAULO in my search, take into account ORDER BY name
IS
sql-server
,postgresql
ormysql
? The way of doing in each DBMS is different.– Diego Rafael Souza
Preferably sql-server, but I need the 3
– user59669
Basically is what is in the post linked above, is a
SELECT count(*) AS posicao WHERE nome < "São Paulo"
– Bacco
@Diegorafaelsouza see the post I inkei above, has exactly what you said. A sub to find the score (in case it would be the city ID) and another external to rank
– Bacco
I managed in Sql-server SELECT COUNT(COD)- 1 AS TOTAL FROM CODMUNICIPIO WHERE CIDADE <= '" + Cidadeempresa + "', Thanks a lot for the tips, helped a lot
– user59669