I have written one query to group the tax items, if tax is null, i dont want to display the tax name. How to do this? Please check my sql server statement:
SELECT
'CENTRAL EXCISE DUTY' AS 'TaxName',
SUM(TaxAmount) AS 'Tax'
FROM
PMT_InvoiceTaxAttribute
WHERE
InvoiceID = 100
AND TaxAttributeName NOT LIKE '%IBR%'
AND TaxAttributeName NOT LIKE '%CST%'
AND TaxAttributeName NOT LIKE '%VAT%'
UNION
SELECT
'CST' AS 'TaxName',
SUM(TaxAmount) AS 'Tax'
FROM
PMT_InvoiceTaxAttribute
WHERE
InvoiceID = 100
AND TaxAttributeName LIKE '%CST%'
UNION
SELECT
'VAT' AS 'TaxName',
SUM(TaxAmount) AS 'Tax'
FROM
PMT_InvoiceTaxAttribute
WHERE
InvoiceID = 100
AND TaxAttributeName LIKE '%VAT%'
This Query gives the Output as follows:
TaxName Tax
------------- -----------
CENTRAL EXCISE DUTY 15000
CST NULL
VAT NULL
Here, I don't want to display the CST and VAT since it has null value.