Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi.i have a view with several columns, that is finebut now i ihave to use DATEDIF in a Date Column thas has NULL valueusing CASE in QueryAnalize works fine, but View doesnt allow to use CASE.Are there other options? tksClagesFrom Rio de JaneiroSELECT * , CASE WHEN DUP_DTPGTO IS NULL THEN DATEDIFF (DAY, GETDATE(),DUP_VENCTO ) END as Atraso, DATEDIFF (DAY, DUP_DTPGTO, DUP_VENCTO) as AtrasoPgto from ViewDuplicat
MichaelP
Jedi Yak
2489 Posts
Posted - 2004-05-11 : 13:08:10
Try this:
SELECT * , COALESCE(DUP_DTPGTO, DATEDIFF (DAY, GETDATE(),DUP_VENCTO) AS Atraso,DATEDIFF (DAY, DUP_DTPGTO, DUP_VENCTO) as AtrasoPgto from ViewDuplicat
COALESCE returns the first non-null item in that select list.Michael<Yoda>Use the Search page you must. Find the answer you will.</Yoda>