我有下表:
create table weights (
ident int references users,
dateW date,
weight float,
primary key(ident,dateW)
);
我只想从最近日期的给定用户(ident)中选择重量。我有:
SELECT WEIGHT
FROM WEIGHTS
WHERE WEIGHTS.IDENT = 22 AND WEIGHTS.DATEW = (SELECT MAX(WEIGHTS.DATEW)
FROM WEIGHTS);
但它没有做我想要的。建议?