On Wed, 2008-07-23 at 12:30 -0400, Igor Tandetnik wrote: > Dennis Cote <[EMAIL PROTECTED]> wrote: > > Andrew Gatt wrote: > >> I have a table of music artist names which i'd like to output in > >> order. Normally i just use: > >> > >> select * from artists order by artist_name; > >> > >> What i'd really like to do is order the artists by name but ignore > >> any "the" or "the," preceding it. > >> > > > > You could try something like this: > > > > select * from t > > order by > > case > > when lower(substr(artist, 1, 3)) = 'the' then substr(artist, > > 4) when lower(substr(artist, 1, 4)) = 'the,' then > > substr(artist, 5) else artist > > end; > > Only change the order of the tests - test for 'the,' (with comma) first, > otherwise you'll never get to it. > > Igor Tandetnik >
Also, the "the" test should be lower(substr(artist, 1, 4)) = 'the ' Otherwise 'they might be giants' would sort as 'y might be giants' which is probably not desirable. David _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users