Select to know customers without service in the last 30 days plsql

1

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

    
asked by anonymous 28.06.2018 / 16:52

2 answers

1

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
    
28.06.2018 / 17:31
0
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)
    
28.06.2018 / 18:29