sql - Marking duplicate values in new column -


Therefore there is some help on a query which will mark the duplicate in a specific column.

Essentially I have 2 columns:

  cust_id Order_id 001 001 001 002 001 003 002 001 003 001 003 002  

I have a new column in my queue which is unique for '1' and '0' for duplicates of only 'cust_id' columns. My thoughts are minutes or & lt;

So far it is with whom I have come, which is clearly not correct:

  SELECT A.cust_id, B.order_id, when COUNT (A. Cust_id) & gt; 1 THEN 0 WHEN COUNT (A.cust_id) = '1 THEN 1 END as' Inquiry' with a check in the chest B.cust_id = A.cust_id GROUP BY B.order_id, A.cust_id  < / Pre> 

It runs but everything marks only with '1' I know that this is fine because I have asked to do this, and it is actually looking at the value of cust_id and why all > 1 and all returning '1'.

How do I type it to mark the first instance of cust_id with '1' and the rest (or duplicate as cust_id's '0')

The purpose is that I I can summarize in Excel and calculate from there for a pivot chart.

Thanks in advance for help !!!!! This site has saved my life once!

Edit:

MS SQL 2008 R2


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -