UnicornLee opened a new issue, #18080:
URL: https://github.com/apache/doris/issues/18080

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Description
   
   1. select的字段中存在子查询,这样的SQL在MySQL中属于比较常见的。
   2. 希望Doris能兼容这样的子查询
   
   ### Use case
   
   1. 建表SQL
   ```sql
   CREATE TABLE `ipo_h5`
   (
       `id`                   varchar(192) NOT NULL,
       `bid`                  varchar(192)    DEFAULT NULL,
       `org_code`             varchar(192)    DEFAULT NULL,
       `research`             decimalv3(18, 4) DEFAULT NULL,
       `research_proportion`  decimalv3(18, 4) DEFAULT NULL,
       `research_ranking`     varchar(48)    DEFAULT NULL,
       `patent`               varchar(150)    DEFAULT NULL,
       `patent_new`           varchar(150)    DEFAULT NULL,
       `patent_design`        varchar(150)    DEFAULT NULL,
       `patent_internation`   varchar(150)    DEFAULT NULL,
       `patent_ranking`       varchar(48)    DEFAULT NULL,
       `patent_ranking_year`  varchar(48)    DEFAULT NULL,
       `research_peo`         varchar(48)    DEFAULT NULL,
       `research_peo_core`    varchar(48)    DEFAULT NULL,
       `company_peo`          varchar(48)    DEFAULT NULL,
       `research_peo_ranking` varchar(48)    DEFAULT NULL,
       `research_peo_year`    varchar(48)    DEFAULT NULL,
       `taking`               decimalv3(18, 4) DEFAULT NULL,
       `taking_ranking`       varchar(48)    DEFAULT NULL,
       `taking_ranking_gem`   varchar(48)    DEFAULT NULL,
       `taking_ranking_year`  varchar(48)    DEFAULT NULL,
       `profits`              decimalv3(18, 4) DEFAULT NULL,
       `profits_ranking`      varchar(48)    DEFAULT NULL,
       `profits_ranking_gem`  varchar(48)    DEFAULT NULL,
       `profits_ranking_year` varchar(48)    DEFAULT NULL,
       `assets`               decimalv3(18, 4) DEFAULT NULL,
       `assets_ranking`       varchar(48)    DEFAULT NULL,
       `assets_ranking_gem`   varchar(48)    DEFAULT NULL,
       `assets_ranking_year`  varchar(48)    DEFAULT NULL,
       `research_year`        varchar(48)    DEFAULT NULL,
       `research_year_se`     varchar(48)    DEFAULT NULL,
       `research_year_th`     varchar(48)    DEFAULT NULL,
       `research_plate_fiavg` decimalv3(18, 4) DEFAULT NULL,
       `research_plate_seavg` decimalv3(18, 4) DEFAULT NULL,
       `research_plate_thavg` decimalv3(18, 4) DEFAULT NULL,
       `taking_fiavg`         decimalv3(18, 4) DEFAULT NULL,
       `taking_seavg`         decimalv3(18, 4) DEFAULT NULL,
       `taking_thavg`         decimalv3(18, 4) DEFAULT NULL,
       `industry_csrc`        varchar(150)    DEFAULT NULL,
       `update_time`          datetimev2       DEFAULT CURRENT_TIMESTAMP,
       `ipo_plate`            varchar(192)    DEFAULT NULL
   ) ENGINE = OLAP UNIQUE KEY(`id`)
   DISTRIBUTED BY HASH(`id`) BUCKETS AUTO
   PROPERTIES (
       "replication_num" = "3",
       "light_schema_change" = "true"
   );
   ```
   
   2. 报错SQL
   ```sql
   SELECT m.id,
          (SELECT COUNT(1) + 1
           FROM ipo_h5 m1
           where m1.ipo_plate = '069001001006'
             AND ifnull(m1.taking, -9999999999999) > IFNULL(m.taking, 
-9999999999999))   takingRanking,
          (SELECT COUNT(1) + 1
           FROM ipo_h5 m1
           where m1.ipo_plate = '069001001006'
             AND ifnull(m1.research_proportion, -9999999999999) >
                 IFNULL(m.research_proportion, -9999999999999))                 
         researchRanking,
          (SELECT COUNT(1) + 1
           FROM ipo_h5 m1
           where m1.ipo_plate = '069001001006'
             AND ifnull((m1.research_peo + 0) / (m1.company_peo + 0), 
-9999999999999) >
                 IFNULL((m.research_peo + 0) / (m.company_peo + 0), 
-9999999999999))     researchPeoRanking,
          (SELECT COUNT(1) + 1
           FROM ipo_h5 m1
           where m1.ipo_plate = '069001001006'
             AND ifnull(m1.assets, -9999999999999) > IFNULL(m.assets, 
-9999999999999))   assetsRanking,
          (SELECT COUNT(1) + 1
           FROM ipo_h5 m1
           where m1.ipo_plate = '069001001006'
             AND ifnull(m1.profits, -9999999999999) > IFNULL(m.profits, 
-9999999999999)) profitsRanking
   FROM ipo_h5 m
   where m.ipo_plate = '069001002002';
   ```
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to