Hi Everyone,
I need your help in formulating a view through which I can create a an output like below image -
Monthly Table
| NUM | STATUS | ACTIVITYCODE |
| HAX603 | Completed | 0x45845a |
| HAX317 | Completed | 0x112z44 |
| HAX465 | Completed | 0x1155x4 |
| HAX523 | Completed | 0x124c69 |
Season Table
| NUM | STARTMONTH | STARTDAY | ENDMONTH | EMDDAY |
| HAX603 | JULY | 1 | OCTOBER | 31 |
| HAX317 | DECEMBER | 1 | DECEMBER | 31 |
| HAX317 | MARCH | 1 | MARCH | 31 |
| HAX317 | July | 1 | July | 28 |
| HAX603 | DECEMBER | 1 | DECEMBER | 31 |
| HAX465 | MARCH | 1 | MARCH | 31 |
| HAX465 | July | 1 | July | 28 |
| HAX465 | August | 1 | August | 30 |
| HAX523 | November | 1 | November | 30 |
Final Output
| NUM | STATUS | ACTIVITYCODE | <SEASONS> |
| HAX603 | Completed | 0x45845a | 1 JULY - 31 OCTOBER, 1 DECEMBER - 31 DECEMBER |
| HAX317 | Completed | 0x112z44 | 1 DECEMBER - 31 DECEMBER, 1 MARCH - 31 MARCH, 1 July - 30 July |
| HAX465 | Completed | 0x1155x4 | 1 MARCH - 31 MARCH, 1 July - 28 July, 1 August - 30 August |
| HAX523 | Completed | 0x124c69 | 1 November - 30 November |
I have written a query to join the values of multiple field, but lacking in as how will I formulate a view which will check for the duplicate values of Num fields and merge there values in a single field like season.
select num, (CAST(startday AS VARCHAR(3)) + ' ' + startmonth + ' - ' + CAST(endday AS VARCHAR(3)) + ' ' + endmonth)AS Season from seasons;
I will really appreciate if you can help me understanding the possibility for this and how can i achieve this please.
Thanks
DP