OK, let me give the simplest example possible. Table with 3 integer fields, A, B and C
A B C ---------------------------- 1 1 2 2 1 2 1 2 1 2 2 1 This needs to be sorted on column A asc Then when the value in A is 1 the second sort needs to be asc on column B, but when the value in A is 2 then the second sort needs to be asc on column C. So, the result should be this: A B C ---------------------------- 1 1 2 1 2 1 2 2 1 2 1 2 I could think of various ways to achieve this, but not with one statement. RBS On Wed, Apr 1, 2015 at 2:43 AM, Igor Tandetnik <igor at tandetnik.org> wrote: > On 3/31/2015 7:50 PM, Bart Smissaert wrote: > >> Say I have a table with 3 fields. Depending on a value in field 1 (this >> value will be either 1 or 2) >> I want to do a different sort order sorting on fields 2 and 3. >> This will be either order by field2 desc, field3 desc or field3 desc, >> field2 desc. >> > > Color me dense, but I for one do not understand from this description what > you are trying to achieve. For one thing, you say you want sort order to > depend on field1, which only contains two different values, but you plan to > somehow derive three different sort orders from it. > > Could you show some sample data, in the order you want it to appear? > Perhaps the pattern would be easier to discern this way. > -- > Igor Tandetnik > > > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >