在 SQL 中使用带大小写的 IN 运算符?

吐司豆

我正在尝试运行一个 case when 语句与IN运算符一起使用 - 这样当值(或多个值)URL被提供给 IN 子句时,当它们匹配时,它会在给值 1 或 Null 时执行 case提供的一个 URL 或一组 URL。

我很困惑如何在IN操作时实际使用操作符。我希望能够在它有 url 的地方提供多个值 - 而不是一个。这可能吗?

我的代码如下:

create temp table ag_table as 
   with sq AS(select id, business, 
   cat1, cat2, channel, call_reason, 
   COUNT(case cat1 when url then 1 else null end) 
   over (partition by subject 
order by 
time range between 604800 preceding
and current row) as count 
from table_name
where table_name.start >= start and table.end_time <= end
)

注意我正在使用 SQLite

福帕斯

这是 CASE 表达式的语法:

COUNT(case when category1 IN (url1, url2, ...) then 1 end)

不需要else null(当没有 else 时,null 是默认值)。
同样可以通过以下方式实现:

SUM(category1 IN (url1, url2, ...))

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章