how to retrive data from InvoiceNo
Something like this (untested) might be what you're after:

SELECT Month(IH.InvoiceDate) as Month, 
    COUNT(*) as Count,
    SUM(CASE WHEN IH.IsBackend = 0 THEN 1 ELSE 0 END) as DirectMobile,
    SUM(CASE WHEN IH.IsBackend = 1 AND PerformaInvoiceNo &lt;&gt; '' AND PerformaInvoiceNo &lt;&gt; '0' THEN 1 ELSE 0 END) as Preselling,
    SUM(CASE WHEN IH.IsBackend = 1 AND (ID.PerformaInvoiceNo = '' OR ID.PerformaInvoiceNo = '0') THEN 1 ELSE 0 END) as DirectWeb
FROM InvoiceDetail ID
INNER JOIN InvoiceHeader IH USING (InvoiceNo)
GROUP BY Month(IH.InvoiceDate);


This emulates the effect of the filter clause that is available in Postgres. See https://modern-sql.com/feature/filter It's optional in the SQL:2003 standard.