On 3/10/2013 11:06 AM, Navaneeth.K.N wrote:
select  distinct(lower(pattern)) as pattern, id  from symbols where
value1 = ?1 or value2 = ?1  group by pattern

This returns

"cchu", "20907"
"chchu", "20879"
"chu", "20935"

This is distinct set of patterns, but I am not getting the list
ordered by id. Even if I add a "order by id" to the above query, it
sorts only the above set. But what I need is to get in the following
order.


"chu", "20851"
"chchu", "20879"
"cchu", "20907"

Why do you expect 'chu' to be accompanied by an ID of 20851, and not 20935? These seem to be equally valid choices?

If you want, say, the smallest of the two, just say so:

select lower(pattern) as pattern, min(id) as minid
from symbols where value1 = ?1 or value2 = ?1
group by pattern order by minid;

--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to