當前位置:首頁 » 編程語言 » sql按字母排序

sql按字母排序

發布時間: 2022-12-20 20:29:25

A. access如何用sql語句按首字母排序

可以這樣
一、
sql="select
*
from

order
by
name
asc"
默認就是這樣
二、加一個欄位,在輸入信息的時候,每個名字加個索引字母,然後用那個欄位來排序,例如,張三就是Z,李四就是L,王五是W
sql="select
*
from

order
by
索引欄位
asc"

B. asp中sql語句怎麼能按姓名的首字母排序,並按A,B,C...分組

按拼音首字母進行排序
1,目前暫以歌手的拼音首字母排序

2,資料庫中輸入的歌手名稱,直接漢字(除了外國佬:),不帶任何的首字母前綴

3,解決辦法,用一函數(現成的),功能嘛就是提取一段字元串的首字母

<script language=vbs>
function getpychar(char)
tmp=65536+asc(char)
if(tmp>=45217 and tmp<=45252) then
getpychar= "A"
elseif(tmp>=45253 and tmp<=45760) then
getpychar= "B"
elseif(tmp>=45761 and tmp<=46317) then
getpychar= "C"
elseif(tmp>=46318 and tmp<=46825) then
getpychar= "D"
elseif(tmp>=46826 and tmp<=47009) then
getpychar= "E"
elseif(tmp>=47010 and tmp<=47296) then
getpychar= "F"
elseif(tmp>=47297 and tmp<=47613) then
getpychar= "G"
elseif(tmp>=47614 and tmp<=48118) then
getpychar= "H"
elseif(tmp>=48119 and tmp<=49061) then
getpychar= "J"
elseif(tmp>=49062 and tmp<=49323) then
getpychar= "K"
elseif(tmp>=49324 and tmp<=49895) then
getpychar= "L"
elseif(tmp>=49896 and tmp<=50370) then
getpychar= "M"
elseif(tmp>=50371 and tmp<=50613) then
getpychar= "N"
elseif(tmp>=50614 and tmp<=50621) then
getpychar= "O"
elseif(tmp>=50622 and tmp<=50905) then
getpychar= "P"
elseif(tmp>=50906 and tmp<=51386) then
getpychar= "Q"
elseif(tmp>=51387 and tmp<=51445) then
getpychar= "R"
elseif(tmp>=51446 and tmp<=52217) then
getpychar= "S"
elseif(tmp>=52218 and tmp<=52697) then
getpychar= "T"
elseif(tmp>=52698 and tmp<=52979) then
getpychar= "W"
elseif(tmp>=52980 and tmp<=53640) then
getpychar= "X"
elseif(tmp>=53689 and tmp<=54480) then
getpychar= "Y"
elseif(tmp>=54481 and tmp<=62289) then
getpychar= "Z"
else '如果不是中文,則不處理
getpychar=char
end if
end function
function getpy(str)
for i=1 to len(str)
getpy=getpy&getpychar(mid(str,i,1))
next
end function
alert("布魯斯狼 的拼音首字母是:"&getpychar("布魯斯狼"))
</script>

C. asp中sql語句怎麼能按姓名的首字母排序

sql中按姓名拼音排序 select 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

D. SQL 字母數字排序問題

用數據段取值方式,進行查詢。再用ORDERY BY排序即可。

取值舉例:
Declare @S1 varchar(100)
Select @S1='http://www.xrss.cn' \--這里寫上表的列名欄位即可,不需單引號--\
Select SUBSTRING(@S1,8,3) \--取第8位開始,取3位長度--\
顯示結果: www

你可改成:Select SUBSTRING(@S1,8,7)
------------------------------------

E. plsql 如何設置按英文字母排列對象

1.按照數據排序:

選中需要排序的表格---點排序和篩選---自定義排序----根據下圖配置好排序列表。

F. SQL 按照字母排列

你本來就是字母問題,所以用order
by
name
就行了根據名稱排列,其name系統默認就是按字母排列,當然字母也是首先按第一個字母排列
所以:
select
*
from
table
order
by
name;

G. sql 字母數字組合 排序

截取分段排序

orderbyleft(kh,charindex('-',kh)-1)
,convert(int,substring(kh,charindex('-',kh)+1,charindex('-',kh,charindex('-',kh)+1)-charindex('-',kh)-1))
,right(kh,len(kh)-charindex('-',kh,charindex('-',kh)+1))

H. access如何用sql語句按首字母排序

和你sql排序規則有關系,你重新設置一下sql的排序規則就可以了,(其排序規則為
Chinese_PRC)
--按拼音
ALTER
TABLE
tableName
ALTER
COLUMN
colName
nvarchar(100)
COLLATE
Chinese_PRC_CI_AS
select
*from
tableName
order
by
colName
--按筆畫
ALTER
TABLE
tableName
ALTER
COLUMN
colName
nvarchar(100)
COLLATE
Chinese_PRC_Stroke_CI_AS
select
*from
tableName
order
by
colName

I. sql查詢語句,按首個字母排列集

直接再加一列吧

(select item,'http://www.xxx.com/'+item+'.HTML' as link from casio) union all (select firstname,'#'+firstname from casio group by firstname) order by item

至於每行6列在程序中用while控制更容易實現

J. sql 排序 某個首字母排最前

orderbycasewhen欄位名like'd%'then0else1end,欄位名

熱點內容
隆地優選交易密碼是什麼 發布:2025-05-14 21:53:23 瀏覽:93
強酸強鹼存儲櫃 發布:2025-05-14 21:45:16 瀏覽:563
車輛參數配置包括什麼 發布:2025-05-14 21:31:03 瀏覽:163
怎麼引入安卓項目 發布:2025-05-14 21:26:39 瀏覽:824
游戲輔編程 發布:2025-05-14 21:18:49 瀏覽:687
三菱plc一段二段密碼什麼意思 發布:2025-05-14 21:17:16 瀏覽:528
電腦開機密碼忘記了怎麼破解 發布:2025-05-14 21:09:40 瀏覽:57
pythondict格式 發布:2025-05-14 21:09:38 瀏覽:886
落葉片拍攝腳本 發布:2025-05-14 20:40:49 瀏覽:799
安卓為什麼不能用cmwap 發布:2025-05-14 20:40:43 瀏覽:658