There are multiple cell phone plans(contracts) issued to a productID (cell phone). A cell phone is considered as having a plan if it has an Active contract starting after previous contract's expiration. In the example below, XYZ001 is counted as having a contract because Contract#003 expired on 4/17/2015 but it was followed by an Active contract#005 on 4/18/2015. The remaining ProductIDs do not have active contracts following its expired contracts and should not be counted. Hold status should be ignored. How can it be achieved with a count function in a straight table using Set Analysis or AGGR.