Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I guess this is a rather simple SELECT question...

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
I'm just trying to order some data correctly. In that respect, I've got the following SELECT statement...

SELECT * FROM BKMASTER WHERE MATKEY='MCCOECO' ORDER BY MEDSTA ASC

The thing is, there are only about 5 two-digit options for MEDSTA: NULL, "OE" "OP" "RT", etc. I want any records with blank MEDSTAs to come first, then records where MEDSTA='RT' to come second, then whatever else. I've tried a few different things, but who am I fooling? I don't have a clue how to do this!

It's worth a star!!

Much appreciated.

Cyprus
 
order by
case
when medsta = '' then 1
when medsta = 'RT' then 2
...
end

this should get you in the right direction.

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top