Finding duplicate values in a sql table
Hey fam, I need your help, i'm a bit stuck on a certain task which needs me to Write a query that gives me all drivers that are linked to more than one vehicle (Give the driver id, name, surname, the number of vehicles that the driver is linked to) my current query: SELECT TOP 100 DT.DRIVERID , DPN.FIRSTNAME , DPN.LASTNAME , SS.SERIALPRIMARY VEHICLEREG , SS.SPECDSC AS VEHICLEDESCRIPTION FROM EXDDRIVERTABLE DT INNER JOIN DIRPERSON DP ON DP.RECID = DT.PARTY INNER JOIN DIRPERSONNAME DPN ON DPN.PERSON = DP.RECID INNER JOIN EXDLINKDRIVERSTRUCT LNK ON LNK.DRIVERPARTYRECID = DT.PARTY AND ((LNK.TODATETIME >= GETDATE() OR LNK.TODATETIME = '1900-01-01 00:00:00.000') AND LNK.FROMDATETIME < GETDATE()) INNER JOIN BBLSPECSTRUCT SS ON SS.RECID = LNK.STRUCTRECID WHERE SS.DATAAREAID = 'ALL' BBLSPECSTRUCT SS ON SS.RECID = LNK.STRUCTRECID WHERE SS.DATAAREAID = 'ALL'