在sql两个日期型如何比较早晚

来源:百度知道 编辑:UC知道 时间:2024/06/21 03:25:42
在子查询中有多种情况出现了三个的日期(filldate1,filldate2,filldate3):但是在最迟到料日期中只填写最晚入库日期,这三个日期如何比较那个日期最晚,请问各位大侠帮忙,不尽感谢!

思路:
sql@kokooa>select * from test038;

A B C
-------------- -------------- --------------
18-9月 -09 09-10月-09 09-8月 -08

sql@kokooa> select f from(
2 select a,b,c,(case when d-c>0 then d else c end) as f from(
3 select a,b,c,(case when a-b>0 then a else b end) as d from test038));

F
--------------
09-10月-09

这样就求出最大日期了也就是最迟日期

最晚日期=
when (when filldate1>filldate2 then filldate1 else filldate2 end) >filldate3 then (when filldate1>filldate2 then filldate1 else filldate2 end) else filldate3 end

不太明白什么意思。

主查询加个max不行吗?