试图让我的查询组,但它不喜欢我的组,所以我必须拿出一些其他东西。如何为每个唯一的person\u id和ah\u person\u id组合获取一行,与哪一行无关。
WITH w_accnt AS
(SELECT DISTINCT account.id AS id,
account.group_code AS account_number,
account.attribute_1 AS group_number,
account.source_id AS ah_person_id,
weekly.person_id AS person_id
FROM MyAccountTable account
INNER JOIN MyWeeklyTable weekly
ON weekly.account_id = account.id
),
示例表
Person AH_PERSON ACCOUNT_num
A 1 22
B 2 23
B 2 24
C 3 25
C 4 26
我想要的是预期的结果
Person AH_PERSON ACCOUNT_num
A 1 22
B 2 23
C 3 25
C 4 26
谢谢
1条答案
按热度按时间esyap4oy1#
使用聚合:
或者窗口功能:
这样可以更好地控制返回的值,并确保它们都来自同一行。