oracle-sql
1.替换表中某个字段中的字符串(不忽略大小写):
update test_customer set org_no = replace(org_no,'ORG','AJS');
2.给表中字段对拼接上“员会”:
update loan_arbitrate_config a set a.arbitrate_org =
(
select b.arbitrate_org||'员会' from loan_arbitrate_config b where b.id<67 and b.id = a.id
);
3.更新规则计划,逗号拼接字符串分别拼接上“员会”:
update loan_arbitrate_config z set z.rule_plan =
(
---查询将规则计划中字段都拼接上员会
select
case substr(a.rule_plan,0,2)
when '石家' then '石家庄仲裁委员会、海南仲裁委员会、珠海仲裁委员会'
when '海南' then '海南仲裁委员会、石家庄仲裁委员会、珠海仲裁委员会'
else '珠海仲裁委员会、石家庄仲裁委员会、海南仲裁委员会'
end rule_plan
from loan_arbitrate_config a
where z.id = a.id
)
where z.id < 67;
4.分组函数与group by:
(1):用了分组函数,未分组的列都要包含在group by子句中。
(2):分组函数可以不结合group by使用。
5.having子句:
having子句与group by结合使用,
having子句可以使用结果集中的列,也可以使用聚合函数(max、min、count、sum、svg)。having的作用是对分组后的结果进行过滤。
where是对每一行进行过滤的,查询出符合where条件的每一行。
having是对查询出结果集分组后的结果进行过滤。