Re: SQLite - Unwanted values using group-by
| From: | Simon Schick | Date: | Tue, 10 Jul 2012 23:45:35 +0000 |
| Subject: | Re: SQLite - Unwanted values using group-by | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-318423@lists.php.net to get a copy of this message | ||
On Sun, Jul 8, 2012 at 12:33 AM, Matijn Woudt <tijnema@gmail.com> wrote:
>
> Both of the results are valid outcomes. I think you don't understand
> the GROUP BY clause well enough. The parameters in the SELECT clause,
> should be either
> 1) an aggregate function (like the max function you're using)
> 2) one of the parameters in the GROUP BY clause.
> If not one of the above, it will return 'random' values for r.month
> and r.year. (probably the first it finds, which might differ in your
> test cases)
>
> - Matijn
Hi, Matijn
But I think you get what I mean, when I say that max() should only
point to one row, in this case the one with the latest date ;)
How is it possible to, for sure, get the data of this rows?
Btw: Here's someone talking about that ... Out of reading this, it
should work as expected.
http://stackoverflow.com/questions/1752556/is-it-safe-to-include-extra-columns-in-the-select-list-of-a-sqlite-group-by-quer#answers
Bye
Simon