Query Help

  • I have a table with some column. It had two column called Due Date and Adj due Date.

    I would like to select some field with if Adj due Date is null then select Due date. I wrote this query and it gave me error message.

    SELECT     [Customer Change No], [PIA Material No], IIf(ISNULL([Adj Due Date]), [Due date], [Adj Due Date])  AS Expr1

    FROM         dbo.[tblPPAP Notification Detail]

     

  • SELECT     [Customer Change No], [PIA Material No], [Due date], [Adj Due Date])  AS Expr1

    FROM         dbo.[tblPPAP Notification Detail]

    where ([Adj Due Date]) is null

    Thanks,

    Ganesh

     

     

     

  • SELECT     [Customer Change No], [PIA Material No], 

    CASE WHEN [Adj Due Date] IS NULL THEN  [Due date] ELSE [Adj Due Date] END  AS Expr1

    FROM         dbo.[tblPPAP Notification Detail]

    hth


    * Noel

  •  

    SELECT     [Customer Change No], [PIA Material No], 

    isnull([Adj Due Date], [Due date]) AS Expr1

    FROM         dbo.[tblPPAP Notification Detail]

     

    Bert

  • You also could use the COALESCE function which returns the first non-null value of its arguments. In your case, COALESCE([Adj Due Date], [Due Date]) ... but this will take any number of arguments.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply