# Force aggregate functions to return data with the same timestamp

What can be done to force the following query to return a single row of data?

``````> SELECT integral(P49), mean(P49), count(P49), min(P49), max(P49) FROM L2 WHERE time >= NOW() - 604800s AND time<NOW()
name: L2
time                integral          mean               count min      max
----                --------          ----               ----- ---      ---
0                   878064.1014254978
1536760367611843633                   1.4520673051503423 3359  0.280718 7.91543
``````

As seen, if integral is performed separately, it returns a single row.

``````> SELECT mean(P49), count(P49), min(P49), max(P49) FROM L2 WHERE time >= NOW() - 604800s AND time<NOW()
name: L2
time                mean               count min      max
----                ----               ----- ---      ---
1536760369666651138 1.4520673051503423 3359  0.280718 7.91543
> SELECT integral(P49) FROM L2 WHERE time >= NOW() - 604800s AND time<NOW()
name: L2
time integral
---- --------
0    878064.1014254978
>``````

As a hack, I suppose I could do the following. Still would like to know the right way to do so.

``````> SELECT integral(P49), mean(P49), count(P49), min(P49), max(P49) FROM L2 WHERE time >= NOW() - 604800s AND time<NOW() GROUP BY time(1209600s) FILL(previous)
name: L2
time                integral          mean               count min      max
----                --------          ----               ----- ---      ---
1536192000000000000 875671.6101544974 1.4486269931527236 3359  0.280718 7.91543
>``````

Turns out that my hack doesn’t work all the time. I first arbitrarily used twice the time range in the WHERE statement as the GROUP BY time duration, and it seemed to work. Elsewhere, however, Influx still responded with two rows; one for the integral and the second for the mean/count/etc. I changed the GROUP BY to 10 times the WHERE duration and it worked, however, I do not know why and can’t believe this is a good approach.

Please, and help would be appreciated. If I haven’t provided enough information, please let me know and I will provide it.

Thanks!