如何显示没有匹配值的记录? [英] How do you show records with no matching values?

查看:113
本文介绍了如何显示没有匹配值的记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定我是否正确地提出了我的问题。但我想要做的是运行两个相关表格的报告如下:


第一个表名为Category - 它有一个名为Category的字段,也是主键。表中列出了18种类别。


第二个表称为CaseManagement,没有主键,还有多个字段,包括从相关类别表中获取的类别。


他们与从Category到CaseManagement的一对多链接有关。


在我的报告中,我想列出所有类别表中的类别来自CaseManagement表中每个类别的案例数。


我的问题是,如果一个classesoy在CaseManagement表中没有任何相关数据,那么该类别不会列在我的报告中。我希望报告包含Cattegory表中的每个类别,如果它在CaseManagement表中没有任何相关数据,则显示0。


感谢您的帮助

Dan

I am not sure if I worded my question correctly. But what I want to do is run a report from two related tables as follows:

The first table is called Category - it has one field, called Category, that is also the primary key. There are 18 categries listed in the table.

The second table is called CaseManagement, with no primary key, and multiple fields including Category which is taken from the related Category table.

They are related with a one to many link from Category to CaseManagement.

In my report I want to list all the categories from the Category table followed by the number of cases in each category from the CaseManagement table.

My problem is that if a categoy does not have any related data in the CaseManagement table, the category is not listed in my report. I want the report to include every category from the Cattegory table and show a 0 for it if it does not have any related data in the CaseManagement table.

Thanks for any help
Dan

推荐答案

SELECT Category.Category,Count(CaseManagement.Category)AS CountOfCategory

FROM Category LEFT JOIN CaseManagement ON Category.Category = CaseManagement.Category

GROUP BY Category.Category;
SELECT Category.Category, Count(CaseManagement.Category) AS CountOfCategory
FROM Category LEFT JOIN CaseManagement ON Category.Category = CaseManagement.Category
GROUP BY Category.Category;



SELECT Category.Category,Count (CaseManagement.Category)AS CountOfCategory

FROM Category LEFT JOIN CaseManagement ON Category.Category = CaseManagement.Category

GROUP BY Category.Category;
SELECT Category.Category, Count(CaseManagement.Category) AS CountOfCategory
FROM Category LEFT JOIN CaseManagement ON Category.Category = CaseManagement.Category
GROUP BY Category.Category;



谢谢您的回复,但我在哪里放置此代码?请原谅我的无知。


感谢您的帮助。

Dan


Thankyou for your response but where do I place this code? Please excuse my ignorance.

Thank you for your help.
Dan


从数据库窗口中选择查询选项卡。


单击新建,在新建查询对话框中选择设计视图,然后单击确定。


在显示表对话框中框,单击关闭。


从Access菜单栏中,单击View~SQL View并将代码粘贴到该窗口中。


来自访问菜单栏,单击View~Design View,您将在图形设计窗口中看到查询。保存查询。


当你运行查询时,你会看到结果。
From the Database Window, select the Queries tab.

Click New, and at the New Query dialog box select Design View and then click OK.

At the Show Table dialog box, click Close.

From the Access menu bar, click View ~ SQL View and paste the code into that window.

From the Access menu bar, click View ~ Design View and you''ll see the query in the graphical design window. Save the query.

When you run the query you''ll see the results.


这篇关于如何显示没有匹配值的记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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