• 首页
  • 小学语文
  • 中学语文
  • 中学英语
  • 免费论文
  • 教学随笔
  • 学生作文
  • 综合考试
  • 试题教案
  • 育儿话题
  • 教学资源
  • 编程技术
  • 博客
  • SQL BUG集之"随机排序中的newid()问题"

    日期:2003-03-26  地址:  作者:

    /**==** 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

    (所影响的行数为 6 行)--*/

    对 SQL BUG集之"随机排序中的newid()问题" 文章的评论    [查看网友评论]

    验证码:
    匿名发表: