从每行中获取最大日期
Get the max date from each ROW
我有这个table:
如何从每一行中获取每个 ID 的最大日期?
使用Greatest
SELECT id, GREATEST (date1, date2, date3)
FROM YourTable
Note that GREATEST and LEAST are not in the SQL standard, but are a common extension. Some other databases make them return NULL if any argument is NULL, rather than only when all are NULL.
我有这个table:
如何从每一行中获取每个 ID 的最大日期?
使用Greatest
SELECT id, GREATEST (date1, date2, date3)
FROM YourTable
Note that GREATEST and LEAST are not in the SQL standard, but are a common extension. Some other databases make them return NULL if any argument is NULL, rather than only when all are NULL.