用到如下语句: select A,B,C from tableName where TO_CHAR(A,'yyyy-MM-dd') like '2009-11-09' and B = '600' and A = (select max(A) from tableName where B = '600') or TO_CHAR(A,'yyyy-MM-dd') like '2009-11-09' and B = '603' and A = (select max(A) from tableName where B = '603') or TO_CHAR(A,'yyyy-MM-dd') like '2009-11-09' and B = '606' and A = (select max(A) from tableName where B = '606') or TO_CHAR(A,'yyyy-MM-dd') like '2009-11-09' and B = '609' and A = (select max(A) from tableName where B = '609') or TO_CHAR(A,'yyyy-MM-dd') like '2009-11-09' and B = '611' and A = (select max(A) from tableName where B = '611')
上述代码中,重复部分比较多,能否简化??select A,B,C from tableName where TO_CHAR(A,'yyyy-MM-dd') like '2009-11-09' and B in('600','603','606','609','611') and A = (select max(A) from tableName where B in('600','603','606','609','611'))
select A,B,C from tableName a where TO_CHAR(A,'yyyy-MM-dd') = '2009-11-09' and b in('600','603','606','609','611') and a=(select max(a) from tablename where b=a.b)