Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7729559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:59:49+00:00 2026-06-01T05:59:49+00:00

I am having trouble with a slowly changing dimension type II selection. I am

  • 0

I am having trouble with a slowly changing dimension type II selection. I am looking to select the actual length of an employees skill certification so that i can display start and end of his certification in a report. How would you go about doing that? Below i have included an image of the records for an employee ‘80844’ and below the records the expected result.

I am using Microsoft SQL Server 2008 R2.

Records an employee 80844 and the expected result needed to display his certification

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:59:50+00:00Added an answer on June 1, 2026 at 5:59 am

    Thank you for interesting question. It is well-known ‘gaps and islands’ problem. You can read more about it there.

    For your case solution could look like this:

        create table #tmp 
           (
             dimEmployeeID int not null,
             EmployeeNumber int not null,
             Start datetime not null,
             [End] datetime not null,
             SkillID int not null
           )
    
    
       insert into #tmp values
         (386 , 80844, '1900-01-01', '2012-02-28', 14),
         (1172, 80844, '2012-02-29', '2012-02-29', 14),
         (1173, 80844, '2012-03-01', '2012-04-01', 14),
         (1175, 80844, '2012-04-06', '2012-04-12', 14),
         (1176, 80844, '2012-04-13', '2012-04-21', 14),
         (1172, 80844, '2012-02-29', '2012-02-29', 87),
         (1173, 80844, '2012-03-01', '2012-04-01', 87),
         (1174, 80844, '2012-04-02', '2012-04-05', 87),
         (1175, 80844, '2012-04-06', '2012-04-12', 87)
    
       ;with StartingPoints as
       (
         SELECT EmployeeNumber, SkillID, Start, ROW_NUMBER() OVER(partition by EmployeeNumber,    SkillID order by Start asc) AS rn
         FROM #tmp AS A
         WHERE NOT EXISTS
           (
             SELECT 1
             FROM #tmp AS B
             WHERE 
               A.EmployeeNumber = B.EmployeeNumber
               and A.SkillID = B.SkillID
               and A.Start - 1 = B.[End]
            )
       ),
       EndingPoints AS
       (
         SELECT EmployeeNumber, SkillID, [End], ROW_NUMBER() OVER(partition by EmployeeNumber,    SkillID order by Start asc) AS rn
         FROM #tmp AS A
         WHERE NOT EXISTS
           (
             SELECT 1
             FROM #tmp AS B
             WHERE 
               A.EmployeeNumber = B.EmployeeNumber
               and A.SkillID = B.SkillID
               and A.[End] + 1 = B.Start
            )
       )
       SELECT S.EmployeeNumber, S.SkillID, S.Start, E.[End]
       FROM StartingPoints AS S
         JOIN EndingPoints AS E
       ON 
         S.EmployeeNumber = E.EmployeeNumber
         and S.SkillID = E.SkillID
         and S.rn = E.rn
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having trouble with proper regex for RewriteCond RewriteCond %{REQUEST_URI} !^/foo/ Works as expected, that
I'm having some trouble getting an object to follow a path that is drawn
Having trouble getting this syntax right: SELECT DISTINCT id FROM metadata WHERE (meta_key =
Having trouble with some select statements. I have 2 tables. sms_log and sms_messages. sms_log
Having trouble with the db.alter command when changing a date field from null=True and
Having trouble inheriting from a template class. Looks something like this: template<typename type> class
Having trouble with a horizontal scroll bar that pops up. My page is set
Having trouble with the following segment of code. I'm getting a parameter count mismatch.
Having Trouble with Entity Framework. I have been populating EntityReferences with an EntityKey inorder
Having trouble finding an explanation in the docs, would someone be kind enough to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.