Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT *
- FROM Account
- WHERE AccountNumber IN (
- SELECT DISTINCT AccountNumber
- FROM(
- SELECT AccountNumber, CASE WHEN InvoiceDate < DATEADD(dd, -20, GETDATE()) THEN 1 ELSE 0 END InvFlag
- FROM Account) a
- WHERE a.InvFlag = 1)
Add Comment
Please, Sign In to add comment