1
I have the following columns: CODCLI, CLIENT AND DTULTCOMP I need to know which customers you haven’t bought in the last 30 days. the DTULTCOMP column is in DATE format Table: PCLIENT
1
I have the following columns: CODCLI, CLIENT AND DTULTCOMP I need to know which customers you haven’t bought in the last 30 days. the DTULTCOMP column is in DATE format Table: PCLIENT
1
If the accuracy is per month you can use the function Add_mouth, passing a negative value by removing months from the date, ex:
select * from SuaTabela
where SuaColuna < add_months(sysdate, -1)
If the operation needs to be in days just make a subtraction on the date of comparison, ex:
select * from SuaTabela
where SuaColuna < sysdate - 30
0
Select * from tabela
where DTULTCOMP is null
or DTULTCOMP < (SYSDATE - 30)
If you want to know only those who actually bought something, because there are customers who bought it a long time ago, or simply never bought it, remove the condition that tests null.
Select * from tabela
where DTULTCOMP < (SYSDATE - 30)
IT WORKED, THANKS.
Browser other questions tagged sql oracle select
You are not signed in. Login or sign up in order to post.
These columns are in which table(s))?
– Giuliana Bezerra
Which database are you using? Mysql, Oracle, MSSQL? Have you tried something? I assume you are, and your problem is in condition
WHERE
, that you need to be theDTULTCOMP < (AGORA - 30 dias)
, that’s it?– Leite
Oracle database.
– Diego Moreira
That’s right, it worked out thanks
– Diego Moreira