-- 핵심은 lead 함수를 써서 체크했습니다. WITH t (dt, amt) AS ( SELECT '20120228', 102345 from dual union all SELECT '20120227', 21485 from dual union all SELECT '20120226', 1111 from dual union all SELECT '20120225', 54748 from dual union all SELECT '20120215', 123474 from dual union all SELECT '20120214', 4444 from dual union all SELECT '20120213', 8424 from dual union all SELECT '20120201', 1248 from dual ) SELECT sum_amt FROM ( SELECT dt, amt, SUM(amt) OVER (ORDER BY dt desc) AS sum_amt, CASE WHEN lead(dt,1) OVER (ORDER BY dt desc) != TO_CHAR(TO_DATE(dt, 'yyyymmdd')-1,'yyyymmdd') THEN '1' ELSE '0' END AS CHECK_DT FROM T ORDER BY dt desc ) WHERE check_dt = '1' AND ROWNUM = 1