I have this query
SELECT semester, COUNT(id) AS total, RIGHT(RTRIM(semester), 4) AS year
FROM TextbookReservation
WHERE (semester IS NOT NULL)
AND (semester <> '')
AND (semester <> 'SM2008')
AND semester <> 'SU2008')
GROUP BY semester ORDER BY year, semester DESC
Which produces something like this:
semester total year
SP2006 2277 2006
FA2006 4367 2006
SP2007 2893 2007
FA2007 5624 2007
SP2008 4083 2008
FA2008 6451 2008
I would like to return something like this:
year totalSpring totalFall
2006 2277 4367
2007 2893 5624
2008 4083 6451
Any ideas on how I can approach this query? Thanks!
Without PIVOT tables, since you didn’t specify the version: