I do not know exactly how to formulate this question, but here it is. I want to reuse the values that I calculated in my query to calculate another value. Variables are the right word that I think. here is my request:
SELECT
t1.label as label,SUM(t1.totalEvents) as Entry,SUM(t2.totalEvents) as Back,
ROUND(Entry/Back*100,2) as 'Rate'
FROM
trackReports_daily t1
.... rest of query ...
Inside the round, I want to use the value returned by SUM (t1.totalEvents), but when I use Entry, I get this errorUnknown column 'Entry' in 'field list'
How else can I get the value there without recounting every time like this:
ROUND(SUM(t2.totalEvents)/SUM(t1.totalEvents)*100,2)
source
share