Friday, March 9, 2012

Removing null values from a result set

Hi,

I have following query which is returing null values along with other values. Could you please tell me how I can restrict to not to return null values

SELECT [Measures].[Total Hours] ON 0,
[Employee].[Hierarchy].[Employee Key]ON 1
FROM[Labor Metrics]

Thanks,

Prudhvi

Prud,

I'm assuming that you want to filter out TotalHours

SELECT [Measures].[Total Hours] ON 0,
[Employee].[Hierarchy].[Employee Key]ON 1
FROM[Labor Metrics]

Where [Measures].[Total Hours] is not null

Ham

|||

Thanks Ham. I did tried this earlier but got the following error message

Executing the query ...
Query (5, 1) The IS function expects a member expression for the 2 argument. A string or numeric expression was used.
Execution complete

|||

Prud,

Are you using SQL 2000 or SQL 2005? The "is not null" is a valid for SQL in the Where clause.

Ham

|||

SSAS 2005 introduces a HAVING clause:

SELECT [Measures].[Total Hours] ON 0,
[Employee].[Hierarchy].[Employee Key]

HAVING [Measures].[Total Hours] <> 0 ON 1
FROM[Labor Metrics]

Or, you can use Filter().

|||

Thanks Teo, it worked.

No comments:

Post a Comment