1024programmer Oracle One of the oracle notes implements the statistics of multiple fields (multiple counts) in a table

One of the oracle notes implements the statistics of multiple fields (multiple counts) in a table

One of the oracle notes implements the statistics of multiple fields (multiple counts) in a table
the
Requirements: Count the total number of work orders, the total number of unprocessed work orders, the total number of completed work orders, and the total number of unfinished work orders in the WAIT_ORDER table.
the
Table structure: For the convenience of examples, the WAIT_ORDER table has only two fields, namely ID and STATUS, where STATUS is the status of the work order.
1 means unprocessed, 2 means completed, 3 means total outstanding.
the
SQL:
[sql]
SELECT
    COUNT(B.ID) AS The total number of work orders,
COUNT(CASE
          WHEN B.status IN ('1') THEN  
        'un_deal'   www.2cto.com  
        END) Total Open Work Orders,  
       
COUNT(CASE
        WHEN B.status IN ('2') THEN  
                                         
        END) total number of completed work orders,
 
COUNT(CASE
WHEN B.status = '3' THEN
                                           
        END) Total Open Work Orders  
           
FROM WAIT_ORDER B
the
The result is as follows:
the

the

the
Author baolong47

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/one-of-the-oracle-notes-implements-the-statistics-of-multiple-fields-multiple-counts-in-a-table/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索