How do I only list 1 row in a result set made up of this:SELECT companyname, parentgroup from companies group by companyname, parentgroup order by companyname
BARRATT EASTERN COUNTIES ZBAR0250BARRATT EASTERN COUNTIES LIMITED ZBAR0250
Instead of 2 rows, I want it to list the top name and group it by its parent code.BARRATT EASTERN COUNTIES ZBAR0250
There is a data nomaly causing this with name changes so I have to deal with it as is as I am unable to correct the source.declare @topnum int,@month intset @topnum = 500set @month = 0SET ROWCOUNT @topnumSELECT C.ParentGroup, sum([amtin loccur]) AS TurnoverFROM zarinvregLEFT JOIN Companies C ON zarinvreg.Customer = C.AccountCodeWHERE monthdata >= @month-11 --this gives us 12 monthsAND C.CompanyName <> '-'AND C.CompanyName is not nullGROUP BY C.ParentGroupORDER BY Turnover descSET ROWCOUNT 0