関係のない単一のテーブルがあります。フィールドcountyNameが長さゼロの文字列の場合Statewide
、結果セットに含める必要があります。それ以外の場合は、フィールドの値をそのままにしておく必要があります。たとえば、2番目の列に「Statewide」と「countyName」があることに注意してください。countyNameは、データベースに実際に格納されている元の値である必要があります。
`countyName` `address`
blah blah
Jackson blah blah
する必要があります(両方の例の最初の行は列名です)
countyName address
Statewide blah blah
Jackson blah blah
これが私が試したことです。この例の残りのフィールドは無視してかまいません。
select case servicetype
when 'cr' then 'Community Resource'
when 'ed' then 'Education'
when 'fb' then 'Faith-based'
when 'me' then 'Medical Equipment'
when 'hc' then 'Health Care'
else 'Other'
end as serviceType
,case countyName
when '' then 'Statewide'
else 'countyname' end
,name
,physicaladdress
,city
,statelocation
,zip
,phone
,website
from main
order by countyName, servicetype, name