可以直接這樣寫
select name
from table
group by name
having count(*)=1
如果不好理解,其實是等同
select name,count(*)
from table
group by name
having count(*)=1
select name
from table
group by name
having count(*)=1
如果不好理解,其實是等同
select name,count(*)
from table
group by name
having count(*)=1
我要的结果是
id name
1 a
2 b
3 c
5 b
我要的结果是
id name
1 a
2 b
3 c
而不是只查询name一个字段
select max(id),name
from table
group by name
select (row_number() over (order by name)) id,
name
from a
group by name
from table
group by name
4 c
两条记录随便取一条吗?sleect id ,name from (select id ,name, rank() over(partition by id order by name) rank from table) where rank=1
dinya2003(OK) 的方法必须要Oracle9i以上才可以运行
差不多