2011-04-16 58 views
1

我試圖從數據庫的「零售商」中提取數據,並按美國排名第一的國家/地區顯示。然後,按照狀態按字母順序排序,然後按名稱在每個狀態中排序。按國家/地區,州/省,按字母順序排列數據庫中的結果

應該潛在的打印這樣的...

美國

Alabama 
    Acme Retail Store 
    Another Alphabetized Store 

Florida 
    Computer Store 

Wyoming 
    Computer Store Also 

阿爾及利亞

Algerian Retail Store 

大不列顛

English Retail Store 

等等等等。等...

我已經從數據庫中正確拉出來了,只是需要幫助排序它。

有什麼建議嗎?

回答

2
order by 
    case when country = 'usa' then 0 else 1 end asc 
    , country asc 
    , state asc 
    , name asc 

應該這樣做。

+0

國家,隊友呢? – 2011-04-16 16:41:16

+0

謝謝。糾正! – davek 2011-04-16 16:41:44