下面方法也不可行:
select *, count(distinct name) from table group by name
结果:
ORA-00979: not a GROUP BY expression 00979. 00000 - "not a GROUP BY expression"
依然报错,
group by 必须放在 order by 和 limit之前,不然会报错
------------------------------------------------------------------------------------------------------------
偶认为这样可行
select max(id), name from table group by name;
结果:
id name
1 a
2 b
4 c
5 d
用法二:
一、数据:
1 zjx 001 AAAiBZAAQAAAAVPAAA
2 zjx 002 AAAiBZAAQAAAAVPAAB
3 zjx 001 AAAiBZAAQAAAAVPAAC
二、多字段
select distinct t.name,t.code from test1 t select distinct t.* from test1 t
结果:
1 zjx 001
2 zjx 002
三、单字段
select distinct t.name from test1 t
结果:
1 zjx