I have a table like below
SUBJECT Years MARKS
AB 1 20
AB 1 25
AC 1 20
AC 1 30
AC 1 40
AD 1 20
I only need count of duplicates (subject||Year), expected answer is 2 and not
AB1 -- 2
AC1 -- 3
That would be one more query on top of the duplicates query...
select subject, year, count(*)
from table1
group by subject, year
having count(*) > 1
will give you all the results with counts. Another count over this..
select count(*)
from (
select subject, year, count(*)
from table1
group by subject, year
having count(*) > 1
)
should give you the number of records which have one or more duplicates.
select subject,years, count(*)
from table
group by subject,years
having count (*) > 1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With