This topic is locked

How to make multiple calculations from a single table

4/12/2025 12:01:58 PM
PHPRunner General questions
E
ES author

Greetings, I would like to have a single page that performs multiple calculations within one table displaying percentage ratios.
The basic idea what I am trying to do.

SELECT
id,
Item1,
Item2,
item1sub1,
item2sub1,
Item1sub2,
Item2sub2,
(item1sub1 + Item2sub1) AS OutputItem1
(Item1sub2 + Item2sub2) AS OutputItem2
(OutputItem1 / 2) As TotalItem1
(OutputItem2 / 2) As TotalItem2
FROM log_items_percentage_ratio

Thank you for your suggestions :)

Admin 4/12/2025

You are missing some commas. ChaptGPT will be able to fix issues like this in five seconds.

SELECT
id,
Item1,
Item2,
item1sub1,
item2sub1,
Item1sub2,
Item2sub2,
(item1sub1 + Item2sub1) AS OutputItem1,
(Item1sub2 + Item2sub2) AS OutputItem2,
(OutputItem1 / 2) As TotalItem1,
(OutputItem2 / 2) As TotalItem2
FROM log_items_percentage_ratio