I have a SQL Query giving me a list of double records in my database.
select periodid, itemid from periodscore
group by periodid, itemid
having count(*) > 1
This works as expected, but now I would like to retrieve additional fields of these records (such as date last updated etc). So I tried:
select * from periodscore where periodscoreid in
(select periodscoreid from periodscore
group by periodid, itemid
having count(*) > 1)
Of course this doesn't work and gives me the error:
Column 'periodscore.PeriodScoreID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
How can I retrieve the extra fields in this query?