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
 Other Forums
 Other Topics
 SQL - Numbering Problem

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-07-06 : 07:44:36
Doran writes "Greetings.

My problem, in its simplest form:

A result set:

FLD1
----
A
A
B
D
D
D

Would like to add a field (FLD2) with a 1 on first occurence, or 0 on all others:

FLD1 FLD2
---- ----
A 1
A 0
B 1
D 1
D 0
D 0


Actually, I dont care if its the first or last occurence.


Thanks for any help!

Doran"

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-07-06 : 08:51:41
Without a primary key on your table, you can't really do much of anything useful with your data in SQL Server. And, in fact, even if you can I don't recommend that you try until you go back and set up your database properly.

It's like writing a 10 page document in Word but not using an punctation at all, and then wondering how you can get Word to format the output properly.

- Jeff
Go to Top of Page
   

- Advertisement -