I have two columns
and the following data:
I have to count the Number of products
I am using
Count (coalesce(Productactual,product)) but its not working any changes in query or new idea to count products in two columns.
If you want to count entries per product, you need to use your COALESCE expression as a grouping item:
SELECT COALESCE(productactual, product) AS product, COUNT(*) AS productcount FROM atable GROUP BY COALESCE(productactual, product) ;