where not exists(select 1 from table1 where col2=acol2 and col1<aCOL1)
结果
COL1 COL2 COl3
1 abc 10
3 xyz 10
4 ijik 9
如果要显示列2则修改 col1<aCOL1 为col1>aCOL1你的d表,a表和b表的关联字段在做join之前要保证唯一性
比如
left join (select distinct bizArea,cntNo from crm_contractbaseinfo) a on ccrtNO=acntNo先把表1里面重复数据去掉,然后再连接表2。
select addr,rem from
(SELECT DISTINCT pro,addr from 表1 ) v1,表2
where v1pro = 表2proselect table1name,table2
from
table1,table2 where table1userid=table2userid and table2id in
(select min(id) as id from table1,table2 where table1userid=table2userid)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)