January 11, 2005 at 9:16 am
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]
January 11, 2005 at 10:16 am
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
January 11, 2005 at 3:19 pm
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
January 12, 2005 at 1:44 am
SELECT [Customer Change No], [PIA Material No],
isnull([Adj Due Date], [Due date]) AS Expr1
FROM dbo.[tblPPAP Notification Detail]
Bert
January 12, 2005 at 2:11 am
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