Версия с группировкой по всем столбцам в SELECT:
Select SaleInvoices.InvoiceID
,SaleInvoices.CustomerID
,Customers.ContactName
,Customers.CNIC
,Customers.City
,Customers.CellNumber
,Customers.CompanyName
,Count(*)
From SaleInvoices
INNER JOIN Customers
ON SaleInvoices.CustomerID=Customers.CustomerId
Where SaleInvoices.UpdatedDate >= '2017-01-02 16:53:53.253'
AND SaleInvoices.UpdatedDate<= '2019-01-02 16:53:53.253'
GROUP BY SaleInvoices.InvoiceID
,SaleInvoices.CustomerID
,Customers.ContactName
,Customers.CNIC
,Customers.City
,Customers.CellNumber
,Customers.CompanyName
Версия с удалением столбцов из выбора, без изменения группы на:
Select Customers.ContactName
,Count(*)
From SaleInvoices
INNER JOIN Customers
ON SaleInvoices.CustomerID=Customers.CustomerId
Where SaleInvoices.UpdatedDate >= '2017-01-02 16:53:53.253'
AND SaleInvoices.UpdatedDate<= '2019-01-02 16:53:53.253'
GROUP BY Customers.ContactName
Другим способом будетиспользовать агрегатные функции, такие как MIN (), MAX (), ... во всех столбцах выбора:
Select MIN(SaleInvoices.InvoiceID)
,MIN(SaleInvoices.CustomerID)
,Customers.ContactName
,MIN(Customers.CNIC)
,MIN(Customers.City)
,MIN(Customers.CellNumber)
,MIN(Customers.CompanyName)
,Count(*)
From SaleInvoices
INNER JOIN Customers
ON SaleInvoices.CustomerID=Customers.CustomerId
Where SaleInvoices.UpdatedDate >= '2017-01-02 16:53:53.253'
AND SaleInvoices.UpdatedDate<= '2019-01-02 16:53:53.253'
GROUP BY Customers.ContactName