11.18 学习
1.sql
select m.user_id,round(ifnull(cfnum/p,0),2) confimation_rate from
(select a.user_id,ifnull(num,0) p from Signups a
left join (select user_id,count(*) num from Confirmations
group by user_id)b
on a.user_id=b.user_id) m left join
(select user_id,count(*)cfnum from Confirmations
where action='confirmed'
group by user_id) n
on m.user_id=n.user_id;
2.try catch
@Override
public R<ModelCenterVO> fetchByModelCode(String modelCode) {
try {
result=
...
.one();
return R.ok(result);
} catch (TooManyResultsException e) {
log.error(
"查询到多个结果,错误类型={},错误信息={}",
e.getClass().getName(),
e.getMessage());
return R.fail("modelCode查询到多个模型");
} catch (Exception e) {
log.error(
"内部错误,错误类型={},错误信息={}",
e.getClass().getName(),
e.getMessage());
return R.fail("内部错误");
}
}
标签:return,11.18,学习,user,catch,id,select
From: https://www.cnblogs.com/vastjoy/p/18556700