No I wanted to output tables that was missing one or the other or both, not just both. HasPrimarykey+HasClusteredIndex is in the order by so tables missing both will sort to the top. Then tables missing only PKs, then tables missing only clustered indexes.