日期:2014-05-17 浏览次数:20601 次
create table table1 (id int,amount int)
insert into table1 values(1,50)
insert into table1 values(2,60)
insert into table1 values(3,110)
insert into table1 values(4,500)
create table table2 (id int ,thresholdvalue int)
insert into table2 values(1,100)
insert into table2 values(2,200)
insert into table2 values(3,300)
select table1.id,table1.amount ,thresholdvalue=MIN(table2.thresholdvalue)
from table1,table2
where table1.amount>(select MIN(thresholdvalue)from table2)
group by table1.id,table1.amount
/*
id amount thresholdvalue
3 110 100
4 500 100
*/
create table table1 (id int,amount int,type nvarchar(5))
insert into table1 values(1,200,'A')
insert into table1 values(2,80,'B')
insert into table1 values(3,100,'C')
create table table2 (id int ,thresholdvalue int,type nvarchar(5))
insert into table2 values(1,100,'A')
insert into table2 values(2,1000,'A')
insert into table2 values(3,50,'B')
insert into table2 values(4,500,'B')
insert into table2 values(5,90,'C')