473,387 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Ranking in Crosstab Query

Hi,

I have a crosstab query which is based on a simple select query. Here is how the query works..

The base query gets it date from employee table and their incentives table for the given quarter. This query feeds to the Crosstab query for displaying the quarterly data. I have a field in the crosstab query which calculates the sum of all three months in the quarter.

I want to give ranks to this quarterly total in the crosstab query. I tried using the rank function posted by someone on this forum with the subquery. But subquery doesnt seem to be working in the crosstab query.

Can anybody help.. its urget...

Thanks

Keyur
Jan 7 '08 #1
6 3098
MMcCarthy
14,534 Expert Mod 8TB
Hi Keyur

Please post the SQL of your crosstab query.

Also explain how you want the data ranked.

Mary
Jan 8 '08 #2
Hi Mary,

For the confidentiality reasons I can not give you the exact sql of my crosstab. However below given is the same syntax I am using except the query and column names.

TRANSFORM Sum(Query1.Coiumn1) AS QuarterlyTotal
SELECT Query.Column2, Query1.Column3, Query1.Column4, Query1.Column5, Query1.Column6, Sum(Query1.Column1) AS NetIncentives
FROM Query1
GROUP BY Query1.Column2, Query1.Column3, Query1.Column4, Query1.Column5
PIVOT Query1.Column6;

I have a query that fetches data of the incentives earned by each employee from the table in the vertical format for a given quarter, say it Query1.

I am then using Query1 to make a crosstab query, say Query2, in which I am showing incentives earned by each employee in monthly basis (i.e. horizontal format) and I am showing the total for the quarter in the last column. I want to give ranks to employees on this Quarterly total.

Looking forward for your quick reply..

Thanks

Keyur
Jan 9 '08 #3
MMcCarthy
14,534 Expert Mod 8TB
Keyur

What kind of Ranks? Just 1, 2, 3, 4 ....

Or do you want to rank them in ranges like

High (>10,000)
Medium Between (1,000 and 9,999)
Low (< 1,000)

What kind of ranking are we talking about?
Jan 9 '08 #4
Keyur

What kind of Ranks? Just 1, 2, 3, 4 ....

Or do you want to rank them in ranges like

High (>10,000)
Medium Between (1,000 and 9,999)
Low (< 1,000)

What kind of ranking are we talking about?
Hi,

Ya just simple ranks like 1,2,3,4 ....

I want to show the top incentives earners in the particular quarter

thanks

Keyur
Jan 10 '08 #5
MMcCarthy
14,534 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Sum(Query1.Coiumn1) AS QuarterlyTotal
  2. SELECT Query.Column2, Query1.Column3, Query1.Column4, Query1.Column5, Query1.Column6, Sum(Query1.Column1) AS NetIncentives
  3. FROM Query1
  4. GROUP BY Query1.Column2, Query1.Column3, Query1.Column4, Query1.Column5
  5. ORDER BY Sum(Query1.Column1) DESC
  6. PIVOT Query1.Column6;
  7.  
Will the Order by give you what you want ?
Jan 11 '08 #6
Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Sum(Query1.Coiumn1) AS QuarterlyTotal
  2. SELECT Query.Column2, Query1.Column3, Query1.Column4, Query1.Column5, Query1.Column6, Sum(Query1.Column1) AS NetIncentives
  3. FROM Query1
  4. GROUP BY Query1.Column2, Query1.Column3, Query1.Column4, Query1.Column5
  5. ORDER BY Sum(Query1.Column1) DESC
  6. PIVOT Query1.Column6;
  7.  
Will the Order by give you what you want ?
Hi,

Sorry for the late reply as was on leave for 4 days.

I tried your suggestion, it gives following error.


"Cannot have aggregare function in ORDER BY clause (sum(Query1.Column1))"

Regards

Keyur
Jan 15 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
2
by: Sherman H. | last post by:
I have a few questions for crosstab and popup form questions: 1. I created a crosstab as follows: IT Financial Operation John 21 22 ...
4
by: Judy | last post by:
I'm using Access 2003 and was wondering if it is possible to have a paramater selection within a crosstab query so that I wouldn't need to build a new table. I have a select query that I'm using...
7
by: newguy | last post by:
I am trying to get the totals of a table by client by type of income. This query will get what I am looking for with each unique combination as a row: SELECT Sales.Client, BillCode.Type,...
8
by: Penny | last post by:
(Access 2003 Multiuser Split DB, Windows XP Pro) Hi All, I would really appreciate just some basic tips on how to make a Crosstab Form based on a Crosstab Query. The query always has the same...
14
by: Tina | last post by:
My employer tracks productivity/performance of clinicians (how much they bill) each week, its averages for the month, and the 6 months. These averages are compared to their expected productivity....
27
by: Bob | last post by:
running access 2k; mdb w/ linked tables to another mdb (front/back-end); trying to run a query that updates a table FROM information from a crosstab query. I AM NOTT trying to update the...
6
by: sara | last post by:
I hope someone can help with this. Our director wants to have a report that will have the departments (Retail stores) across the top, stores down the side and the RANKING of the YTD dept sales...
4
by: m.wanstall | last post by:
I have a crosstab query that compiles data for Months of the year. I have a stacked select query on top of that crosstab query that uses the latest 2 months data and exports it to a fixed length...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.