G
Guest
I want to pull the top 5 Values and then group all other values under an
"Other" category. Can this be done?
"Other" category. Can this be done?
Ofer Cohen said:If for example if I want to display the last 5 categories that were inserted
by date ith there amount, and then display the rest without the Top 5, Can be
done with three queries
1. To select the Top 5
Select Top 5 [category], Amount From TableName Order By [DateField] Desc
2. Group on all records, without the Top 5
SELECT "Other" AS Othercategory, Sum(TableName.Amount) AS SumAmount FROM
TableName
WHERE DateField Not In (Select Top 5 [DateField] From TableName Order By
[DateField] Desc)
GROUP BY "Other"
3. Union query To Join both queries
Select [category], Amount From Query1
Union
Select Othercategory, SumAmount From Query2
--
Good Luck
BS"D
Myra said:I want to pull the top 5 Values and then group all other values under an
"Other" category. Can this be done?