如题所述
æ以åæåè¿ç¨MSSQLæ¥è¯¢çï¼è¿æ¯ä»£ç ï¼ä½ å¯ä»¥æµè¯ä¸ä¸ï¼ææ头ä¸æ²¡æACCESSselect isnull(b.py,upper(left(a.username,1))) as py
,a.username
from (
select 'a3' as username
union select UserName from UserTable --ä¿®æ¹è¿éçå§åå~
)
a
left outer join (
select 'A' as PY,N'éª' as word, N'å' as sword
union select 'B',N'ç°¿',N'éª'
union select 'C',N'é',N'ç°¿'
union select 'D',N'éµ½',N'é'
union select 'E',N'樲',N'鵽'
union select 'F',N'é³',N'樲'
union select 'G',N'è ',N'é³'
union select 'H',N'夻',N'è '
union select 'J',N'æ',N'夻'
union select 'K',N'ç©',N'æ'
union select 'L',N'é±³',N'ç©'
union select 'M',N'æ',N'é±³'
union select 'N',N'æ¡',N'æ'
union select 'O',N'沤',N'æ¡'
union select 'P',N'æ',N'沤'
union select 'Q',N'å',N'æ'
union select 'R',N'鶸',N'å'
union select 'S',N'è¶',N'鶸'
union select 'T',N'箨',N'è¶'
union select 'W',N'é¹',N'箨'
union select 'X',N'é',N'é¹'
union select 'Y',N'éµ',N'é'
union select 'Z',N'å',N'éµ'
) b on left(username,1) between b.sword and b.word
where UserName<>'a3' and py='A' --è¿éçand py='A'æ¯æ¥è¯¢ä»¥Aæ¼é³å¼å¤´çå§åï¼ä½ å¯ä»¥ æ¹æå ¶ä»çï¼æè ç´æ¥å»æå°±æ¯æ¥è¯¢ææç~
order by py
,a.username
from (
select 'a3' as username
union select UserName from UserTable --ä¿®æ¹è¿éçå§åå~
)
a
left outer join (
select 'A' as PY,N'éª' as word, N'å' as sword
union select 'B',N'ç°¿',N'éª'
union select 'C',N'é',N'ç°¿'
union select 'D',N'éµ½',N'é'
union select 'E',N'樲',N'鵽'
union select 'F',N'é³',N'樲'
union select 'G',N'è ',N'é³'
union select 'H',N'夻',N'è '
union select 'J',N'æ',N'夻'
union select 'K',N'ç©',N'æ'
union select 'L',N'é±³',N'ç©'
union select 'M',N'æ',N'é±³'
union select 'N',N'æ¡',N'æ'
union select 'O',N'沤',N'æ¡'
union select 'P',N'æ',N'沤'
union select 'Q',N'å',N'æ'
union select 'R',N'鶸',N'å'
union select 'S',N'è¶',N'鶸'
union select 'T',N'箨',N'è¶'
union select 'W',N'é¹',N'箨'
union select 'X',N'é',N'é¹'
union select 'Y',N'éµ',N'é'
union select 'Z',N'å',N'éµ'
) b on left(username,1) between b.sword and b.word
where UserName<>'a3' and py='A' --è¿éçand py='A'æ¯æ¥è¯¢ä»¥Aæ¼é³å¼å¤´çå§åï¼ä½ å¯ä»¥ æ¹æå ¶ä»çï¼æè ç´æ¥å»æå°±æ¯æ¥è¯¢ææç~
order by py
温馨提示:答案为网友推荐,仅供参考