Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Case Statement displaying all NULLS

$
0
0

Hi, 

I have the used the following code of which isn't working as I would have expected and that is due to my new column derived from the CASE statement shows all values as a NULL. 

Is there something missing from my case statement that would ultimately make this work please?

select 
distinct(dbo.pk.job_number) as job_number, 
dbo.PK.Client_Code,
dbo.pk.client_name, 
DBO.DDI.INVOICE_DATE,

CASE 
WHEN 
'2018-01' >= FORMAT(DBO.DDI.INVOICE_DATE, 'yyyy-MM') 
AND '2018-01' < Format (DBO.DDI.INVOICE_DATE, 'yyyy-MM')
THEN   dbo.DDI.due_amount
END As Jan18


from 
dbo.pk 
left join dbo.ddi
on dbo.pk.job_number = dbo.ddi.job


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>