September 14, 2011 at 9:55 am
I am brain dead this morning...
I have a table that I want to list distict phone #'s. I can do that with with:
SELECT DISTINCT PHONENBR FROM TABLE1
But I want to have an identifier column before the phone # column. I just need the extra id column for identification purposes.
Is there a way to do this? My original table has an id column, but if I included that in my select statement, then I get every single record in the table, which then creates a ton of duplicate numbers.
I know this is simple, but for some reason I am unable to figure this simple task out today...
September 14, 2011 at 10:00 am
you can create identity column column
create table "table name"
(seqi_id int identity(1,1),
phone number bigint
)
Thanks
Bhavesh
September 14, 2011 at 10:00 am
ROW_NUMBER()
September 15, 2011 at 7:55 am
Michal-469362 (9/14/2011)
I am brain dead this morning...I have a table that I want to list distict phone #'s. I can do that with with:
SELECT DISTINCT PHONENBR FROM TABLE1
But I want to have an identifier column before the phone # column. I just need the extra id column for identification purposes.
Is there a way to do this? My original table has an id column, but if I included that in my select statement, then I get every single record in the table, which then creates a ton of duplicate numbers.
I know this is simple, but for some reason I am unable to figure this simple task out today...
Do you want an existing ID from the table or just a sequential number to go with the phone number? If you just want a sequential number then you do want to use ROW_NUMBER(). If you want an ID from the table (any ID) then you use the MIN or MAX function and GROUP BY phone number.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply