Reputation: 83
Sorry for being to vague last time I asked this question.
I have this existing table in my database the shows the prizes for certain events. I am looking to run a query in phpMyAdmin to correctly make the existing prizes be multiplied by 50, divided by 2 then rounded up to the nearest whole number.
For example rank 1 in event_id 1 would be (120*50)/2 shown as new_prize.
an example of my table is as follows:
event_id ranking prize
1 1 120
1 2 60
2 1 10
2 2 5
I hope I have better explained it this time. Thank you for any help provided.
Upvotes: 0
Views: 2806
Reputation: 1793
You can use ROUND(X)
, CEILING(X)
, FLOOR(X)
for getting round off value
For Example
1.ROUND(X)
select *,round((prize*50)/2) as new_price from events
It will return 5
for values of 4.8
, and 4
for '4.1'
2.CEILING(X)
select *,ceiling((prize*50)/2) as new_price from events
It will return 5
for 4.8
3.FLOOR(X)
select *,floor((prize*50)/2) as new_price from events
It will return 4
for 4.8
thanks..
Upvotes: 2
Reputation: 19882
This is very simple
SELECT round((prize*50)/2) as New_prize FROM table where event_id = 1
And remove WHERE condition to get all records
Upvotes: 0