/**==** 2. 随机排序中的newid()问题 **==**/–测试数据declare @t table(name char(1),value int)insert into @tselect ‘a’,1union all select ‘a’,2union all select ‘b’,3union all select ‘b’,4union all select ‘c’,5union all select ‘c’,6
–要求,随机排序,但name相同的要排在一齐select a.*from @t a join( select aa=newid(),name from(select distinct name from @t) a) b on a.name=b.nameorder by b.aa,newid()
/*–测试结果之一,并没有达到要求.如果将join改成left right full join,就正确name value —- ———– b 4b 3c 5a 1a 2c 6
http://www.gaodaima.com/35911.htmlSQL BUG集之"随机排序中的new_sqlserver
(所影响的行数为 6 行)–*/
欢迎大家阅读《SQL BUG集之"随机排序中的new_sqlserver》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码