DongJigong commented on issue #10257:
URL: 
https://github.com/apache/shardingsphere/issues/10257#issuecomment-841748171


   > @DongJigong With 4.1.1 version, you can rewrite sql like this:
   > 
   > ```sql
   > SELECT COUNT(DISTINCT device_code) AS devSum, SUM(qr_num) AS portNum
   >    , SUM(CASE
   >            WHEN state = 0 THEN qr_num
   >    END) AS unUseQrNum, SUM(CASE
   >            WHEN state = 1 THEN qr_num
   >    END) AS useQrNum
   >    , status AS status
   > FROM (
   >    SELECT dev.device_code, dev.status, COUNT(ite.qr_num) AS qr_num, 
ite.state
   >            , dev.org_id
   >    FROM charge_match_device dev
   >            LEFT JOIN charge_match_device_items ite ON dev.device_code = 
ite.device_code
   >    GROUP BY dev.device_code, ite.state
   > ) d
   > WHERE org_id = 1
   >    OR org_id IN (
   >            SELECT c.org_id
   >            FROM sys_org c
   >            WHERE FIND_IN_SET(1, c.ancestors)
   >    )
   > GROUP BY status;
   > ```
   
   Thanks. I have rewrite my sql to solve this problem. I hope that problems 
like this can be solved quickly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to