Welcome! Log In Create A New Profile

Advanced

Windev Request - Update with Rank

Posted by spinx 
Windev Request - Update with Rank
November 05, 2025 09:32AM
Hello,
I have an Itemstable in my database HF containing this columns: codeItem, libItem, prixceItem, and rankPrice (see attached). I need a query or source code in Windev that updates the rankItem column like this:
For a given item code, the row with the lowest price should have the rankItem column set to 1, the row with the second lowest price should have the rankItem column set to 2, and the row with the third lowest price should have the rankItem column set to 3.
See attached for an example of how this column will be filled.

Thank you in advance for your help.
Attachments:
open | download - 2025-11-05_093112.jpg (80 KB)
Re: Windev Request - Update with Rank
November 05, 2025 11:09AM
You can sort the values in the sql-statement:

SELECT
"Order".OrderID AS OrderID,
"Order".Code AS Code,
"Order".Name AS Name,
"Order".Price AS Price,
"Order".Rank AS Rank
FROM
"Order"
ORDER BY
Code ASC,
Price ASC


Then you can use this code:

i, n are int
n = TableCount(TABLE_Orders)

FOR i = 1 _TO_ n

IF i = 1 THEN
TABLE_Orders.COL_Rank = 1
ELSE
IF TABLE_Orders.COL_Code = TABLE_Orders.COL_Code[i-1] THEN
IF TABLE_Orders.COL_Price = TABLE_Orders.COL_Price[i-1] THEN
TABLE_Orders.COL_Rank = TABLE_Orders.COL_Rank[i-1]
ELSE
TABLE_Orders.COL_Rank = TABLE_Orders.COL_Rank[i-1] + 1
END
ELSE
TABLE_Orders.COL_Rank = 1
END
END
END
Re: Windev Request - Update with Rank
November 05, 2025 02:22PM
Thank you so much Markus K. for your help.

I have another problem
The records in the table displaying the query results are not displayed in the order specified by the query. Do you have any idea how to do : the ordrer of table records is the same order configured in the query.

Best Regardsthumbs up
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: