select contentid, count(*) howmany, min(fromtype) mnfrom, max(fromtype) mxfrom from parts group by contentid having min(fromtype) <= 2 and max(fromtype) >= 3