
/* Code Fragment 9.10 When was it recorded that two projections had the same type? */

SELECT 	P1.PROJECTION_ID, P2.PROJECTION_ID, P1.PROJECTION_TYPE,
	Start_Date =
CASE
	WHEN P1.Start_Date > P2.Start_Date
		THEN P1.Start_Date
		ELSE P2.Start_Date
END,
	Stop_Date =
CASE
	WHEN P1.Stop_Date < P2.Stop_Date
		THEN P1.Stop_Date
		ELSE P2.Stop_Date
END
FROM P_TT AS P1, P_TT AS P2
WHERE P1.PROJECTION_ID <> P2.PROJECTION_ID
AND P1.PROJECTION_TYPE = P2.PROJECTION_TYPE
AND
	CASE
		WHEN P1.Start_Date > P2.Start_Date
			THEN P1.Start_Date
			ELSE P2.Start_Date
	END
<
	CASE
		WHEN P1.Stop_Date < P2.Stop_Date
			THEN P1.Stop_Date
			ELSE P2.Stop_Date
	END
