How to list a column with update?

Asked

Viewed 87 times

0

Hi, I’m new to sql and need help:

I have the following columns:

Usuário | Ranking | Posição 
Fulano      300        1
Ciclano     400        2 
Beltrano    500        3

I wanted to know how to put this position 1 2 3... without being manual as I do and yes through an sql command, always adding 1 more to be in order: 1 2 3 4 5... and has to be according to the ranking, who has lower ranking gets the first positions

I need a command update to do this, because every week I have to change positions.

I tried to use DECLARE @contador = 1, but I could not use this command in SQL. It gave Unrecognized statement type error. (near "DECLARE"). I’m doing it for phpmyadmin. Could someone help me how to do this?

  • Which SQL are you using? Mysql, SQL Server, Postgresql... ?

  • Why do you need to save the position if you already have the ranking, which is what defines it? Wouldn’t it be better to resolve this in the application?

  • I’m using Cpanel’s phpmyadmin. I don’t understand much about it. Help?

  • I don’t know if you’ll understand any more: I’m counting the column row and that count is what the rankings numbers are 1,2,3... and then after that I use an if so that according to last week’s rankings and this week’s rankings, it shows whether it remained stable, or fell or rose in the rankings, manually filling the ranking column. Example: in the ranking column, the person is in position 2, and in the count of the columns she is in position 1, so she went up... I don’t know if I could understand, but my problem is that I wanted to enter in the ranking table the values in order 1,2,3... without being manually.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.