I need to make the rows in a table appear in columns in sql server as Im recording peoples annual leave - the users want what ive created in .net to appear like in their spreadsheets hence why im doing this. I have heard that you can use a PIVOT table.I have a select statement below:
select
typeID,
datesFrom,
datesTo
from availability
where authno = 24
Which returns the below:
+--------+-------------------------+-------------------------+
| typeID | datesFrom | datesTo |
+--------+-------------------------+-------------------------+
| 1 | 2015-02-16 00:00:00.000 | 2015-02-23 00:00:00.000 |
| 2 | 2015-06-23 00:00:00.000 | 2015-06-29 00:00:00.000 |
+--------+-------------------------+-------------------------+
but my problem is that I need it to appear like below:
+--------+---------------------+-------------------+--------+-----------------+---------------+
| typeID | datesFrom(February) | datesTo(February) | typeID | datesFrom(June) | datesTo(June) |
+--------+---------------------+-------------------+--------+-----------------+---------------+
| 1 | 16/02/2015 | 23/02/2015 | 2 | 23/06/2015 | 29/06/2015 |
| | | | | | |
+--------+---------------------+-------------------+--------+-----------------+---------------+
Any help is greatly, greatly appreciated. I havent been able to find a pivot which shows dates like this