根据最后的整数排序 [英] order by based on last integers
本文介绍了根据最后的整数排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
在我的asp.net应用程序中
我想根据员工的代码对他们进行排序
代码是
Hi
In my asp.net application
I want to sort employees based on their code
code is
emp 1000
emp 23
emp 33
我要按此顺序结果
i want result in this order
emp23
emp33
emp1000
请帮助我
pls help me
推荐答案
以这种方式尝试
try in this way
DECLARE @Table TABLE (ID VARCHAR(30))
INSERT @Table
SELECT ''emp1000'' UNION ALL
SELECT ''emp23'' UNION ALL
SELECT ''emp33''
SELECT ID
FROM @Table
ORDER BY SPACE(50 - LEN(ID))+ ID ASC
您只能在数据库中存储Integer值.查询时,请使用以下方式
You store only Integer value in DB. while querying use the below way
SELECT ID, 'emp'+ID AS EmpID FROM TableName ORDER BY ID
似乎"emp"对于所有记录都是通用的. /> 如果是这样,
您可以修剪所有行中的"emp",
然后将所有记录存储在ArrayList中,
然后对那个ArrayList进行排序,
最后通过在其上附加"emp"来显示ArrayList中的所有对象.
It seems that "emp" is common for all records.
If that the case,
you can trim "emp" from all rows,
then store all records in an ArrayList,
then Sort that ArrayList,
and finally display all objects from ArrayList by appending "emp" to it.
这篇关于根据最后的整数排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文