Hello, Thanks for the help.
On Sun, Mar 10, 2013 at 10:36 PM, Igor Tandetnik <i...@tandetnik.org> wrote: > 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? More than the id, I care about order. When I use my first query, "chu" comes at the end. But since it has a lower id, it should be first. This order defined how my application behaves. Doing min(id) did the trick. Thanks for the help. Thanks to James also for the additional information. > > 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 -- Thanks Navaneeth _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users