当我有 7 列时区分 3 列

Distinct on 3 columns when I have 7

我想要这样的输出 table 使用 db2...

NR  TAG1    TAG2    someData1   someData2
=========================================
1   Class1  2015    11665456     862187687
1   Class1  2014    33254665     86221187687
1   Class1  2013    55557321     8687687787
2   Class2  2015    21654765     86822117687
2   Class2  2014    57658776     8632187687
2   Class2  2013    54878575     8682127687

现在我尝试但未能编写 SQL 代码 在前 3 行有一个 Distinct。

当我尝试使用 (*) 获取所有数据时,我得到了 865 条记录。

当我只取前 3 行并忽略其余行时,我得到 808 条记录。

但我不知道如何显示其余数据。

我假设您希望通过仅考虑前三列并显示结果来删除重复项。如果我的理解有误,请进一步解释。

with cte as 
    (select *, row_number() over(partition by NR, TAG1, TAG2 order by NR, TAG1, TAG2) as row_num from Table_name)
    select * from cte where row_num=1