Lots to say, but I'll be spreading it out.
I'm going to try to force myself to write at least a little blurb daily, but we'll see just how long that lasts.
Anyway, today's odd bit of SQL -- I needed to get a list of all items in a table that had no corresponding child records via a self join. The resulting blurb looks odd, but does in fact work:
SELECT
Uniques.*, DATEDIFF(DAY, Uniques.StartDate, Uniques.EndDate)
FROM
#people Uniques LEFT OUTER JOIN #people Related
ON (Uniques.PersonNumber = Related.PersonNumber AND Related.PersonRecordNumber IS NOT NULL)
WHERE
Uniques.PersonRecordNumber IS NULL AND
Related.PersonRecordNumber IS NULL
Works fine, but looks funny. After some optimization, the seemingly conflicting clauses were removed, and placed in the requisite UPDATE statement, but I got a chuckle out of this. (Record names and tables changed to protect the innocent :) )