有一个表
如: 
控制号  条形码  
1       123456
1       123457
1       156487       
2       352548
2       212336
2       254848
2       547854我现在想查看一下控制号一样的最小的那个条形码帮忙呀

解决方案 »

  1.   

    http://topic.csdn.net/u/20090625/23/bcb92eed-fcaa-411f-9c12-b405551a5279.html
      

  2.   


    select 控制号,min(条形码) from 表
    Group by 控制号
      

  3.   

    if not object_id('Tempdb..#T') is null
        drop table #T
    Go
    Create table #T([Name] nvarchar(1),[Memo] nvarchar(2))
    Insert #T
    select N'A',N'1' union all
    select N'A',N'2' union all
    select N'B',N'1' union all
    select N'B',N'2' union all
    select N'B',N'3'
    SELECT  name,min(memo) from #T
    group by name
      

  4.   

    select 控制号,min(条形码) from 表 group by 控制号
      

  5.   

    declare @T table
    (
    [控制号] int,
    [条形码] int
    )
    insert into @T select 1,123456 
    union all select 1,123457 
    union all select 1,156487    
    union all select 2,352548 
    union all select 2,212336 
    union all select 2,254848 
    union all select 2,547854 select [控制号],min([条形码]) as 条形码 from @T group by [控制号]
    /*
    控制号  条形码
     1     123456
     2     212336
    /*