【发布时间】:2014-02-11 19:10:57
【问题描述】:
如何在 1 个字段中使用 Distinct 或 Group by 语句,其中 SELECT 是全部或至少几个?
示例:使用 SQL SERVER!
SELECT id_product,
description_fr,
DiffMAtrice,
id_mark,
id_type,
NbDiffMatrice,
nom_fr,
nouveaute
From C_Product_Tempo
我想要Distinct 或Group By nom_fr
刚刚得到答案: 选择 id_product, description_fr, DiffMAtrice, id_mark, id_type, NbDiffMatrice, nom_fr, nouvaute 从 ( SELECT rn = row_number() over(按 [nom_fr] 分区,按 id_mark 排序) , id_product, description_fr, DiffMAtrice, id_mark, id_type, NbDiffMatrice, nom_fr, nouvaute 来自 C_Product_Tempo ) d 其中 rn = 1
而且效果很好!
【问题讨论】:
-
你能提供几行数据以及你最终想要达到的结果吗?
标签: sql sql-server group-by distinct