Converting a non-standard table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was sent a database table with overtime hours per period that needs linked
with a rate table to calculate total amount due. The table was sent in by a
field person with a format resembling the following:
Name EmpNum PerEnd7/24 PerEnd 8/1 PerEnd 8/8
Jones 123456 2.0 4.0 6.5
Martin 654987 1.5 6.5 8.0

Note (in reality there are many more periods on the table than shown here)

Is there an easy way I can query this table to create a new table something
like:
Name EmpNum Period Hours
Jones 123456 7/24 2.0
Jones 123456 8/1 4.0
Jones 123456 8/8 6.5
.....
Martin 654987 8/8/ 8.0
 
You could create a UNION query to normalize the records. I have left off the
Name field because I don't like it and the EmpNum is probably sufficient to
uniquely identify the employee.

SELECT EmpNum, [PerEnd7/24] As OTHrs, #7/24/2004# as OTDate
FROM tblYuk
UNION ALL
SELECT EmpNum, [PerEnd8/1], #8/1/2004#
FROM tblYuk
UNION ALL
SELECT EmpNum, [PerEnd8/8], #8/8/2004#
FROM tblYuk
UNION ALL
--etc--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top