日期:2014-05-17 浏览次数:20846 次
-- JUST TRY IT .. -- 1: SELECT SUM(FSALARY) "SALARYS" FROM TABLE1 WHERE FNAME = '张三' AND TO_CHAR(FDATE,'YYYY')=TO_CHAR(SYSDATE,'YYYY'); -- 2: SELECT TO_CHAR(FDATE,'YYYY') "YEAR", TO_CHAR(FDATE,'YYYYMM') "MONTH", SUM(FSALARY) "SALARYS" FROM TABLE1 GROUP BY TO_CHAR(FDATE,'YYYY'),TO_CHAR(FDATE,'YYYYMM'); -- 3: SELECT DISTINCT FNAME FROM (SELECT FNAME, TO_CHAR(FDATE,'YYYY') "YEAR", TO_CHAR(FDATE,'YYYYMM') "MONTH", SUM(FSALARY) "SALARYS" FROM TABLE1 GROUP BY FNAME, TO_CHAR(FDATE,'YYYY'), TO_CHAR(FDATE,'YYYYMM') )TT WHERE SALARYS BETWEEN 500 AND 800;