KavJack
Programmer
- Apr 1, 2001
- 46
Is there a better way to do this ?
My SQL query
SELECT CUPALL2.YR, CUPALL2.RD, Count(CUPALL2.YR) AS [Count]
FROM CUPALL2
WHERE RP="r"
GROUP BY CUPALL2.YR, CUPALL2.RD
ORDER BY CUPALL2.YR, Iif(CUPALL2.RD="F","Z", CUPALL2.RD )
UNION SELECT CUPALL2.YR, "Z - ALL",Count(CUPALL2.YR) AS [Count]
FROM CUPALL2
WHERE RP="r"
GROUP BY CUPALL2.YR; works but I want to output the order so that the total appears at the bottom for each year. The output looks like this:
Year Round Count
1979 R1 12
1979 R2 8
1979 Z - All 20
1980 R1 11
1980 R2 13
1980 SF 9
1980 Z- All 33
but I have to use the contrivance "Z - ALL" to get my total to appear at the end of each year. Is there about a better way of doing this without having to use the "Z -" in front of the word ALL ?
My SQL query
SELECT CUPALL2.YR, CUPALL2.RD, Count(CUPALL2.YR) AS [Count]
FROM CUPALL2
WHERE RP="r"
GROUP BY CUPALL2.YR, CUPALL2.RD
ORDER BY CUPALL2.YR, Iif(CUPALL2.RD="F","Z", CUPALL2.RD )
UNION SELECT CUPALL2.YR, "Z - ALL",Count(CUPALL2.YR) AS [Count]
FROM CUPALL2
WHERE RP="r"
GROUP BY CUPALL2.YR; works but I want to output the order so that the total appears at the bottom for each year. The output looks like this:
Year Round Count
1979 R1 12
1979 R2 8
1979 Z - All 20
1980 R1 11
1980 R2 13
1980 SF 9
1980 Z- All 33
but I have to use the contrivance "Z - ALL" to get my total to appear at the end of each year. Is there about a better way of doing this without having to use the "Z -" in front of the word ALL ?