The time is not sorted inside aggregate function in this query:
SELECT id,
aggregate(time)
FROM (SELECT *
FROM TABLE
ORDER BY time) AS foo
GROUP BY something;
How can I sort by column inside group by expression?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You shouldn’t have an
ORDER BYon a subquery and you don’t need it.You can add an
ORDER BYto the result of the aggregate function, but that won’t affect how the aggregate function calculates its results.If you want to affect the order in which the aggregate function looks at its arguments then you can can add an
ORDER BYto the aggregate function but only in some databases and in some situations.Examples