Oracle Grouping summation a small example

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.