排序更改
Posted 延杰.郑
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了排序更改相关的知识,希望对你有一定的参考价值。
1 select p.Id,p.Title,g.* from testPager p 2 inner join pageQuestionGroup g on p.id=g.testPagerId 3 where publicDate is null 4 order by p.id,g.id 5 6 7 8 9 declare @testPagerId int 10 set @testPagerId=33 11 12 IF OBJECT_ID(‘dbo.#GroupQuestion‘,‘U‘) IS NOT NULL DROP TABLE dbo.#GroupQuestion; 13 14 SELECT * 15 INTO dbo.#GroupQuestion 16 FROM GroupQuestion where testPagerId=@testPagerId 17 order by id 18 19 -- 声明变量 20 DECLARE 21 @id INT, 22 @rank int 23 set @rank=0 24 25 WHILE EXISTS(SELECT id FROM dbo.#GroupQuestion) 26 BEGIN 27 -- 也可以使用top 1 28 set @rank=@rank+1 29 SELECT top 1 @id=id FROM dbo.#GroupQuestion; 30 UPDATE GroupQuestion SET sort=@rank WHERE id=@id; 31 DELETE FROM dbo.#GroupQuestion WHERE id=@id; 32 END 33 select * from dbo.#GroupQuestion 34 DROP TABLE dbo.#GroupQuestion;
以上是关于排序更改的主要内容,如果未能解决你的问题,请参考以下文章
初识Spring源码 -- doResolveDependency | findAutowireCandidates | @Order@Priority调用排序 | @Autowired注入(代码片段
初识Spring源码 -- doResolveDependency | findAutowireCandidates | @Order@Priority调用排序 | @Autowired注入(代码片段