Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select distinct (sql server 2000) afraid i dont know how to use 1

Status
Not open for further replies.

pssheba

Programmer
Oct 22, 2004
87
IL
Hi !
My table contains phone numbers.
I want to show all the phone numbers but each number once only:
Code:
select distinct phone
from
my phones
but i get all the phones including few of each number.
How do i write that distict to show me each number once only ?
Phone number is not a primary key.
Thanks !
 
This should give you the distinct phones, but how do you store the phones in that table? Is there a difference between them:
This phone 99 999 999 is different than 9 999 999 99 or 999999999

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Hi bborissov !
The phone column is varchar 255 and the "distinct" is not working ! I get the same phone number on 2 3 and more rows.
This table comes from a text file !
I import a text file originally from Excel.
Can i define the phone field prior to the import action ?
Thank you very much !
 
DISTINCT must work. But maybe you have some other chars in that field. Can you run this just for test:
Code:
SELECT DISTINCT REPLACE(phone,' ','') AS Phone
FROM [My Phones]
ORDER BY Phone

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
It worked this time !
Thank you so much bborissov !
are you a professional life guard ?:-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top