Subject Self join problem
Author Chris Wallis
Given a table with the following values

DOC_ID SEC_ID AVALUE
1 1 A
1 2 B
1 3 C
1 5 E
2 1 A
2 3 C
2 4 D

is there any query construct that will return a table like this

SEC_ID AVALUE AVALUE_0
1 A A
2 B null
3 C C
4 null D
5 E null

I'm trying to a self join on a table based on SEC_ID and compare results
from an earlier and later period so that I can compute differences between
the periods. I was hoping to do this in a stored procedure using outer joins
but I can't make it work. Any help is most welcome.