select * from tablename a where 时间字段 in (select max(时间字段) from tablename where productname=a.productname)
Select a.* from product a join (select 产品类别,max(时间字段) as 时间字段 from product group by 产品类别) b on a.产品类别 = b.产品类别 and a.时间字段 = b.时间字段
你的数据库对每一种物品的进货有什么特别的表示没有吗?如id,date,time? 如果有的话。 select distinct producttype from product a where a.标示字段 in (select max(b.标示字段) from product b where a.producttype=b.prodtcutpye)这样可以把你的产品类别提取出来。但是记录标示不可以用错的。并可以显示唯一的纪录。
select * from 表 a where a.id = (select max(id) from 表 where ProductType = a.ProductType)select * from 表 a where a.时间字段= (select max(时间字段) from 表 where ProductType = a.ProductType)
select * from 表 a where a.id = (select max(id) from 表 where ProductType = a.ProductType)
where productname=a.productname)
join (select 产品类别,max(时间字段) as 时间字段 from product group by 产品类别) b
on a.产品类别 = b.产品类别 and a.时间字段 = b.时间字段
如果有的话。
select distinct producttype from product a where a.标示字段 in (select max(b.标示字段) from product b where a.producttype=b.prodtcutpye)这样可以把你的产品类别提取出来。但是记录标示不可以用错的。并可以显示唯一的纪录。
from 表 a
where a.id = (select max(id) from 表 where ProductType = a.ProductType)select *
from 表 a
where a.时间字段= (select max(时间字段) from 表 where ProductType = a.ProductType)
from 表 a
where a.id = (select max(id) from 表 where ProductType = a.ProductType)