如何计算 Oracle SQL 中行之间的百分比增加?

问题描述

我有如下数据:

post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name.start_with?("Pods")
  puts "Updating #{target.name} to exclude Firebase/Analytics"
  target.build_configurations.each do |config|
    xcconfig_path = config.base_configuration_reference.real_path
    xcconfig = File.read(xcconfig_path)
    xcconfig.sub!('-framework "FirebaseAnalytics"','')
    new_xcconfig = xcconfig + 'OTHER_LDFLAGS[sdk=iphone*] = -framework "FirebaseAnalytics"'
    File.open(xcconfig_path,"w") { |file| file << new_xcconfig }
  end
end
end
end

我想把它做成一个表格来计算添加的访问成员的百分比:

YEAR_MONTH|AVG_VISITS|WAS_MEMBER
2020-09|10|True
2020-09|5|False
2019-04|2.5|True
2019-04|5|False

让我在行之间查看此类计算的 sql 是什么?

解决方法

您只需要如下条件聚合:

select year_month,100 * sum(case when WAS_MEMBER = 'True' then avg_visits end) /
       sum(case when WAS_MEMBER = 'False' then avg_visits end) as perc_increase
  from your_table t
group by year_month

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...