select query

Hi all

I have very simple requirement... I have a table [TM_C_details] with accountno,custname,city,country,zone.
now i have to create new column 'Unique A/c' into another table [TM_NEW_TABLE] if the acountno is unique then Unique a/C should be 1 else 0.

Hope am clear... any suggestions are highly appreciated.
parpaaAsked:
Who is Participating?
 
batchakamalConnect With a Mentor Commented:
Here you go..

SELECT AccountNo, CASE COUNT(*) WHEN 1 THEN 1 ELSE 0 END AS [Unique A/c]
INTO TM_NEW_TABLE
FROM dbo.TM_C_details
GROUP BY AccountNo
0
 
Alpesh PatelAssistant ConsultantCommented:
To Insert in another table flag for unniqueness

Select 1 from TM_C_details where PrimaryKey <> current row Primary Key
If return 1 then put 1 in [TM_NEW_TABLE]
0
 
parpaaAuthor Commented:
thanks @Patel

Unfortunately NO PRIMARY KEYS HAVE BEEN DEFINED FOR THE TABLES..
0
 
parpaaAuthor Commented:
@Kamal thanks so much..
It worked
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.