So I have this data structure
ID DATE1 STATUS1 DATE2 STATUS2
1 1/1/2012 1 1/1/2012 3
1 3/1/2012 1 1/2/2012 3
2 2/1/2012 1 3/4/2012 3
3 4/1/2012 1 NULL 3
4 2/1/2012 1 6/2/2012 3
How would I get to…
ID DATE STATUS
1 1/1/2012 1
1 1/1/2012 3
1 3/1/2012 1
1 1/2/2012 3
2 2/1/2012 1
2 3/4/2012 3
3 4/1/2012 1
3 NULL 3
4 2/1/2012 1
4 6/2/2012 3
My initial guess might be to use lots of unioned unpivots?
You can use union for this:
if you want to remove dupes, just replace
union allwithunionNote: I’ve named the resulting date column
mydatebecause date is probably a reserved keyword in whichever dbms you’re using..