34,873
社区成员
发帖
与我相关
我的任务
分享SQL codeselect
*
from
产品表 a
left join 销售表 b on
a.id=b.上级ID
and
购买日期=(select max(购买日期) from 销售表 where 产品id=b.产品id )select
*
from
产品表 a
left join 销售表 b on
a.id=b.上级ID
and
购买日期=(selectmax(购买日期) from 销售表 where 产品id=b.产品id )
select * from
产品表 a left join 销售表 b on a.id=b.上级ID
and not exists(select 1 from 销售表 where 产品id=b.产品id and 购买日期>a.购买日期)
select * from 产品表 a,销售表 b
where a.id=b.上级ID
and not exists(select 1 from 销售表 where 产品id=b.产品id and 购买日期>a.购买日期)