排序包含零或多个小数点的varchar数据类型列 [英] sorting varchar data type column containing zero or multiple decimal point
问题描述
你好sql开发者,
我想排序数字
1.它可能包含零个或多个小数点,例如1或1.0.1
2.数字可能像00001注意这里我们可以修剪0000使它成为1
>
列数据类型是varchar(50)
例如。
1.
1.2
1.2.1
1.2.3
1.2.3.1
2.
00003在这里我们可以修剪0000使其达到3
5. br />
7
$
以上只是我想做的排序示例。
我怎么写shpuld查询或函数做上面的排序
帮助是需要
问候
Nitin
< blockquote> SA是正确的,数字不能超过一个小数。 RK是正确的,为了清楚起见,他所指的答案是将你的价值观转移到 heirarchyid [ ^ ]类型。< br $> b $ b
选择 * 来自 yourtable ORDER BY CAST(' /' + yourVersionNumber + ' /' AS hierarchyid )
访问这里........
http://stackoverflow.com/questions/17324903/sort-order-on-column-wit h-多个小数位 [ ^ ]
Hello sql developers ,
I want to sort the number
1. It may contain zero or multiple decimal point e.g. 1 or 1.0.1
2. number may be like 00001 Note here we may trim 0000 to make it to 1
Column Data type is varchar(50)
eg.
1.
1.2
1.2.1
1.2.3
1.2.3.1
2.
00003 here we may trim 0000 to make it to 3
5.
7
100
the above one is just example of sorting that i want to do.
how shpuld i write query or function to do above sorting
Help is needed
Regards
Nitin
SA is right, numbers do not have more than one decimal. RK is right, for clarity, the answer he's referring to, is the one that casts your values to the heirarchyid[^] type.
select * from yourtable ORDER BY CAST('/' + yourVersionNumber + '/' AS hierarchyid)
visit here........
http://stackoverflow.com/questions/17324903/sort-order-on-column-with-multiple-decimal-places[^]
这篇关于排序包含零或多个小数点的varchar数据类型列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!