MDX查询问题

发布于 2024-09-15 03:21:30 字数 239 浏览 3 评论 0原文

在分析服务中,我有基于住院数据的立方体。对于每次住院治疗,可能有 9 个 ICD 代码,每个代码都存储在多维数据集所基于的视图中各自的字段中。这些存储在 SSAS 数据库所基于的关系数据库的子表中。

我想查询多维数据集以返回在 9 个 ICD 代码字段中的任意一个或多个字段中具有特定 ICD 代码的所有行。在 WHERE 或 Filter 子句中使用这种“OR”似乎应该很简单,但我没有找到正确的方法。

提前致谢, 杰里米·施拉德

In analysis services, I have cube that is based on hospitalization data. For each hospitalization there are potentially 9 icd codes and these are each stored in their own field in the view on which the cube is based. These are stored in a child table in the relational database on which the SSAS database is based.

I would like to query the cube to return all rows that have a certain ICD code in any one or more of the 9 icd code fields. It seems as if it should be simple to have this sort of "OR" in the WHERE or the Filter clause, but I'm not finding the correct method.

Thanks in advance,
Jeremy Schrader

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

薄荷港 2024-09-22 03:21:30

据我了解,您是一名 SQL 人员,并且是 MDX 新手,所以这就是您在查询时遇到困难的原因。

如果您告诉我们您想要使用 ICD 代码选择哪些措施,那就更好了,但我将尝试向您展示尽可能简单的 mdx 查询示例。您的查询应如下所示;

select {Measure1,Measure2,...} on columns
ICDCodeDimension.Children on rows
//{ICDCodeDimension.ICDCode1,ICDCodeDimension.ICDCode5,...} on rows
from Cube

MDX 是非常先进的查询语言,您应该了解/学习更多概念才能有效地使用它。

希望这有帮助。

As far as i understand, you are an SQL guy and new to MDX, so that's why you have difficulties for the query.

it would be better if you tell us what are the measures you want to select with ICD codes but i am going to try to show you an mdx query sample as simple as possible. Your query should like below;

select {Measure1,Measure2,...} on columns
ICDCodeDimension.Children on rows
//{ICDCodeDimension.ICDCode1,ICDCodeDimension.ICDCode5,...} on rows
from Cube

MDX is highly advanced query language and there are many more concept you should know/learn to use it effectively.

Hope this help.

青巷忧颜 2024-09-22 03:21:30

我猜你会有一个名为 [ICD 代码] 的维度,其中有一个名为 [代码] 的级别和 9 个名为 [代码 A] 和 [代码 B] 或其他的成员。也许甚至是[无代码]的会员?

在这种情况下,您的查询将能够告诉您在特定时间段内所有医院中每个代码的住院病例总数:

SELECT {[ICD Codes].[Codes].members} ON ROWS,
{[Measures].[Number of Cases]} ON COLUMNS
FROM [CubeName]
WHERE ([Time].[2010].[Quarter 1])

I am guessing that you'd have a dimension called [ICD Codes] with a single level called [Codes] and 9 members called [Code A] and [Code B] or whatever. Perhaps even a member for [No code] too?

In that case your query would be able to tell you the total number of hospitalisation cases for each code, for a certain time period, across all hospitals:

SELECT {[ICD Codes].[Codes].members} ON ROWS,
{[Measures].[Number of Cases]} ON COLUMNS
FROM [CubeName]
WHERE ([Time].[2010].[Quarter 1])
情栀口红 2024-09-22 03:21:30

感谢您的反馈。在我进一步研究之后(特别是这里的一篇文章: http://sqlblog.com/blogs/mosha/ default.aspx 使用 SUBCUBE 方法提供一些“OR”功能,但性能非常差)我意识到我正在寻找的 OR 构造需要记录级信息,因此在聚合后不起作用SSAS 执行的操作。因此,我需要在事实表上创建一个字段,其中包含我需要的 SQL“OR”语句的结果。

在这种情况下,我将只为在 9 个 ICD 代码字段中的任何一个中具有特定范围的 ICD 代码的任何记录创建一个标志。然后,我将创建一个度量来对这些进行计数。幸运的是,我的应用程序的要求是只需要以这种方式查看有限数量的诊断(即任何与糖尿病相关、烟草相关的住院治疗等)。我仍然很好奇如果您需要允许用户选择任何 ICD 代码,人们将如何解决这个问题。我目前的理解是,您需要恢复到纯 SQL。

杰里米

Thanks for both of your feedback. After I researched further (particularly an article here: http://sqlblog.com/blogs/mosha/default.aspx that uses the SUBCUBE method to give some "OR" functionality but with very poor performance) I realized that the OR construct that I was looking for requires record-level information and so doesn't work after the aggregation that SSAS performs. Thus, I need to create a field on the fact table that has the result of the SQL "OR" statement that I need.

In this case I will just create a flag for any record that has a certain range of ICD codes in any of the 9 ICD code fields. Then, I'll create a measure that gives a count of these. Luckily, the requirements of my app are that only a limited number of diagnoses need to be looked at in this way(i.e. any hospitalization that is diabetes-related,tobacco-related,etc.). I'm still curious how one would approach this if you needed to allow the user to choose any ICD code. My understanding at this point is that you would then need to revert back to plain SQL.

Jeremy

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文