How many teams in the NBA which has at least 3 all-star players?
NBA refers to lgID = 'NBA'; have at least 3 all-star players refers to count(player_allstar.playerID) > 3
SELECT COUNT(*) FROM ( SELECT tmID FROM players_teams AS T1 INNER JOIN player_allstar AS T2 ON T1.playerID = T2.playerID WHERE T1.lgID = 'NBA' GROUP BY T1.tmID HAVING COUNT(DISTINCT T1.playerID) > 3 ) AS T3