select  distinct  a.art_no,batch_no,b.technics_no
  from dbo.PdArtRecipeMain a with(nolock) join PdArtRecipeDetail b with(nolock) on a.art_no=b.art_no
 where a.art_no='N077120024'在加上distinct 得到的technics_no排序不一样,但是不加distinct 会有很多重复的信息,
请问高手们怎么处理?TKS!

解决方案 »

  1.   

    select     distinct     a.art_no,batch_no,b.technics_no 
        from   dbo.PdArtRecipeMain   a   with(nolock)   join   PdArtRecipeDetail   b   with(nolock)   on   a.art_no=b.art_no 
      where   a.art_no='N077120024' 
    order by a.art_no --自己排序
      

  2.   

    可能没有说太清楚,
    正常顺序是
    111#
    111#
    40#
    40#
    131#
    131#
    131#
    210#
    210#
    但是加DISTINCT 后就变成了
    111#
    131#
    210#
    40#
    请高手们继续指点!TKS!
      

  3.   

    select identity(int,1,1) as id ,a.art_no,batch_no,b.technics_no  into #
        from   dbo.PdArtRecipeMain   a   with(nolock)   join   PdArtRecipeDetail   b   with(nolock)   on   a.art_no=b.art_no 
      where   a.art_no='N077120024' 
    select distinct a.art_no,batch_no,b.technics_no
    from #
    order by iddrop table #
      

  4.   

    加上DISTINCT 后想得到的数据应是
    111# 
    40# 
    131# 
    210#, 
    不知怎么处理?