Guest User

Untitled

a guest
Apr 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. SELECT *
  2. FROM Account
  3. WHERE AccountNumber IN (
  4. SELECT DISTINCT AccountNumber
  5. FROM(
  6. SELECT AccountNumber, CASE WHEN InvoiceDate < DATEADD(dd, -20, GETDATE()) THEN 1 ELSE 0 END InvFlag
  7. FROM Account) a
  8. WHERE a.InvFlag = 1)
Add Comment
Please, Sign In to add comment