如何在插入值后立即在表的最后设置行值 [英] how to set row value at last of table even after inserting values
本文介绍了如何在插入值后立即在表的最后设置行值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
create table callRecords
(
srNo int identity(1,1),
mode varchar(20)
)
<pre lang="sql">
insert into callRecords values ('Email')
insert into callRecords values ('Telephone')
insert into callRecords values ('Others')
insert into callRecords values ('fax')
insert into callRecords values ('paper')
select * from callRecords
</pre>
$上面查询的b $ b输出是
srNo模式
1电子邮件
2电话
3其他
4传真
5张纸
但我想要'其他'的价值在表格的最后,即使进一步插入值后
srNo模式
1电子邮件
2电话
3传真
4纸
5其他
有没有办法做到这一点???
output of above query is
srNo mode
1 Email
2 Telephone
3 Others
4 fax
5 paper
but i want that 'others' value at last of table even after further inserting values
srNo mode
1 Email
2 Telephone
3 fax
4 paper
5 Others
is there any way to do this ???
推荐答案
如果我理解你,你想要对数据进行排序。一种可能的方法是使用 ORDER BY [ ^ ]子句。
If i understand you well, you want to sort data. One of possible way is to use ORDER BY[^] clause.
SELECT *
FROM callRecords
ORDER BY CASE WHEN SrNo=3 THEN 1 ELSE 0 END, SrNo
这篇关于如何在插入值后立即在表的最后设置行值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文