1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Return Condition from case expression in where clause (Error - Incorrect syntax near...

Discussão em 'Outras Linguagens' iniciado por Stack, Novembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    In SQL it is giving me error

    Incorrect syntax near '<'.

    SELECT *
    FROM TableName
    WHERE CStatus = 'Active'
    AND ServiceStatus = 'Active'
    AND DATEDIFF(day, OnDate, OffDate) > 0
    AND CASE WHEN EOMONTH(CA.OnDate) = 31 THEN DATEDIFF(day, OnDate, OffDate) <= 31 ELSE DATEDIFF(day, OnDate, OffDate) <= 30 END


    I am trying to put CASE expression in my Where clause, but I am getting an error:


    Incorrect syntax near '>'.

    I want compare if OnDate month have 31 days then 31 days otherwise 30 days.

    Continue reading...

Compartilhe esta Página