select a.id,a.name,b.id,min(b.money) as money
from A,B
where a.id = b.id and (b.money is not null)
group by a.id,a.name,b.id
from A,B
where a.id = b.id and (b.money is not null)
group by a.id,a.name,b.id
调试欢乐多
declare @tb1 table(id int,name varchar(2))
insert into @tb1
select 1,'bb'
union all select 1,'bb'
union all select 2,'cc'
declare @tb2 table(id int,money int)
insert into @tb2
select 1,20
union all select 1,40
union all select 2,60
--得到结果
select a.id,a.name,b.id,min(b.money) as money
from @tb1 a,@tb2 b
where a.id = b.id and (b.money is not null)
group by a.id,a.name,b.id