Return rows with the greatest row count - MS-SQL
insert into CallData ([800num], CompanyName) values ('8009874321',
'cars'); insert into CallData ([800num], CompanyName) values
('8009874321', 'Newsales'); insert into CallData ([800num], CompanyName)
values ('8009874321', 'Newsales'); insert into CallData ([800num],
CompanyName) values ('8009870000', 'BenaSales'); insert into CallData
([800num], CompanyName) values ('8009870000', 'BenaSales'); insert into
CallData ([800num], CompanyName) values ('8009870000', 'BenaSales2');
insert into CallData ([800num], CompanyName) values ('8009870000',
'BenaSales2');
Running SQLServer 2008 Requirement 1: When the 800num matches I would like
to return a single row, the row with the greatest row count. Requirement
2: If the 800num row count matches then return both rows.
Results would be: 8009874321 Newsales 8009870000 BenaSales 8009870000
BenaSales2
Any help would be great.
No comments:
Post a Comment