--- Igor Tandetnik <[EMAIL PROTECTED]> wrote:
> woj <[EMAIL PROTECTED]> wrote:
> > Now, when I run a query:
> > SELECT Mieszalnia.IdMat, Mieszalnia.Partia, Mieszalnia.Kont,
> > Mieszalnia.Uk, Max(Mieszalnia.Data) FROM Mieszalnia;
> > I always get:
> > IdMat   Partia  Kont    Uk      Data
> > 6 33333 33333 sl1 1172135769
> >
> > In this result there is indeed max from Data field but rest of the
> > fields fit not...
> 
> When a SELECT statement involves aggregate functions, all column 
> references in the SELECT must be either parameters to some aggregate 
> functions, or else be also mentioned in GROUP BY clause. SQLite allows, 
> as an extension, departure from this rule, but the row from which values 
> for columns that are neither aggregated nor grouped by are taken is 
> random and unpredictable.
> 
> Specifically, in the query you show, there's no guarantee that values 
> for IdMat, Partia and so on would be taken from the same row from which 
> Max(Data) comes. Even if SQLite really wanted to help you out here, it 
> is impossible in general. Consider:
> 
> SELECT IdMat, Max(Data), Min(Data) from Mieszalnia;
> 
> Which value of IdMat would you expect to see in response to such a 
> query? Should it come from the row with the largest value of Data, with 
> the smallest, or some other?

This thread describes how the non-aggregate values in a group by are 
selected by SQLite:

 http://www.mail-archive.com/sqlite-users@sqlite.org/msg17770.html



 
____________________________________________________________________________________
Yahoo! Music Unlimited
Access over 1 million songs.
http://music.yahoo.com/unlimited

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to