Hi All,
Below is the data
CREATE TABLE #Coverage( EmployeeID INT, EmployeeName VARCHAR(20), CoverageName VARCHAR(50), CoverageAmount Decimal, CoveredBy VARCHAR(20), EventDate DATETIME, CoverageStartDate DATETIME, CoverageEndDate DATETIME ) INSERT INTO #coverage VALUES (8,'Lara','Employee + Children',213.60,'EmployeeContribution','2013-10-01','2013-10-01','2014-05-31'), (8,'LAra','Employee + Children', 606.31 ,'CompanyContribution' ,'2013-10-01','2013-10-01','2014-05-31'), (8,'LAra','Employee Only' ,0.00 ,'EmployeeContribution' ,NULL ,'2013-06-01','2014-05-31'), (8,'LAra','Employee Only' ,431.55 ,'CompanyContribution' ,NULL ,'2013-06-01','2014-05-31'), (8,'LAra','Employee Only' ,81.42 ,'EmployeeContribution' ,NULL ,'2012-06-01','2013-05-31'), (8,'LAra','Employee Only' ,420.93 ,'CompanyContribution' ,NULL ,'2012-06-01','2013-05-31') SELECT * FROM #Coverage drop table #coverage
and expected out put for the year 2013
EmployeeID | EmployeeName | CoverageName | CoverageAmount | CoveredBy | Month | Year |
8 | Lara | Employee Only | 81 | Employee Contibution | 1 | 2013 |
8 | Lara | Employee Only | 421 | Company Contribution | 1 | 2013 |
8 | Lara | Employee Only | 81 | Employee Contibution | 2 | 2013 |
8 | Lara | Employee Only | 421 | Company Contribution | 2 | 2013 |
8 | Lara | Employee Only | 81 | Employee Contibution | 3 | 2013 |
8 | Lara | Employee Only | 421 | Company Contribution | 3 | 2013 |
8 | Lara | Employee Only | 81 | Employee Contibution | 4 | 2013 |
8 | Lara | Employee Only | 421 | Company Contribution | 4 | 2013 |
8 | Lara | Employee Only | 81 | Employee Contibution | 5 | 2013 |
8 | Lara | Employee Only | 421 | Company Contribution | 5 | 2013 |
8 | Lara | Employee Only | 81 | Employee Contibution | 6 | 2013 |
8 | Lara | Employee Only | 421 | Company Contribution | 6 | 2013 |
8 | Lara | Employee Only | 81 | Employee Contibution | 7 | 2013 |
8 | Lara | Employee Only | 421 | Company Contribution | 7 | 2013 |
8 | Lara | Employee Only | 81 | Employee Contibution | 8 | 2013 |
8 | Lara | Employee Only | 421 | Company Contribution | 8 | 2013 |
8 | Lara | Employee Only | 81 | Employee Contibution | 9 | 2013 |
8 | Lara | Employee Only | 421 | Company Contribution | 9 | 2013 |
8 | Lara | Employee +Children | 214 | Employee Contibution | 10 | 2013 |
8 | Lara | Employee +Children | 606 | Company Contribution | 10 | 2013 |
8 | Lara | Employee +Children | 214 | Employee Contibution | 11 | 2013 |
8 | Lara | Employee +Children | 606 | Company Contribution | 11 | 2013 |
8 | Lara | Employee +Children | 214 | Employee Contibution | 12 | 2013 |
8 | Lara | Employee +Children | 606 | Company Contribution | 12 | 2013 |
Can any one help me out with this.
Thanks!