TABLE(test)
a b
1 1
1 1
2 2
2 2
2 2
3 3
select distinct a,b from test
出来
1 1
2 2
3 3
有没有办法,不用distinct ,而出来这样的结果,只有两个字段,a,b,请高手指点
a b
1 1
1 1
2 2
2 2
2 2
3 3
select distinct a,b from test
出来
1 1
2 2
3 3
有没有办法,不用distinct ,而出来这样的结果,只有两个字段,a,b,请高手指点
(
select * , px = row_number() over(partition by a , b order by a , b) from test
) t
where px = 1
select a,b
from (select a,b ,count(1) c from test group by a,b) m
SELECT 1, 1
UNION ALL
SELECT 1, 1
UNION ALL
SELECT 2, 2
UNION ALL
SELECT 2, 2
UNION ALL
SELECT 2, 2
UNION ALL
SELECT 3 ,3SELECT * FROM testp tselect a,b
from (select a,b ,count(1) c from testp group by a,b) ma b
----------- -----------
1 1
2 2
3 3(3 row(s) affected)
b
from test
group by a,b
select a,b from test group by a,b