with T as (
select ROW_NUMBER() over (partition by c_state order by c_state ) c_stateRN,
c_state ,
ROW_NUMBER() over (partition by c_city order by c_city ) c_cityRN ,
c_city ,c_address from customerLocations
)
select case when c_stateRN = 1 then c_state else null end c_state , case when c_cityRN = 1 then c_city else null end c_city , c_address
from T
תגובת אחת.