How do I show GST slab-wise tax amount for different GST percentages using a SQL Server query.
I want to understand how to write a query for this problem in SQL Server. I want to fetch the monthly taxable amount and also tax amount for different GST percentages like the one in the table below:
SELECT DISTINCT(CAST(cgst AS DECIMAL(18, 2)) + CAST(sgst AS DECIMAL(18, 2))) AS 'GST',
SUM(CASE
WHEN (CAST(cgst AS DECIMAL(18, 2)) + CAST(sgst AS DECIMAL(18, 2))) = '5.00'
THEN CAST(paidamt AS DECIMAL(18, 2))
END)
FROM Sales
GROUP BY cgst, sgst, paidamt;
Now the above query is working but it shows repeated values of 5.00 percentage and shows no amount in 12.00 and 18.00 percentages as you can see in the table below:
Can you help me rectify my mistake or reform my query to get the desired output? Thanks in advance.