I am trying to create an employment timesheet for contractors. I need to output a table with a date column and have the flexibility of a variable number of pay rates.

The pay rates are in a table called "RATES" and these need to become columns of the output table:

```
RATEID    PROJECTID   RATENAME   RATEOFPAY
1         1           Normal     1000
2         1           Double     2000
3         1           Special    2500
4         2           Flatrate   1000
5         3           Rateone    1000
6         3           Rate2      1500

```

I already have a function that generates dates between ranges:

```
SELECT IndividualDate FROM DateRange('03-01-16', '03-30-16') as DATESINRANGE

```

This outputs

```
IndividualDate
2016-03-01 00:00:00.000
2016-03-02 00:00:00.000
thru
2016-03-30 00:00:00.000

```

I have a 3rd table that contains data about when these contractors worked, the rate and number of hours (they may not work every day):

```
dateworked    projectid  rateid     hoursworked
2016-03-02    1          2          5
2016-03-02    1          3          2

```

What I want is to output a table that shows every day of the month for PROJECTID=1 like this:

```
Dates        Normal     Double    Special
2016-03-01   0          0         0
2016-03-02   0          5         2
2016-03-03   0          0         0
etc...

```

I've looked at examples with PIVOT, but am not sure if they apply in this scenario as the examples used aggregates. I'd really appreciate help with this.