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
Post a Comment