0
Fala galera...
I need to list only the EXPIRED contracts, because when the company renews the contract, the data of the expired (old) contract remain in the BD with status "0". So we have: 1 contract expired (old) and 1 in force (new, which was renewed).
And this query is showing me the company that has expired contract registration, but that already has contract in force (renewed) and this is not right, because if she has already renewed the contract, then there is no expired contract on the current date and then it should not appear in the list.
What I need is a list of companies that do not have contract current and loser.
I tried that query, but it didn’t work:
SELECT *
FROM contrato_empresa ce, empresas e
WHERE
e.emp_id = ce.cte_id_emp AND
ce.cte_status = 0 AND
ce.cte_dt_ini < CURDATE() AND
ce.cte_dt_fim < CURDATE()
ORDER BY e.emp_cidade ASC, e.emp_fantasia ASC
Someone can help me?
Thank you!
If you want to filter out companies that don’t have existing and expired contracts, you want companies that don’t have contracts?
– Diego_F
@Diego_f, I need the list only with EXPIRED contract, because when the company renews the contract, the data of the expired (old) contract remain in the BD with status "0". So we have: 1 expired contract (old) and 1 in force (new, which has been renewed). And this query is showing me the company that has expired contract registration, but that already has contract in force (renewed) and this is not right, because if she has already renewed the contract, then there is no expired contract on the current date and then it should not appear on the list, He drew?! :)
– Myller Meireles