|
declare @A table(id int,name varchar(50))
declare @B table(id int,AID int,price int)
insert @A select 1,'DEMO'
union all
select 2,'DEMO2'
insert @B select 1,1,30
union all select 2,1,32
union all select 3,1,26
select top 1 A.id, A.name, B.id, B.AID, B.price
from @B B
join @A A on A.id=B.AID
order by price |
|