Union All [message #355105] |
Wed, 22 October 2008 12:41  |
ada26
Messages: 15 Registered: September 2007 Location: cleveland
|
Junior Member |
|
|
I have a query below, EMP1 is current records, EMP2 is historical. In cases that EMPLOYEE ABC is present on both tables, this query would give me 2 records; how can I get only 1 output.. or SUM the hrs credit.
SELECT EMP_NAME, SUM(HRS_CREDIT)
FROM EMP1
UNION
SELECT EMP_NAME, SUM(HRS_CREDIT)
FROM EMP2;
-------------
BOB SMITH 12
BOB SMITH 0
JANE DOE 24
JANE DOE 3
-------------
OUTPUT SHOULD BE;
BOB SMIT 12
JANE DOE 27
|
|
|
|
|