简体   繁体   中英

SQL Server MDX Query: All Member accounts and Member Emails with = 0 minutes Using CROSSJOIN AND FILTER

I am new to SQL Server and am trying to get a query to show the members for all [Email] (ie User's E-mail Addresses) who have (null) values for the [Mins] field AND I also want a column for the user's [Account Name] (ie the company they work at).

Getting the query to run with the [Account Name] with ".Members" at the end is where I'm falling down. All three of these fields are on different tables, and I'm using a combination of CROSSJOIN AND FILTER.

I am not sure if the query won't run because:

  1. I am using .Members incorrectly, since I'm using for both [Email] and [Account Name], OR
  2. We have some sort of memory issues (which wouldn't be the first time!).

I am new to SQL and found different solutions on StackOverFlow for parts of the problem to successfully piece together the below code, but I've been unable to piece it together by adding ".Members" after "[Account Name]" The query runs but after a couple of minutes it runs out of memory.

If I don't include ".Members" after "[Account Name]", then the query runs successfully after about 17 seconds; however, it just shows "All" for Account Name, and it doesn't show the account. I simply want to show the Account next to Email!

'''
SELECT
    [Measures].[Sum of Mins]
        ON COLUMNS,
    CROSSJOIN(
        [vw_AccountData].[Account Name].Members,
            Filter (
                    [vw_UserData].[Email].Members,
                    [Measures].[Sum of Mins] = 0
                     ))
         ON ROWS
FROM [Model]  
'''

Expected/Actual Results

My understand is that for the users who have null values or zero values for this measure [Measures].[Sum of Mins you want their emailid and account name. I presume you have a measure [Measures].[Sum of Mins] and dimension attributes [vw_AccountData].[Account Name] and [vw_UserData].[Email] in your cube

Select 
[Measures].[Sum of Mins]
ON COLUMNS,
filter 
(
([vw_AccountData].[Account Name].[Account Name],[vw_UserData].[Email].[Email]),
[Measures].[Sum of Mins] = 0
)
on rows
from 
[Model]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM