2个计数并将结果组合为一列| SQL Server Management Studio
我试图根据某些登记日期和创建日期在数据库中对数据库中的不同ID进行计数。
tables:
- people p
- number n
- message m
- volume v
要求
在链接到ID的数字的情况下; 最古老的数字之间的时间registrationDateTime和Message.CreationDateTime< = 10 wd
,如果链接到ID的音量(和没有数字); 最古老的数字之间的时间registrationDateTime和Message.CreationDateTime< = 10 wd
均应总计计数为
查询的我计数:
- count(case cast deDiff(dw,dw,n.RegistrationDateTime,m.creationdateTime,m.creationdateTime)< lt; = 10然后p.id end作为a
- ,count(dw,dw,v.registrationDateTime,m.creationdatetime)< = 10 then p.id end as a
我的问题;
- 我如何结合2个计数的总数,该计数将显示在“ A”列中
Im trying to do a count of distinct Id's of people in a database based on some registrationdate and creationdate.
tables:
- people p
- number n
- message m
- volume v
Requirements
In case of a number linked to the Id;
the time between the oldest number.registrationdatetime and message.creationdatetime <= 10 wdIn case of a volume (and no number) linked to the Id;
the time between the oldest number.registrationdatetime and message.creationdatetime <= 10 wd
Both should be counted in total as A
my count part of the query:
- count (case when datediff(dw, n.registrationdatetime , m.creationdatetime) <=10 then p.id end as A
- ,count (case when datediff(dw, v.registrationdatetime , m.creationdatetime) <=10 then p.id end as A
my question;
- How do I combine the 2 counts for a total that will be displayed in column "A"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论