I have the following columns: CODCLI, CLIENT AND DTULTCOMP I need to know the customers who have not bought in the last 30 days. the DTULTCOMP column is in DATE format Table: PCLIENT
I have the following columns: CODCLI, CLIENT AND DTULTCOMP I need to know the customers who have not bought in the last 30 days. the DTULTCOMP column is in DATE format Table: PCLIENT
If accuracy is per month you can use Add_Mouth , passing a negative value, removing months from the date, eg:
select * from SuaTabela
where SuaColuna < add_months(sysdate, -1)
If the operation needs to be in days just subtract the comparison date, eg:
select * from SuaTabela
where SuaColuna < sysdate - 30
Select * from tabela
where DTULTCOMP is null
or DTULTCOMP < (SYSDATE - 30)
If you want to know only the ones who actually bought something, why not because there were customers who bought a long time ago, or just never bought it, remove the condition that tests zero.
Select * from tabela
where DTULTCOMP < (SYSDATE - 30)