Avatar of ppdocs

asked on 

Problems with SQL Statement- Group By, Order By, and Sort Order

I have a query that I need to execute to get the referrer of our clients. I want to group them by the referrer, but when I try to add a where clause to take out the blank referrals, it ignores the group by clause. If I add an order by clause to sort the referrals, it ignores the group by clause as well. Here is my SQL statement:

 SqlStr = "SELECT CaseGUID, ClientName, CaseNumber, Referrer  FROM PI_Active_Case_Referrals WHERE Referrer NOT IN (' ') Group By Referrer, ClientName, CaseNumber, CaseGUID ORDER BY Referrer"

The result is that I don't have any blank referrals and they are in order, but they are not grouped. Any help is appreciated.
Microsoft SQL Server 2005SQL

Avatar of undefined
Last Comment
Guy Hengel [angelIII / a3]

8/22/2022 - Mon