Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to eliminate rows with samecontents incolumn?

Author  Topic 

papochka2002
Starting Member

2 Posts

Posted - 2004-09-22 : 10:31:07
Here the "select" query which I use to create view.

select COMPANY, CompanyID, CITY, ADDR, ST, ZIP, FAX, fax_status_id
from allcompanies
where FAX like '416%' and (cat like '%FINANC%' or cat like '%BANK%')

In result I got view with list of the companies with same name but different address(branches of companies)
I need to have only one record for every company for example first record from the companies with same name.

How can I do this task?
Thanks a lot.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-09-22 : 10:50:26
do an inner join on on a subquery where you do max(CompanyId) as CompanyId, COMPANY and group by COMPANY

Go with the flow & have fun! Else fight the flow
Go to Top of Page

papochka2002
Starting Member

2 Posts

Posted - 2004-09-22 : 12:19:46
Thanks.
It works.
Go to Top of Page
   

- Advertisement -