| date | nums | tag |
| 2019-3-11 | 1 | A |
| 2019-3-11 | 2 | B |
| 2019-3-12 | 4 | A |
| 2019-3-12 | 5 | B |
select nu-nums,F.tag
from
(
select *
from
pandora_fea_num
where
{t [conditions.daterange1(first)]}
) F INNER JOIN
(
select nums as nu, t as nt, tag
from
pandora_fea_num
where
{t [conditions.daterange1(last)]}
) M where F.tag=M.tag
分母为0的处理情况:
select F.date as date, (case M.nums=0 then 0 else 100*(F.S/M.nums) end) as pvr, M.L as source
from (
select date, nums, source as L
from img_monitor_imageid
where date="20190806"
) M INNER JOIN (
select date , nums as S ,source as D
from img__fea
where date="20190806"
) F where F.date=M.date and F.D=M.L;
SQL数据处理与分析技巧
本文深入探讨了SQL中复杂的数据处理与分析方法,包括如何使用CASE语句处理分母为0的情况,以及如何通过INNER JOIN操作连接不同数据集进行对比分析。文章详细解释了SQL查询语句的构造,展示了如何从特定日期范围内的数据集中筛选并计算比例值,为读者提供了实用的SQL编程案例。
6994

被折叠的 条评论
为什么被折叠?



