I have two tables. The first one holds information about Hours:
ID | activitydate | userid | phaseid | activityid | time |
3 | 2011-04-11 | 1 | 1 | 1 | 120 |
4 | 2011-04-12 | 1 | 1 | 1 | 180 |
5 | 2011-04-12 | 3 | 1 | 1 | 360 |
6 | 2011-04-22 | 2 | 2 | 3 | 300 |
The 2nd table holding the data of Users:
ID | userid | lastname |
1 | abc | ABC |
2 | xyz | XYZ |
3 | asd | ASD |
4 | qwe | QWE |
I need a query which generate below given format:
Date | ABC | XYZ | ASD | QWE |
2011-04-11 | 120 | 0 | 0 | 0 |
2011-04-12 | 180 | 0 | 360 | 0 |
2011-04-22 | 0 | 300 | 0 | 0 |
This can be as below format:
User | 2011-04-11 | 2011-04-12 | 2011-04-13| .... | 2011-04-22 |...
ABC | 120 | 180 | 0 | .....| 0 |...
XYZ | 0 | 0 | 0 | .....| 300 |...
ASD | 0 | 360 | 0 | .....| 0 |...
QWE | 0 | 0 | 0 | .....| 0 |...
Any help is really appreciated!