在SELECT [MYSQL]中加入或选择

问题描述 投票:1回答:1

请帮我加入这两个选择:

SELECT IFNULL(sum(estimated_hours * t2.man_hour),0) as 
estimated from project_has_tasks t1 left join users t2 
on t1.user_id = t2.id group by project_id

SELECT IFNULL(sum(TIME_FORMAT(SEC_TO_TIME 
(time_spent),'%k.%i' )* t2.man_hour),0) as time_spent_cost FROM project_has_tasks t1
left join users t2 on t1.user_id = t2.id group
 by project_id

想得到:

| estimated | time_spent_cost |
_______________________________
| 000000000 |    00000000     |
mysql join select
1个回答
1
投票

只需将它们放在一个查询中:

SELECT IFNULL(sum(estimated_hours * t2.man_hour),0) as 
estimated, IFNULL(sum(TIME_FORMAT(SEC_TO_TIME 
(time_spent),'%k.%i' )* t2.man_hour),0) as time_spent_cost
from project_has_tasks t1 left join users t2 
on t1.user_id = t2.id group by project_id
© www.soinside.com 2019 - 2024. All rights reserved.