Oracle sql 去除重复 和 字段去除空格

1.去除重复两种方式 

1.1 distinct 函数

select distinct userid from projectinfo where projecttype in (select id from p_fundcategory where departid = 21 and parentid !=0)


1.2  group by 也可以

select userid,count(userid) from projectinfo where projecttype in (select id from p_fundcategory where departid = 21 and parentid !=0) group by userid 



2.去除左右空格

函数 ltrim左边空格

函数rtrim右边空格

两个函数联合使用 ltrim(rtrim(name)) 就可以了

你可能感兴趣的:(SQLServer,oracle)