我想取ID相同的条件下,RQ(日期)是最大值的那一条数据的JG,应该怎么设置
select id ,max(rq), jq from a
group by id jq
select ID,JG,max(RQ) FROM 表 GROUP BY ID,JG
SELECT a.id, a.rq, a,.jg FROM tabname a INNER JOIN ( SELECT id, max(rq) FROM tabname GROUP BY id ) b ON a.id = b.id AND a.rq = b.rq
D2设置
如果用sql的话 自己写一下。很简单