79726468

Date: 2025-08-05 17:45:17
Score: 0.5
Natty:
Report link

Here's the updated code...

-- One NULL and one NOT NULL
SELECT
  nullrow.ID,
  nullrow.Account,
  notnullrow.Contact
FROM
  MYtable nullrow
  JOIN MYtable notnullrow
    ON nullrow.ID = notnullrow.ID
WHERE
  nullrow.Contact IS NULL
  AND notnullrow.Contact IS NOT NULL

UNION ALL

-- Two NOT NULL: swap contacts
SELECT
  t1.ID,
  t1.Account,
  t2.Contact
FROM
  MYtable t1
  JOIN MYtable t2
    ON t1.ID = t2.ID
    AND t1.Account <> t2.Account
WHERE
  t1.Contact IS NOT NULL
  AND t2.Contact IS NOT NULL

ORDER BY
  ID,
  Account;
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: user31217914