Jump to content

Recommended Posts

Hi!

 

Let's say I've retrieved some data from a DB...

I've got two different prices: $currentprice and $previousprice..

 

I would like to work out which have the highest increase in price from my list...

I managed to work out porcentages by doing something like:

 

$evolution = ($row[currentprice]-$row[previousprice])/$row[previousprice]*100;

 

but I would like to select the top 10 highest increases for example...

 

Can you do that?

 

Thank you very much!

Link to comment
https://forums.phpfreaks.com/topic/54796-solved-sql-query/
Share on other sites

right!

 

I tried that... I don't know what the name of the new variable will be... I tried $difference it's ok!! great!

 

do you know how to find out what are the name of the original variables that selected?

 

The DB has the following:

 

id, players, previousprice, currentprice and nickplayer...

 

you see I need to show the name of the top 5 players that have increased it's price the highest...

 

Thank you for your help!

Link to comment
https://forums.phpfreaks.com/topic/54796-solved-sql-query/#findComment-271014
Share on other sites

ok.. after a little testing I got the rest...

 

I had to add the "players" to the query:

 

SELECT players, (currentprice - previousprice) AS difference FROM table ORDER BY difference ASC LIMIT 1

 

then it was:

 

$row['difference'] and $row['players']...

 

thanks a lot

 

Link to comment
https://forums.phpfreaks.com/topic/54796-solved-sql-query/#findComment-271036
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.