4 열을 포함하는 Table1
테이블이 있습니다. 예를 들어SQL Server 2008 R2에서 쿼리가 필요합니다.
:
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
4 열을 포함하는 Table1
테이블이 있습니다. 예를 들어SQL Server 2008 R2에서 쿼리가 필요합니다.
:
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
Select Distinct Field1, Field2
from Table1
나는 field3과 field4 ... 괜찮 았어.하지만 뚜렷한 field1과 2를 원한다. – Ibra
SELECT DISTINCT Field1,Field2 FROM TABLE_NAME
방법 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
는 필드 1에 의존 FIELD2인가? – user2864740