April 9, 2015 cold weather
Table Gw_log is designed as follows:
Name Type NullableDefaultComments--------------------------------------------------ID VARCHAR2 ( -) Message ID service_id VARCHAR2 ( -) Y Service ID req_timeDATEY Request Time Invoke_timeDATEY Call Time STATUSCHAR(1) Y' 0 ' 0: Failure, 1: SuccessResp_timeDATEY Response Time User_name VARCHAR2 ( -) Y User name Service_timeDATEY Call service End time DESCN VARCHAR2 ( the) Y Description
Count the total number of records passed and failed each day: a successful SQL statement:
select req_time, sum(decode(status, ‘0‘, 1, 0)) fail, sum(decode(status, ‘1‘, 1, 0)) success from gw_log group by req_time;
The results of the implementation are as follows:
Failed SQL statement:
SelectG.req_time, G.success, G.fail from(SelectA.req_time,Count(*) Success fromGw_log Awhere 1=1 andA.status =1 Group byReq_timeUnion All SelectB.req_time,Count(*) fail fromGw_log bwhere 1=1 andB.status =0 Group byB.req_time) G
The prompt error is:
How can not find the error, know the friend remember to me point out oh, thank you!!!
Oracle Grouping summation a small example