I have a mysql query which stores the result in variable, but when I use the same variable later, It doesnt return the same value. Am I missing something?
SELECT
duration,
@sum_duration := (SUM(duration) OVER (
PARTITION BY user_id,`Date`
)) as sum_duration,
@sum_duration
-- 9*3600*1000*(duration/@sum_duration) as normalized_duration
FROM duration_table
The result of the above query is
'duration', 'sum_duration', '@sum_duration'
'86400000', '172800000', '783413.000000000000000000000000000000'
'86400000', '172800000', '783413.000000000000000000000000000000'
'86400000', '172800000', '783413.000000000000000000000000000000'
'86400000', '172800000', '172800000.000000000000000000000000000000'
'86400000', '172800000', '172800000.000000000000000000000000000000'
'86400000', '172800000', '172800000.000000000000000000000000000000'
'86400000', '172800000', '172800000.000000000000000000000000000000'
'86400000', '172800000', '172800000.000000000000000000000000000000'
'86400000', '172800000', '172800000.000000000000000000000000000000'
'86400000', '172800000', '172800000.000000000000000000000000000000'