Answer the question
In order to leave comments, you need to log in
What is wrong with the NOT IN expression?
What is wrong with the NOT IN expression?
Select
ACCOUNT_ID,
PAYMENT_DATE,
coalesce(DATEFORMAT(pay.PAYMENT_DATE,'mm.yyyy'),'nl'),
---DATEADD( MONTH, -1, DATEFORMAT(pay.PAYMENT_DATE,'mm.yyyy') )
DATEADD( MONTH, -1, pay.PAYMENT_DATE ),
----DATEFORMAT((DATEADD( MONTH, -1, pay.PAYMENT_DATE )), 'mm.yyyy') )
DATEFORMAT(DATEADD( MONTH, -1, pay.PAYMENT_DATE ),'mm.yyyy') df
---DATEADD( MONTH, -1, (pay.PAYMENT_DATE),'mm.yyyy'),
---CAST ( DATEADD( MONTH, -1, (pay.PAYMENT_DATE) ),'mm.yyyy') AS VARCHAR(9)] )
---CONVERT ( CHAR( 20 ), pay.PAYMENT_DATE, 365)
FROM
(select pay.ACCOUNT_ID, MAX(pay.PAYMENT_DATE)PAYMENT_DATE
from spss.PAYMENTS pay, ----KOLLECTO.PAYMENTS
spss.PAYMENTS_DOC pd
where pay.PAYMENT_DOC_ID=pd.PAYMENT_DOC_ID
and pd.PAYMENT_DOC_TYPE='NORMAL'
and pay.fnc_amount>=500
GROUP BY pay.ACCOUNT_ID) pay
WHERE
---coalesce(DATEFORMAT(pay.PAYMENT_DATE,'mm.yyyy'),'nl') not in ( DATEFORMAT(GETDATE(),'mm.yyyy'), DATEFORMAT(DATEADD( MONTH, -1, (pay.PAYMENT_DATE) ),'mm.yyyy') )
coalesce(DATEFORMAT(pay.PAYMENT_DATE,'mm.yyyy'),'nl') not in ( DATEFORMAT(GETDATE(),'mm.yyyy'), DATEFORMAT(DATEADD( MONTH, -1, (pay.PAYMENT_DATE) ),'mm.yyyy') )
Answer the question
In order to leave comments, you need to log in
In NOT IN
you can use either constants or a subquery. And you are using a value from a table.
For two values and <>
enough.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question