I have the following tale that appears like this:
IMAGE
Its show the top 10 company, with the top 5 sub companies underneath in a table where I use the filter TOPN = 10 . My problem comes in when I have two company that exist in the top 10 with the same value, in this case $0.00 it shows more than 10. I understand that using the top = 10 in sql reporting services is suppose to function like this, but want to only show 10. My SP looks like this:
SELECT SicDescription, ISNULL(Company, 'OTHER') AS Company, AccountMV, AccountFeely,sicid,relationshipid as 'rnumber' from snapsraw
WHERE (Branchstate = @state) AND sicdescription is not null AND (monthend = @date)
Any help would be greatly appreciated, I heard of some people saying use the rownumber function, but not sure how to implement it if thats the only solution

Top 10 with ties
project2n5e0o1
Dead_Zone
The reason I dont want to group into one line is because each company might have a sub-company, and if i group on company, i will not be displaying the subcompanies anymore, its the subcompanies that make of the top 5 under the top 10
examp
company 1 $999
subcomp1 $333
subcomp2 $333
subcomp3 $333
........
sveroa
Mike Howes
Hammer
Would you mind outling how that query would look, this is what I have now:
SELECT
SicDescription, ISNULL(Company, 'OTHER') AS Company, AccountMV, AccountFeely,sicid,relationshipid as 'rnumber' from snapsrawWHERE
(Branchstate = @state) AND sicdescription is not null AND (monthend = @date)Munita Vohra
Steve from adzac
Duane
Why not just return the Top 10 in your Query
SELECT TOP 10 SicDescription, ISNULL(Company, 'OTHER') AS Company, AccountMV, AccountFeely,sicid,relationshipid as 'rnumber' from snapsraw
WHERE (Branchstate = @state) AND sicdescription is not null AND (monthend = @date)
Ham
VinceG
Furqanms
Duane,
In your table, right click select properties, select Filter tab, in the Filter List
Expression = your account value
Operator = Top N
Value = 10
I hope this is what you were looking for.
Ham
Waltari
Duane,
My approach would be to first select the 10 companies, after I have the 10 top companies, I would then select the top 5 sub-companies for my TOP 10 companies. I would group my report by the main companies and my detail would be the sub-companies.
Ham
johnstonb
You should do this in your query. Assuming you are using a SQL 2005 database, you can use the new DENSE_RANK windowing function to perform a rank with ties.
I'm not sure what your currency filed is.
Try this:
WITH myCTE AS
(
SELECT SicDescription
, ISNULL(Company, 'OTHER') AS Company
, AccountMV
, AccountFeely
, sicid
, relationshipid AS rnumber
, DENSE_RANK() OVER (ORDER BY AccountMV) AS rnk
FROM snapsraw
WHERE
Branchstate = @stateAND sicdescription IS NOT NULL
AND monthend = @date
)
SELECT * FROM myCTE
WHERE rnk <= 10
djbjmb
Just another quick note, this is what we have:
SELECT
SicDescription, ISNULL(Company, 'OTHER') AS Company, AccountMV, AccountFeely,sicid,relationshipid as 'rnumber' from snapsrawWHERE
(Branchstate = @state) AND sicdescription is not null AND (monthend = @date)sicdescription is the top level grouping (TOP10)
company is the 2nd level grouping (top5)
re infecta
Jordan Roher
Found your forum post whilst trying to solve the same problem, and I came up with this (quite dodgy) solution.
I changed the expression which I am trying to evaluate for my TopN from
=count(Fields!incident_ref.Value) to
=count(Fields!incident_ref.Value) + (rnd *0.00001)
As my data would always be a range of whole numbers, I have effectively ensured that I won't end up with two values the same.
so 20th may be 57.00038 and 21st may be 57.00047. Now I only get 20 rows on each data set.
Hope this makes sense and helps.
Pete