An Ordered List

  • Thread starter Thread starter Ste
  • Start date Start date
S

Ste

Hi

My database is MS Access and I need to order records according to a list of
values:

I have a table of sales leads - one of its columns has the name of Status
and this is an id pointing at a lead_status table - the status table has
several records but the leads table has hundreds. What I need to do when I
pull them out to my web page is sort by this status so that all the records
with a status of 3 are brought out first, then 6, then anything except 3, 6
and 1 and finally the last one needs to be 4th.

The web page has also become quite complicated before I got to play with
it - if possible I would prefer not to add anything to the database because
this will mean several hours of manually changing records. Also I don't
want to have to do 4 seperate queries on the web page and then output the
results because this too will mean hours of work.

What I really need is something to finish this query:

SELECT * from lead_tbl

The end of the query then needs to get all records where Status=3 first
Then where Status=6
Then where Status not = 1,3,6
Then where Status=1

And return all of them in one query to the recordset on the Asp page.

Has anyone got a solution to this - it seems something quite simple really -
just needs a function which accepts an ordered list and lets you order by
the result.

Thanks
Steve
 
Add a calculated field to the query, and then order by
it. Something like:-

MyOrder:iif([status]=3,1,iif([status]=6,2,iif([staus]
=1,4,3)))


hth

Chris
 
Back
Top