如何在 SQL Server Compact Edition 中进行此查询? [英] How can I make this query in SQL Server Compact Edition?

查看:37
本文介绍了如何在 SQL Server Compact Edition 中进行此查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此子查询适用于 SQL Server:

this subquery works in SQL Server:

select systemUsers.name, 
    (select count(id) 
     from userIncidences 
     where idUser = systemUsers.id ) 
from systemUsers

如何在 SQL Compact 中制作?

How can It be made in SQL Compact?

谢谢!

推荐答案

试试这个:

SELECT su.Name, COUNT(ui.ID)
FROM systemUsers su
LEFT JOIN userIncidences ui ON ui.idUser = su.ID
GROUP BY su.Name


我最初有一个像 Tomalak 一样的 INNER JOIN,但我意识到这会排除没有事件的用户,而不是用 0 计数显示他们.这甚至可能是您想要的,但与您的原件不符.


I originally had an INNER JOIN just like Tomalak, but I realized that this would exclude users with no incidents, rather than show them with a 0 count. That might even be what you want, but it doesn't match your original.

这篇关于如何在 SQL Server Compact Edition 中进行此查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆