select Month(IH.InvoiceDate) as Month,
COUNT(ID.InvoiceNo) as Count,
COUNT(ID.InvoiceNo) as DirectMobile,
COUNT(ID.InvoiceNo) as Preselling,
COUNT(ID.PerformaInvoiceNo) as DirectWeb
from InvoiceDetail ID
INNER JOIN InvoiceHeader IH ON ID.InvoiceNo = IH.InvoiceNo
WHERE IH.IsBackend = 1
GROUP BY Month(IH.InvoiceDate)
I want to ask how to retrieve data from InvoiceNo into two columns and how to give the where clause to complete these conditions.
Count is full count of every type of invoices and i want to get the count of DirectMobile , DirectWeb and Preselling . For get the count of those 3 these are the coditions.
DirectMobile - IsBackend=0
DirectWeb - IsBackend=1 and PerformaInvoiceNo= '' or 0
Preselling - IsBackend = 1 and PerformaInvoiceNo = a varchar value.