sql >> Database teknologi >  >> RDS >> Sqlserver

Betinget WHERE-klausul i SQL Server

Prøv dette

SELECT 
    DateAppr,
    TimeAppr,
    TAT,
    LaserLTR,
    Permit,
    LtrPrinter,
    JobName,
    JobNumber,
    JobDesc,
    ActQty,
    (ActQty-LtrPrinted) AS L,
    (ActQty-QtyInserted) AS M,
    ((ActQty-LtrPrinted)-(ActQty-QtyInserted)) AS N
FROM 
    [test].[dbo].[MM]
WHERE 
    DateDropped = 0
    AND (
    (ISNULL(@JobsOnHold, 0) = 1 AND DateAppr >= 0) 
    OR 
    (ISNULL(@JobsOnHold, 0) != 1 AND DateAppr != 0)
    )

Du kan læse mere om betinget WHERE her.



  1. PDO få det sidste ID indsat

  2. Hvordan kopierer eller importerer jeg Oracle-skemaer mellem to forskellige databaser på forskellige servere?

  3. TSQL-e-mail-validering (uden regex)

  4. MYSQL OR vs IN ydeevne