sql按字母排序
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,字段名