Unix Technical Forum

Simple query

This is a discussion on Simple query within the SQL Server Data Warehousing forums, part of the Microsoft SQL Server category; --> Hi, I've just started with Analysis Services. I have had created simple query on 'FoodMart 2000': SELECT{ [Measures].[Unit Sales]} ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server Data Warehousing

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 07:39 PM
mkazmierski@gmail.com
 
Posts: n/a
Default Simple query

Hi,

I've just started with Analysis Services. I have had created simple
query on 'FoodMart 2000':

SELECT{ [Measures].[Unit Sales]} ON COLUMNS,
[Promotions].[Promotion Name].Members ON ROWS
FROM Sales

Now I just want to modify it to get not all, but only first ten
Promotion Names with the highest unit sales. Could you help me with
that (if you could also point some good resources about mdx I would be
grateful).

Regards, Mark

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 07:40 PM
=?Utf-8?B?bWlrZQ==?=
 
Posts: n/a
Default RE: Simple query

WITH
SET [TOP 10] AS 'TOPCOUNT({[Promotions].[Promotion Name].Members}, 10,
[Measures].[Unit Sales])'
SELECT{ [Measures].[Unit Sales]} ON COLUMNS,
[TOP 10] ON ROWS
FROM Sales

"mkazmierski@gmail.com" wrote:

> Hi,
>
> I've just started with Analysis Services. I have had created simple
> query on 'FoodMart 2000':
>
> SELECT{ [Measures].[Unit Sales]} ON COLUMNS,
> [Promotions].[Promotion Name].Members ON ROWS
> FROM Sales
>
> Now I just want to modify it to get not all, but only first ten
> Promotion Names with the highest unit sales. Could you help me with
> that (if you could also point some good resources about mdx I would be
> grateful).
>
> Regards, Mark
>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 07:40 PM
Darren Gosbell
 
Posts: n/a
Default RE: Simple query

Named sets (eg. "WITH SET...') are indispenseable for complex queries, I
just want to point out that you can also define the top 10 set "inline",
which is what I would normally do for a simple query.


SELECT
{ [Measures].[Unit Sales]} ON COLUMNS,
{ TOPCOUNT({[Promotions].[Promotion Name].Members}, 10,
[Measures].[Unit Sales])} ON ROWS
FROM Sales


--
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 07:40 PM
mkazmierski@gmail.com
 
Posts: n/a
Default Re: Simple query

Hey!

Thx! It works perfectly . I also discover bottomCount but again have
a little problem with it. I want to get the last three names of
promotions which is non empty (when I try to use non empty clause I got
an error). Thx.

Regards, Mark

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 07:40 PM
Darren Gosbell
 
Posts: n/a
Default Re: Simple query

The "NON EMPTY" clause is only valid at the start of a axis definition
(like rows and columns). What you need to do is used the filter function
to filter out the members with empty results for the measure in
question.

e.g.

SELECT
{ [Measures].[Unit Sales]} ON COLUMNS,
{ BottomCOUNT(
FILTER({[Promotions].[Promotion Name].Members}
,Not IsEmpty(Measures.[Unit Sales]))
, 3, [Measures].[Unit Sales])} ON ROWS
FROM Sales

--
Regards
Darren Gosbell [MCSD]
Blog: http://www.geekswithblogs.net/darrengosbell

In article <1131133590.165452.127860@g43g2000cwa.googlegroups .com>,
mkazmierski@gmail.com says...
> Hey!
>
> Thx! It works perfectly . I also discover bottomCount but again have
> a little problem with it. I want to get the last three names of
> promotions which is non empty (when I try to use non empty clause I got
> an error). Thx.
>
> Regards, Mark
>
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:15 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com