Thursday, August 12, 2010

Some Tricky SQLs FTE

I have a requirement where in I have to get starting date and ending date of an FTE Value. Sample Employee data is as follows. Can we create a View which will give my desired rages as shown in the following format.

Employee Data:
EMPLID EMPL_RCD EFFDT FTE
000051 0 01-jan-2008 1
000051 0 10-feb-2008 1
000051 0 10-mar-208 0.5
000051 0 10-apr-2008 0.5
000051 0 10-may-2008 1
000051 0 10-jun-2008 1
000051 0 10-jul-2008 0.5

Required output format:
EMPLID EMPL_RCD FTE FTE_BGN_DT FTE_END_DT
000051 0 1 01-jan-2008 09-mar-2008
000051 0 0.5 10-mar-2008 09-may-2008
000051 0 1 10-may-2008 09-Jul-2008
000051 0 0.5 10-jul-2008 null

If the above tables are not clear enough to understand, Below image will give clear picture of the table structure.

No comments:

Post a Comment