Calculatons in SUM

  • Thread starter Thread starter galin
  • Start date Start date
G

galin

Hi all,
I have 5 fields in a query. ID, PAYCODE_1, PAYCODE_2,
PAYCODE_1HOUR, PAYCODE_2HOUR.

PAYCODE_1 AND PAYCODE_2 include codes such as
vac,reg,dbl,ovt..etc..

I am trying to SUM up all codes by hour. PAYCODE_1
corresponds to hours in PAYCODE_1HOUR and subsequently
PAYCODE_2 to PAYCODE_2HOUR.

How can I SUM up all the codes, having the fact that some
of the codes (REG,DBL, and OVT) are presented in both
fields. Basically, I have to sum up the codes from
PAYCODE_1 by PAYCODE_1HOUR , PAYCODE_2 BY PAYCODE_2HOUR.
Then I have to sum up the matching codes and have
everything summarized ready for report..

Any suggestions...

I was advised to use a Union query , which converted
PAYCODE_1 and PAYCODE_2 into just PAYCODE and the same
with PAYCODE_1HOUR and PAYCODE_2HOUR, but I am missing
hours.
Thank you
galin
 
Galin

You have described a classic ... spreadsheet. And the problem you seem to
be running into (the same code could be in either PAYCODE_1 or PAYCODE_2
(?!or both?!) is due to the design of the table. Check into the topic of
normalization.

If you wish to pursue the UNION query, could you provide more information
about what you mean when you say "... I am missing hours"?
 
Pardon me.

If you used a UNION query and didn't use the UNION ALL clause, then the query
will drop duplicate rows.

SELECT ...
UNION ALL
SELECT ...
 
Back
Top