"jose isaias cabrera" <[EMAIL PROTECTED]>
wrote in message news:[EMAIL PROTECTED]
> I would like to have the results of a select be returned sorted in an
> specific way.  Let me show you what I mean:
>
> sqlite> SELECT PSubClass FROM LSOpenJobs WHERE subProjID = 2190 GROUP
> BY PSubClass;
> DOC-Trans
> DTP
> PM
> Post-Proc
> Pre-Proc
> sqlite>
>
> What I would like is to have the SELECT result be,
>
> Pre-Proc
> Post-Proc
> DOC-Trans
> DTP
> PM
>
> is this possible?  Yes, I know I can sort it in the program, but how
> can I get this special sort from the DB?


Create a table specifying a desired sort order, like this:

create table SortOrder(PSubClass primary key, rank integer);
insert into SortOrder values('Pre-Proc', 1);
insert into SortOrder values(Post-Proc', 2);
...

SELECT distinct j.PSubClass
FROM LSOpenJobs j join SortOrder o on (j.PSubClass = o.PSubClass)
WHERE subProjID = 2190
order by rank;




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

Reply via email to