我想选择最长日期的项目。
我有 select
:
select d.MaxDate from (select max(c.ChangedDateTime) MaxDate FROM c WHERE AND c.IsLatest = true) d
结果是:
[
{
"MaxDate": "2020-07-16 12:23:57"
}
]
现在我要选择一行的最大日期:
select * FROM c WHERE IsLatest = true
WHERE c.ChangedDateTime = (select d.MaxDate from (select max(c.ChangedDateTime) MaxDate
FROM c WHERE AND c.IsLatest = true) d)
结果为空,应返回一行日期 2020-07-16 12:23:57
当我这样选择的时候:
select * from c where c.IsLatest = true AND c.ChangedDateTime = '2020-07-16 12:23:57'
它只返回我想要的一行,所以我认为subselect有问题,因为它返回带有object的数组 [{"MaxDate": "2020-07-16 12:23:57"}]
1条答案
按热度按时间lkaoscv71#
排序后只选一行怎么样?