1 1
2 2
1 3
2 4
我只要a列不重复的项 ,b列哪个都行????急!!请帮忙,先谢过了
10 个解决方案
#1
加关键字 distinct
#2
select distinct a from 表
#3
? 你是要不重复的列? 还是去掉重复列??? 去掉重复列. 使用distinct 就行了
#4
#5
如果是 选择不重复列.
select *
from table b inner join
(
select a
from table
group by a
having count(a)=1
) as c on b.a=c.a
select *
from table b inner join
(
select a
from table
group by a
having count(a)=1
) as c on b.a=c.a
#6
select a,min(b) from table
group by a
#7
select * from table a where not exists(select 1 from table where a.a = a and a.b<b)
#8
但是,我还想要表中的其他列。如果用distinct就只能查处a这一列了,
#9
select distinct a,b,c,..... from 表
你想要多少都可以。。。。
你想要多少都可以。。。。
#10
哦,明白lz的意思咯。。。
那用group by
再每组取一条记录
那用group by
再每组取一条记录
#1
加关键字 distinct
#2
select distinct a from 表
#3
? 你是要不重复的列? 还是去掉重复列??? 去掉重复列. 使用distinct 就行了
#4
#5
如果是 选择不重复列.
select *
from table b inner join
(
select a
from table
group by a
having count(a)=1
) as c on b.a=c.a
select *
from table b inner join
(
select a
from table
group by a
having count(a)=1
) as c on b.a=c.a
#6
select a,min(b) from table
group by a
#7
select * from table a where not exists(select 1 from table where a.a = a and a.b<b)
#8
但是,我还想要表中的其他列。如果用distinct就只能查处a这一列了,
#9
select distinct a,b,c,..... from 表
你想要多少都可以。。。。
你想要多少都可以。。。。
#10
哦,明白lz的意思咯。。。
那用group by
再每组取一条记录
那用group by
再每组取一条记录