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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not sure how to Query 2

Status
Not open for further replies.

bdichiara

Programmer
Oct 11, 2006
206
US
I have a table that needs to be separated first by `type`, then by `state`, then sorted by `name`

The problem I want `type` to be in a specific order. Right now, there are 3 types:
free, surcharge, and fee

I want them to show up in that order, but i can't do it Alphabetically ASC or DESC.

Inside those 3 groups, I want it to group all similar states together. (this can be alphabetical)

Last, I want each group to be alphabetical (ASC) by `name`.

How would I go about accomplishing this?

_______________
_brian.
 
Code:
order 
    by case when type='free' then 1
            when type='surcharge' then 2
            when type='fee' then 3
                 else 4 end
     , state
     , name

r937.com | rudy.ca
 
excellent! Works perfectly!

_______________
_brian.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top