有一种方法可以使用 WHERE date = MAX(date) 发出请求
There is a way to make a request with WHERE date = MAX(date)
我想知道是否可以在 postgresql 中使用像他这样的操作员发出请求:
WHERE date = MAX(date)
谢谢
您可以使用 order by
和 limit
:
select t.*
from t
order by t.date desc
limit 1;
或者,如果您想获得重复项,请使用子查询:
select t.*
from t
where t.date = (select max(t2.date) from t t2);
我想知道是否可以在 postgresql 中使用像他这样的操作员发出请求:
WHERE date = MAX(date)
谢谢
您可以使用 order by
和 limit
:
select t.*
from t
order by t.date desc
limit 1;
或者,如果您想获得重复项,请使用子查询:
select t.*
from t
where t.date = (select max(t2.date) from t t2);