gpt4 book ai didi

tsql - TSQL计数“在哪里”条件

转载 作者:行者123 更新时间:2023-12-03 15:11:56 25 4
gpt4 key购买 nike

如何实现以下psuedo-SQL语句的“含义”:

COUNT(distinct id where attribute1 > 0)


换句话说,我该如何做出有条件的,不同的计数语句?

谢谢!

最佳答案

好吧,如果您可以过滤整个查询,那么LittleBobbyTables已经为您提供了the answer。如果没有,您可以这样获取该列:

count(distinct case when attribute1 > 0 then id end) -- implicit null-else, iirc

关于tsql - TSQL计数“在哪里”条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11676226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com