当字段中存在text类型字段时,选取重复数据不能用distinct
方法1:
把text类型字段转为varcahr类型,再用distinct
方法2:
利用开窗函数,个人觉得比方法一效率高,下面的sql语句是伪代码哈,写个思路而已
with table1 as
(
select *,ROW_NUMBER() over(partition by a,b order by a)
as number from t
)
select * from table1 where number=1
当字段中存在text类型字段时,选取重复数据不能用distinct
方法1:
把text类型字段转为varcahr类型,再用distinct
方法2:
利用开窗函数,个人觉得比方法一效率高,下面的sql语句是伪代码哈,写个思路而已
with table1 as
(
select *,ROW_NUMBER() over(partition by a,b order by a)
as number from t
)
select * from table1 where number=1