Monday, February 13, 2006

SQL Server CASE statement

SELECT DISTINCT
case when CQ.AccountNo is NULL then IMP.AccountNo
Else
CQ.AccountNo
end as AccountNo

, CQ.Staff_ID, CQ.DateOfEntry,IMP.BalanceDue, IMP.BrokerRef, IMP.Note FROM tblCancelationQueue AS CQ RIGHT JOINtblimportcan AS IMP ON CQ.AccountNo = IMP.AccountNoWHERE IMP.processed = 0ORDER BY CQ.dateofentry DESC

No comments: