排序问题 [英] A Sorting Problem
问题描述
这真是老实,我在排序时遇到问题
我的数据库字段是PART_NO,slnoinpart,HOUSE_NO,FM_NAME,... etc
在那个PART_NO中,我有1和2,用PART_NO
中的所有列将两个Part_no的门牌号升序排序
我正在尝试按ASC订购,像这样的订单显示HOUSE_NO
1-10
1-10
1-100
1-100A
我到底想干什么
1-10
1-10
1-11
1-11A
.
.
.
1-99
1-100
如果有更多的字符,例如-,\,A,B,请考虑一下
重复HOUSE_NO
没问题
请任何一个发送查询尽早
Hi,
this is mahesh, iam having problem in sorting
My database Fields is PART_NO,slnoinpart,HOUSE_NO ,FM_NAME, ...etc
in that PART_NO ,i have 1 and 2 ,sort both Part_no ''s House numbers Ascending order with All columns in both PART_NO
i am trying with Order by ASC ,HOUSE_NO shown like this order
1-10
1-10
1-100
1-100A
what exactly i want to do
1-10
1-10
1-11
1-11A
.
.
.
1-99
1-100
if chance to have more characters like - , \ , A ,B consider this also
No problem With Duplicate of HOUSE_NO
Plz any one Send Query As early as possible
推荐答案
问题是数据库中的HOUSE_NO字段是字符串.因此,当您对字符串进行排序时,您将只会得到这样的数据.
the problem is ur HOUSE_NO field in database is string. so when u sort string u will the datas like this only.
select *, cast(SUBSTRING (house_no,1,1) as decimal) as a, cast(SUBSTRING (house_no,3,3) as decimal) as b from e-details
order by a asc ,b asc
这篇关于排序问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!