select max(col3),max(app_date)
from (select col3,min(approved_date) app_date
from csms_m_vendor
where code1='A0001'
and code2='B0002'
group by col3)
==>
select max(col3),max(app_date) from csms_m_vendor
where code1='A0001'
and code2='B0002'
from (select col3,min(approved_date) app_date
from csms_m_vendor
where code1='A0001'
and code2='B0002'
group by col3)
==>
select max(col3),max(app_date) from csms_m_vendor
where code1='A0001'
and code2='B0002'
col3的max只是因为group by而已。
----------------------------------------
select max(col3),max(my_date)
from (select col3,min(app_date) my_date
from csms_m_vendor
where code1='A0001'
and code2='B0002'
group by col3)
----------------------------------------
如果是
select max(col3),max(app_date) from csms_m_vendor
where code1='A0001'
and code2='B0002'
这样的话得到的不能保证是最“新”的值了。