Using MySQL Formulas in Summary view

Hi,

I can not be able to have a summary view when i have formulas in my mysql query.

For example, how can i use summary for this query ( a1 and a2 are field)

SELECT
x , Month,
sum(a1) as ‘a1’,
sum(a1) / sum(a2) * 100 as ‘a3’

FROM table group by x, Month

Edit :
Because summary view add another ‘sum’ (ex: sum(sum(a1) / sum(a2) * 100 as ‘a3’ ) and sum in sum is not ok for mysql syntax.

Esto te puede ayudar


SELECT field1,
           month,
           sum((a1 / a2) * 100) as 'a3'
FROM
(SELECT 
         `x` as field1, 
         Month as month, 
         sum(a1) as 'a1', 
         sum(a2) as 'a2'

FROM `table` 
group by `x`, Month ) as view_final



I will try.

Gracias…

[QUOTE=egercek;34120]Hi,

I can not be able to have a summary view when i have formulas in my mysql query.

For example, how can i use summary for this query ( a1 and a2 are field)

SELECT
x , Month,
sum(a1) as ‘a1’,
sum(a1) / sum(a2) * 100 as ‘a3’

FROM table group by x, Month

Edit :
Because summary view add another ‘sum’ (ex: sum(sum(a1) / sum(a2) * 100 as ‘a3’ ) and sum in sum is not ok for mysql syntax.[/QUOTE]

Views are your friends