I’m trying to build a type of calculator that will add and multiply certain data in my database.
I’m having trouble using the mysql round() function correctly within nested selects (and other counts).
An example of my code is below, any help would be greatly appreciated. (the code looks more complex than it really is….)
This works if I remove the ‘select round’ from each nested select. My goal here is to take the Floor of each of these calculations (some number x count of result), but have each calculation round up.
select
FLOOR
(
select round( 1 *
(
SELECT count(action) from table
)
)
+
select round( .5 *
(
SELECT count(action) from table
)
)
-
select round( .5 *
(
SELECT count(action) from table
)
)
-
select round( .1 *
(
SELECT count(action) from table
)
)
) as total
from table
LIMIT 0,1
Is this what you are after? Because all the table names and field names are the same, it’s really hard to tell what you are trying to do. But, assuming all the fields come from a single table: