Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

SQL Server 2012 - Instrução Case na cláusula where


Tente este -
SELECT foo,
       bar,
       test
FROM [table]
WHERE bar = 1
    AND (
            (
                foo = 0 
                AND 
                DATEDIFF(dd, GETDATE(), 2 ) < test
            )
        OR  
            DATEDIFF(hh, GETDATE(), 2 ) < test
        )