我需要将每个用户ID的行压缩为一行,只有唯一的产品ID,并且排除任何唯一产品的数量> 2的地方。有人可以指出我正确的方向。
+--------------+-------------+-----------------+-------------+-----------------+ | UserID | ProductID1 | CoverageLevel1 | ProductID2 | CoverageLevel2 | +--------------+-------------+-----------------+-------------+-----------------+ | 1 | 90001439952 | C | 90001439952 | C | | 1 | 90001439952 | C | 90026439964 | A | | 2 | 90145434879 | A | 90017434947 | D | | 2 | 90145434879 | A | 90017434947 | B | +--------------+-------------+-----------------+-------------+-----------------+
由于UserID = 2具有唯一值(90145434879& A,90017434947& D,90017434947& B),因此将排除该ID的所有记录。
+--------------+-------------+-----------------+-------------+-----------------+ | UserID | ProductID1 | CoverageLevel1 | ProductID2 | CoverageLevel2 | +--------------+-------------+-----------------+-------------+-----------------+ | 1 | 90001439952 | C | 90026439964 | A | +--------------+-------------+-----------------+-------------+-----------------+