SELECT customermaster_0.CustomerNumber, customermaster_0.CustomerName, Sum(invoicehistoryline_0.LineExtension) AS 'Sales'
FROM VOL01.customermaster customermaster_0 LEFT OUTER JOIN VOL01.invoicehistoryline invoicehistoryline_0 ON customermaster_0.CustomerNumber = invoicehistoryline_0.CustomerNumber}
WHERE (customermaster_0.SalesYearToDate>0) AND (customermaster_0.StoreNumber='03') AND (invoicehistoryline_0.InvoicePostDate>={d '2014-07-01'} And invoicehistoryline_0.InvoicePostDate<={d '2015-03-31'})
GROUP BY customermaster_0.CustomerNumber
ORDER BY customermaster_0.CustomerNumber
I have the query listed above. I would like to use an if statement so that if Sum(invoicehistoryline_0.LineExtension) AS 'Sales' is null, it will return a 0.
I have tried:
ISNULL(Sum(invoicehistoryline_0.LineExtension),0) AS 'Sales'
NZ(Sum(invoicehistoryline_0.LineExtension),0) AS 'Sales'
and neither work.
Any help would be greatly appreciated.
Thanks
FROM VOL01.customermaster customermaster_0 LEFT OUTER JOIN VOL01.invoicehistoryline invoicehistoryline_0 ON customermaster_0.CustomerNumber = invoicehistoryline_0.CustomerNumber}
WHERE (customermaster_0.SalesYearToDate>0) AND (customermaster_0.StoreNumber='03') AND (invoicehistoryline_0.InvoicePostDate>={d '2014-07-01'} And invoicehistoryline_0.InvoicePostDate<={d '2015-03-31'})
GROUP BY customermaster_0.CustomerNumber
ORDER BY customermaster_0.CustomerNumber
I have the query listed above. I would like to use an if statement so that if Sum(invoicehistoryline_0.LineExtension) AS 'Sales' is null, it will return a 0.
I have tried:
ISNULL(Sum(invoicehistoryline_0.LineExtension),0) AS 'Sales'
NZ(Sum(invoicehistoryline_0.LineExtension),0) AS 'Sales'
and neither work.
Any help would be greatly appreciated.
Thanks