oracle中查询的小问题,在线等 数据库中有一张表,ismg_icp_flow
表结构如下
sql>desc ismg_icp_flow
name null Type
ICPNO NOT NULL VARCHER(6)
SERVICE_ID VARCHAR2(10)
STST_MIN NOT NULL DATETIME
MT_RECV_OK NOT NULL NUMBER(10)
期望的输出结果如下
ICPNO SERVICE_ID TOTAL
901001 7700 271965
901001 7800 3857795
thanks
------解决方案--------------------
笔试题呀? ------解决方案-------------------- select ICPNO,SERVICE_ID,sum(MT_RECV_OK) TOTAL from ismg_icp_flow where STAT_MIN between to_date('2003-1-1','yyyy-mm-dd')
and to_date('2003-2-1','yyyy-mm-dd') ------解决方案--------------------
SELECT ICPNO,SERVICE_ID,SUM(MT_RECV_OK) AS TOTAL
FROM ISMG_ICP_FLOW
WHERE STST_MIN > TO_DATE('20130101','YYYYMMDD')
AND STST_MIN < TO_DATE('20130201','YYYYMMDD')
GROUP BY ICPNO,SERVICE_ID;
------解决方案-------------------- 楼上漏掉了分组。。 ------解决方案-------------------- 后面加上group by ICPNO,SERVICE_ID order by TOTAL
select ICPNO,SERVICE_ID,sum(MT_RECV_OK) TOTAL from ismg_icp_flow where STAT_MIN between to_date('2003-1-1','yyyy-mm-dd') and to_date('2003-2-1','yyyy-mm-dd') group by ICPNO,SERVICE_ID order by TOTAL desc ------解决方案--------------------