简体   繁体   中英

Combine 2 SQL Queries using Inner or Cross Join?

Trying to combine results from both queries

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

Trying to combine both of these queries for 1 detailed result with grand totals

as mentioned union is what your after

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM