[英]SQL CountIf a condition is met from another column based on average
I want to get a count of cells in Column A that meet a criteria (average of 10 minutes or more) in Column B using SQL. Apologies as I'm definitely not an SQL expert.我想使用 SQL 计算 A 列中满足标准(平均 10 分钟或更长时间)的单元格数量。抱歉,我绝对不是 SQL 专家。 Column B has wait times by second and I need to change it to minute, so basically my equation would be Column_B/60, but then also I want to only count the cells in Column A that have an average of 10 minutes or more in Column B. My current formula is below, I know it's off but to give an idea:
B 列有等待时间,我需要将其更改为分钟,所以基本上我的等式是 Column_B/60,但我也想只计算 A 列中平均等待 10 分钟或更长时间的单元格B. 我目前的公式如下,我知道它已关闭但给出一个想法:
COUNT(CASE Column_A
WHERE Column_B/60 >= 10)
END
You can try你可以试试
SELECT COUNT(*) FROM table_name WHERE Column_B/60 >= 10;
It can be achieved using the two step process below:可以使用以下两步过程来实现:
HH:MM:SS
HH:MM:SS
To display Column_B
in an HH:MM:SS
format, set the Field Type to:要以
HH:MM:SS
格式显示Column_B
,请将字段类型设置为:
Number > Duration (Sec.)
If required, change the aggregation as required, such as to AVG .如果需要,请根据需要更改聚合,例如更改为AVG 。
One way that it can be achieved is by displaying the Column_B
value in seconds (60 seconds * 10 minutes):实现它的一种方法是以秒为单位显示
Column_B
值(60 秒 * 10 分钟):
COUNT(CASE
WHEN Column_B >= 600 THEN Column_A
ELSE NULL END)
Google Data Studio Report and a GIF to elaborate: Google Data Studio 报告和 GIF 来详细说明:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.