Different conditions of the same column

2

I have a table named anuncios :

id | nome   | finalizar | datafim
1  | teste1 | N         | 0000-00-00
2  | teste2 | S         | 2018-12-05

I would like to make a SELECT listing only the records where the value of the finalizar column is N or that is S , since when S , datafim is less than or equal to today.

    
asked by anonymous 02.12.2018 / 01:46

1 answer

0

You can use the following statement:

SELECT * 
  FROM anuncios
 WHERE (finalizar = 'N' OR (finalizar = 'S' AND datafim <= GETDATE()))
    
02.12.2018 / 02:24