1、group by()结合max() 滤重策略
select a.aa a.bb max(a.cc)
from tb_a a
group by a.aa,a.bb
oracle中group by方法,不同于mysql,要查询的参数必须要在这个分组内,所以,为了避免这个问题,可以用max方法取到cc的值,这里用count方法没啥用。
2、instr()函数的格式 (俗称:字符查找函数)
格式一:instr( string1, string2 ) // instr(源字符串, 目标字符串)
格式二:instr( string1, string2 [, start_position [, nth_appearance ] ] ) // instr(源字符串, 目标字符串, 起始位置, 匹配序号)
在Oracle/PLSQL中,instr函数返回要截取的字符串在源字符串中的位置。只检索一次,也就是说从字符的开始到字符的结尾就结束
instr的类似like关键字
MySQL: select * from tableName where name like '%helloworld%';
Oracle:select * from tableName where instr(name,'helloworld')>0;
--这两条语句的效果是一样的
instr的参数还可以反过来用,参数1写传参,参数2写数据库字段,这样就可以类似in的方法
select * from tableName where instr('1;11',class_id)>0;
select * from tableName where class_id in(1,11);
--这两个的效果一样--这种情况是比如传参的字符串过来就是以;分隔的,那这个函数的好处就体现出来了。
3、substr函数格式 (俗称:字符截取函数)
格式1: substr(string string, int a, int b);
1、string 需要截取的字符串(空格也算一个字符)
2、a 截取字符串的开始位置(注:当a等于0或1时,都是从第一位开始截取)
3、b 要截取的字符串的长度
格式2:substr(string string, int a) ;
1、string 需要截取的字符串
2、a 可以理解为从第a个字符开始截取后面所有的字符串。
4、查询序号函数