MSSQL Query Explination
===

I am working on code from a person who held my position 2+ years ago, and am having trouble deciphering a block of their SQL code.

    WHERE  ACCOUNT NOT IN (SELECT ACCOUNT
                       FROM   MWAPPTS A1
                       WHERE  A1.ACCOUNT = A.ACCOUNT
                              AND ADATE > dbo.Endofmonth(ACTIONDATE)
                              AND REASON IN ('CPE','NPPE')
                              AND USERFLAG IN ( 'U', 'B' ))

`dbo.Endofmonth` is a stored procedure which gets the last day of the month for the inputed date.

If I am reading that right, we are not including rows where the account would be returned by the select statement shown. I am having problems with the select statement though. Am I correct that it is getting `ACCOUNT` where `ADATE` is older than the end of the month. The reason IS "CPE" or "NPPE", and the `USERFLAG` is either "U", or "B"?

