|
create table A (id int identity (1,1), name varchar (10))
create table B (id int identity (1,1), aid int, price varchar (10))
insert into a
select 'demo1'
union all select 'demo2'
insert into b
select 1, '30 'union all
select 1, '32 'union all
select 1, '36 '
select a.id, a.name, a.bid, a.aid, a.price from (select a.id, a.name, b.id as bid, b.aid, b.price from A a inner join B b on a.id = b.aid) a, b where a.id = b.id and a.price <= b.price
drop table a
drop table b |
|