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
cust_id Order_id unique 001 001 001 002 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0 0 0/0 / What is the result above? What are you looking at? Below is a bold works based on database. The reason you are getting is due to the order on the customer and customer's order above all 1. You just want to group on the cut.
Use AdventureWorks2008R2; As with CustSales (C. Customer ID, H. Seal Order ID, ROW_NUMBER (), select (Customer's Sales Sales Sales Sales Cells, C.CustomerID = H. Customer Id) Customer ID, Select Cellsardide, case, when S = 1 then end of 1 and 0 [Unique] is in the form of a cut sale
Comments
Post a Comment