The decimal value needs to round up to the nearest integer, it doesn't matter if the fractional part is greater or less than .5.
Here is my query:
SELECT MONTH_
, COST
, DISC_COST / COST AS 'amount'
, DISC_COST
, PROFIT
FROM arr
WHERE MONTH_ LIKE 'JANU%'
These are the result:
MONTH_ COST amount DISC_COST PROFIT
January 200 1 200 70
January 3500 2,414285714 8450 7250
January 4500 1 4500 2900
January 28500 0,631578947 18000 11200
January 600 1 600 100
2 Answers
Use CEIL() function (MySQL/Postgres).
Use CEILING() function (MS SQL).
SELECT
MONTH_ ,
COST ,
CEIL((DISC_COST / COST)) AS 'amount' ,
DISC_COST , PROFIT
FROM
arr
WHERE
MONTH_ LIKE 'JANU%'
You can use trunc() to make it integer value by just cut off the decimal values.
SELECT MONTH_ , COST , TRUNC(DISC_COST / COST) AS 'amount' , DISC_COST , PROFIT FROM arr WHERE MONTH_ LIKE 'JANU%'