使用内部或交叉连接组合2个SQL查询?

时间:2016-07-13 19:46:42

标签: mysql sql oracle-sqldeveloper

尝试合并两个查询的结果

--#90 QUERY BEGIN

--012 WO MANH HOURS BY EMPLOYEE

select a.team_code, a.job_function_name, a.login_user_id, b.user_first_name, b.user_last_name, a.START_DATE_TIME, a.END_DATE_TIME, round((sum(case when level_5 = 'WORK ORDER' then total_time/60 - unpaid_brk/60 else 0 end)),2) as "HOURS"
from lm2015prd.e_consol_perf_smry a, lm2015prd.ucl_user b
where a.login_user_id = b.user_name
and a.level_5 = 'WORK ORDER'
and a.whse = '012'
and a.clock_in_status < 90
and a.team_code in ('PREKIT 1ST 08')
and a.clock_in_date > '2016-07-12 04:00' and a.clock_in_date < '2016-07-14 03:00'
group by a.team_code, a.job_function_name, a.login_user_id, b.user_first_name,
b.user_last_name, a.START_DATE_TIME, a.END_DATE_TIME
Order by a.LOGIN_USER_ID;

SELECT NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, round((sum(case when level_5 = 'WORK ORDER' then total_time/60 - unpaid_brk/60 else 0 end)),2) as "HOURS"
from lm2015prd.e_consol_perf_smry a, lm2015prd.ucl_user b
where a.login_user_id = b.user_name
and a.level_5 = 'WORK ORDER'
and a.whse = '012'
and a.clock_in_status < 90
and a.team_code in ('PREKIT 1ST 08')
and a.clock_in_date > '2016-07-13 04:00' and a.clock_in_date < '2016-07-14 03:00';
--QUERY END

尝试将这两个查询与1个详细结果与总计

结合起来

1 个答案:

答案 0 :(得分:0)

如上所述,工会就是你的事后

http://www.w3schools.com/sql/sql_union.asp