Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert rows to Columns

Status
Not open for further replies.

barnard90

IS-IT--Management
Mar 6, 2005
73
US
Hi

I have an employee table which has employee Overtime hours worked information
The employees work only for 3 days overtime (Monday , Tuesday , Wednesday)

The table is like

EmpID Day OvertimeHoursworked
----------------------------------------------

101 Monday 4
101 Tuesday 2
101 Wednesday 4
102 Monday 3
102 Tuesday 3
102 Wednesday 2
103 Monday 1
103 Tuesday 5
103 Wednesday 3

I would like to display the weekday rows as columns
I would like to write a SELECT query which gives me a result like this

EmpId MondayOvertime TuesdayOvertime WedOvertime
------------------------------------------------------

101 4 2 4
102 3 3 2
103 1 5 3

How do I get this ? Please suggest
 
Hi,

There are a bunch of examples in this forum to do exactly what you are after. Do a search on 'pivot' or cross-tab.

I am assuming that this is a simplified example -Is your data refreshed weekly, or how do you handle 'weeks' or cumulative amounts for each emplyee for those 3 days as you don't have a 'date'.

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top