PSIUnit
asked on
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
What's wrong with this code? I'm getting the above error message. I'm trying to delete all records that are duplicates except for the one with the largest date.
DELETE FROM NIPRLicenseInfo
WHERE (NPN IN
(SELECT NPN, State, LicenseID
FROM NIPRLicenseInfo
GROUP BY NPN, State, LicenseID
HAVING (COUNT(NPN) > 1))
AND NOT [ExpirationDate] IN (
SELECT MAX([ExpirationDate]) as MaxOfExpire
FROM NIPRLicenseInfo
GROUP BY NPN, State, LicenseID
HAVING ((COUNT(NPN))>1)))
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What's wrong is:
WHERE (NPN IN
(SELECT NPN, State, LicenseID
FROM NIPRLicenseInfo
A SELECT Statment inside the IN must only return 1 field.
You need:
WHERE (NPN IN
(SELECT NPN
FROM...)
WHERE (NPN IN
(SELECT NPN, State, LicenseID
FROM NIPRLicenseInfo
A SELECT Statment inside the IN must only return 1 field.
You need:
WHERE (NPN IN
(SELECT NPN
FROM...)
ASKER
Ok - that makes sense. Thanks!
ASKER