独特的值对SQL [英] Distinct pair of values SQL
本文介绍了独特的值对SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
创建表对(数字a,数字b)
数据为
1,1
1,1
1,1
2,4
2,4
3,2
3,2
5,1
等等。
什么查询为我提供了数字列b的不同值所以我可以看到
1,1
5,1
2,4
3,2
只有
我试过了
select distinct(a),b from pairs group by b
但给我不是一个组通过表达式
解决方案
您的意思是
SELECT DISTINCT a,b FROM pairs;
或
SELECT a,b FROM对GROUP BY a,b;
Consider
create table pairs ( number a, number b )
Where the data is
1,1
1,1
1,1
2,4
2,4
3,2
3,2
5,1
Etc.
What query gives me the distinct values the number column b has So I can see
1,1
5,1
2,4
3,2
only
I've tried
select distinct ( a ) , b from pairs group by b
but gives me "not a group by expression"
解决方案
What you mean is either
SELECT DISTINCT a, b FROM pairs;
or
SELECT a, b FROM pairs GROUP BY a, b;
这篇关于独特的值对SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文