UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Select top 10 highest based on a crosstab query    
 
   
ketan_lad
post Jun 5 2008, 04:15 AM
Post #1

UtterAccess Addict
Posts: 194
From: Midlands, UK



Hi,

Does anyone have any ideas on how I can select the top 10 highest entries in a crosstab query? I know that the sql command is 'top ....' but I cant seem to get this working in a crosstab query. Below is the sql from the query as it stands:

TRANSFORM Count([Change Register].CR_ID) AS CountOfCR_ID
SELECT [Change Register].PCRNo, [Change Register].[Financial Value], BPM.[BPM Name]
FROM BPM INNER JOIN [Change Register] ON BPM.[BPM ID] = [Change Register].BPM_Name
WHERE ((([Change Register].PCRNo) Not Like "blank") AND (([Change Register].[Financial Value]) Not Like "blank"))
GROUP BY [Change Register].PCRNo, [Change Register].[Financial Value], BPM.[BPM Name]
PIVOT [Change Register].Requestor;

Any help would be appreciated.
Go to the top of the page
 
+
Larry Larsen
post Jun 5 2008, 04:27 AM
Post #2

UA Editor + Utterly Certified
Posts: 22,722
From: Melton Mowbray,Leicestershire (U.K)



Hi
Your only option may be to base your xtab on a query that's already done the filtering of the top 10..
(IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif)
Go to the top of the page
 
+
AQM_UK
post Jun 5 2008, 04:31 AM
Post #3

UtterAccess VIP
Posts: 4,447
From: Suffolk, England



I would take the cross tab.

Add this into a query and sort descending on the field you want and then select the top 10 in the properties.

I think trying to do this all in one might be asking a but too much.

Jim
Go to the top of the page
 
+
ketan_lad
post Jun 5 2008, 04:38 AM
Post #4

UtterAccess Addict
Posts: 194
From: Midlands, UK



Hi,

Thanks will give it a go. I take it that there is no way to do this via a crosstab query then?

Thanks
Go to the top of the page
 
+
Larry Larsen
post Jun 5 2008, 04:39 AM
Post #5

UA Editor + Utterly Certified
Posts: 22,722
From: Melton Mowbray,Leicestershire (U.K)



Hi
Dynamically maybe..!!!
(IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif)
Go to the top of the page
 
+
ketan_lad
post Jun 5 2008, 04:45 AM
Post #6

UtterAccess Addict
Posts: 194
From: Midlands, UK



thanks both, help much appreciated....
Go to the top of the page
 
+
ketan_lad
post Jun 5 2008, 05:07 AM
Post #7

UtterAccess Addict
Posts: 194
From: Midlands, UK



Hi,

Managed to get it working via a select query:

SELECT TOP 10 [Change Register].PCRNo, [Change Register].[Financial Value], BPM.[BPM Name], [Change Register].Requestor, Count([Change Register].CR_ID) AS CountOfCR_ID
FROM BPM INNER JOIN [Change Register] ON BPM.[BPM ID] = [Change Register].BPM_Name
WHERE ((([Change Register].PCRNo) Not Like "blank") AND (([Change Register].[Financial Value]) Not Like "blank"))
GROUP BY [Change Register].PCRNo, [Change Register].[Financial Value], BPM.[BPM Name], [Change Register].Requestor
ORDER BY [Change Register].[Financial Value] DESC;

Thanks for your help.
Go to the top of the page
 
+
AQM_UK
post Jun 5 2008, 05:22 AM
Post #8

UtterAccess VIP
Posts: 4,447
From: Suffolk, England



Yes, that is the way I was shown and do.

Glad you got it to work okay.

Jim
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 21st May 2013 - 09:35 PM