我有一个具有下列列的表。我想知道每天有四个或更多的视频发布的百分比?做这件事最有效的方法是什么?
| video_id | published_date |
+------------+------------------+
| abc | 9/1/2018 |
| dca | 9/4/2018 |
| 5555 | 9/1/2018 |发布于 2019-10-28 21:37:58
Oracle的解决方案:演示
select sum(perc) from (
select published_date
, round(100*(count(*) / sum(count(*)) over ()),2) perc
, count(published_date) cc
from dense_rank_demo
group by published_date)
where cc >= 4;下面是对OP问题的补充解释:“您能解释这个函数应该完成什么吗?SUM(计数(*)) over (),2) perc”
Server解决方案:演示
select sum(perc) Perc from (
select published_date
, round(Count(published_date)* 100 / (Select Count(*) From dense_rank_demo), 2) perc
, count(published_date) cc
from dense_rank_demo
group by published_date) t
where cc >= 4;https://stackoverflow.com/questions/58598389
复制相似问题