Let's say I have a table with these fields:
ID, LAST_NAME, FIRST_NAME, PROGRAM_CODE, PGM_YEAR
And there's at least one entry per person for each year they served. I'm trying to list people who have more than one PGM_YEAR row listed, and I need to list all of those fields in the resulting query.
So here's what I tried:
I also need to select PROGRAM_CODE but definitely don't want to group by that. Is there a way around that?
SELECT * FROM (
SELECT LAST_NAME, FIRST_NAME, Count(PGM_YEAR) AS YearsServed
GROUP BY LAST_NAME, FIRST_NAME, PGM_YEAR)
WHERE YearsServed > 1;