Jerwin Mathew Aton
Jerwin Mathew Aton

Reputation: 77

Mysql syntax to get values by percentage

Im a beginner and I would like to ask how to get the 20% of the Rates Column Values (The Mysql Syntax for this) . How can I make another column using SELECT statement where the values are 20% of the Rates.

+-------------------+----------------------+------+
| Fullname          | position             | rate |
+-------------------+----------------------+------+
| terry, sanchez    | Web Developer        | 1500 |
| bernie, nahoma    | Web Developer        | 1500 |
| marie, viray      | Web Developer        | 1500 |
| lucy, dante       | Web Developer        | 1500 |
| benedict, cruz    | Web Developer        | 1500 |
| jhon paul, arroyo | Web Designer         | 1200 |
| lewis, abante     | Web Designer         | 1200 |
| lito, lapid       | Database Administrat | 1350 |
| jerwin, aton      | Project Manager      | 2000 |
| benjie, cruz      | Dev Ops              | 1250 |
+-------------------+----------------------+------+

Upvotes: 0

Views: 115

Answers (2)

Rohit Sngh
Rohit Sngh

Reputation: 19

select rates, (select (rates * 20) / 100) as percentage from table

This will give you desried result. selecting rates as the first column is totaly optional.

Upvotes: 1

Indraraj26
Indraraj26

Reputation: 1966

select (0.2 * rate) as 20_percent_rate, rate from table

This should work for you.

Upvotes: 1

Related Questions