我有一个名为Table1
的表,其中包含4列。
例如:
id Field1 Field2 fIELD3
1 A 1 R1
2 A 1 R2
3 B 3 R21
4 A 1 R3
5 B 3 R44
我需要一个给我这个结果的查询
Field1 Field2
A 1
B 3
答案 0 :(得分:2)
Select Distinct Field1, Field2
from Table1
答案 1 :(得分:2)
SELECT DISTINCT Field1,Field2 FROM TABLE_NAME
答案 2 :(得分:0)
方法1:
SELECT Field1, Field2
from Table1
Group BY Field1, Field2
方法2:
Select Distinct Field1, Field2
From Table1
方法3:
Select Field1, Field2
From
(
Select Field1, Field2,Row_NUmber() Over(Partition by Field1, Field2 Order By Field1) AS RN
) AS T
Where RN = 1