select a.A,a.B,b.c
from master a,detail b
where a.A=b.A and a.B=b.B

解决方案 »

  1.   

    select * from detail A
    where C = (select min(C) from detail where A = A.A and B = B.B)
      

  2.   

    1,建自定义函数
    create function getstr(@a int, @b int)
    returns Nvarchar(4000)
    as 
    begin
    declare @str Nvarchar(2000)
    set @str=N''
    select @str=@str+rtrim(C)+N' or ' from detail
    where A = @a and B = @b
    if @str<>N'' 
        set @str=left(@str,len(@str)-4)
    return @str
    endGO2,
    select A, B, dbo. getstr(A, B) as C from master
      

  3.   

    赞同: tj_dns(愉快的登山者)