子查询返回操作数应包含1列

时间:2018-04-15 11:48:06

标签: mysql

我有以下选择查询:

SELECT     `tbl_calendar`.`id_tech` count(`tbl_calendar`.`id_tech`) AS scheduled , 
           ( 
                     SELECT    `tbl_calendar`.`id_tech` , 
                               `tbl_client`.`c_name`           AS name , 
                               count(`tbl_calendar`.`id_tech`) AS quantity 
                     FROM      `tbl_calendar` 
                     LEFT JOIN `tbl_client` 
                     ON        ( 
                                         `tbl_calendar`.`id_tech` = `tbl_client`.`id_client`) 
                     LEFT JOIN `tbl_service_report` 
                     ON        ( 
                                         `tbl_service_report`.`id_service_case` = `tbl_calendar`.`id_service_case`)
                     WHERE     `tbl_service_report`.`timeout` !='') 
FROM       `db_pm`.`tbl_service_case` 
INNER JOIN `db_pm`.`tbl_calendar` 
ON         ( 
                      `tbl_service_case`.`id_service_case` = `tbl_calendar`.`id_service_case`) 
INNER JOIN `db_pm`.`tbl_service_report` 
ON         ( 
                      `tbl_service_case`.`id_service_case` = `tbl_service_report`.`id_service_case`) AS finished
GROUP BY   `tbl_calendar`.`id_tech`

需要输出:

|----|-----------|----------|
| ID | Scheduled | Finished |
|----|-----------|----------|
| 1  | 2         | 1        |
|----|-----------|----------|

但结果是
操作数应包含1列

请帮忙

0 个答案:

没有答案