å½åææ°é
select sum(æ°é) from 表å where to_char(æ¶é´,'yyyy-mm')=to_char(sysdate,'yyyy-mm')æå®æ¶é´æ®µå æ°éï¼æ¯å¦10æ1æ¥0ç¹0å0ç§å°10æ3æ¥23ç¹59å59ç§
select sum(æ°é) from 表å where to_char(æ¶é´,'yyyy-mm-dd hh24:mi:ss')between '2013-10-01 00:00:00' and '2013-10-03 23:59:59'追é®æçæææ¯è¯´ åæ¶æ¥è¯¢æ°æ¥ æ¯å¦è¯´ å°Aä¸æ份åäº100éé¢ï¼äºæ份åäº120éé¢ ä¸æ份åäº150éé¢ ï¼ç°å¨æ¯åæä¸æ¬ åååäº70éé¢ æè¦æ¥è¯¢çç»ææ¯ å°A ä¸æ份åäºæ份çåé¢æ»æ° åç®åå½æå·²ç»åçé¢ç®æ°é æ¥è¯¢è¦æ¾ç¤ºæ
å§å ä¸äºæ综å å½æ
å°A 220 70
æè¦æ¥è¯¢æè¿ä¸ªæ ·å
æ¡ä»¶ä½ å°±å¨case when éå 就好äºï¼æ¯å¦ä½ åªæ¥1ï¼2æç
sum(case when to_char(æ¶é´,'yyyy-mm') in ('2013-01','2013-02') then æ°é else 0 end)