sqlite - Was it mandatory to put a "distinct" field as the first field in a query? -


just out of curiosity, looks distinct field must placed ahead of other fields, wrong?

see example in sqlite,

sqlite> select ip, distinct code parser; # syntax error? error: near "distinct": syntax error sqlite> select distinct code, ip parser; # works 

why that? have syntax error?

there no such thing "distinct field".

distinct applies fields in query , therefore must appear after select.

in other words, select distinct code, ip really

select distinct code, ip 

rather than

select distinct code, ip 

it selects distinct pairs of (code, ip). result set include repeated values of code (each different value of ip).

it not possible apply distinct single field in way you're trying (group by might useful alternative, need understand you're trying achieve).


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -