如图两张ORACLE数据表我要如何让表1中数据列除以表2中的总数据
答案:1 悬赏:30 手机版
解决时间 2021-11-11 07:32
- 提问者网友:心如荒岛囚我终老
- 2021-11-10 19:12
如图两张ORACLE数据表我要如何让表1中数据列除以表2中的总数据
最佳答案
- 五星知识达人网友:毛毛
- 2021-11-10 19:38
select a.brand_id,a.brand_name,(a.cnt1/b.cnt2)*100||'%' percentage from (select g.brand_id, c.brand_name, count(g.brand_id) cnt1 from car_goods_info g left join car_brand c on g.brand_id=c.id group by g.brand_id,c.brand_name ) a left join
(select count(*) cnt2 from car_goods_info) b on 1=1 试试追问我去 真厉害!!那个小数位数能不能限制在2位之内啊,还有就是。。前面的0咋没了- -!
追答select a.brand_id,a.brand_name,round((a.cnt1/b.cnt2)*100,2)||'%' percentage from (select g.brand_id, c.brand_name, count(g.brand_id) cnt1 from car_goods_info g left join car_brand c on g.brand_id=c.id group by g.brand_id,c.brand_name ) a left join
(select count(*) cnt2 from car_goods_info) b on 1=1
(select count(*) cnt2 from car_goods_info) b on 1=1 试试追问我去 真厉害!!那个小数位数能不能限制在2位之内啊,还有就是。。前面的0咋没了- -!
追答select a.brand_id,a.brand_name,round((a.cnt1/b.cnt2)*100,2)||'%' percentage from (select g.brand_id, c.brand_name, count(g.brand_id) cnt1 from car_goods_info g left join car_brand c on g.brand_id=c.id group by g.brand_id,c.brand_name ) a left join
(select count(*) cnt2 from car_goods_info) b on 1=1
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯