title: Oracle SQL: Show Individual Count Even if There are Duplicates
body: <p>this is my first question on here, so please forgive me if I break any rules.</p>
  
  <p>Here is what I need to know:</p>
  
  <p>How do I create an Oracle SQL query that will display a unique count of something even if there are duplicates in the results?</p>
  
  <p>Example:  a customer table has a list of purchases made by various customers.  The table lists the customer ID, name, category of purchase (ie Hardware, Tools, Seasonal) ect.  The outcome of the query needs to show each customer id, customer name and the category of the purchase, and a count of the individual customer.  SO customer ID 1 for John Smith has made a purchase in each department.  If I do a count of the customer, he will appear three times as he has made three purchases, but I also need a column to count the customer only once.  The count in the other rows returned for the other departments should show a 0 or Null.</p>
  
  <p>I normally achieve this by pulling everything and exporting to excel.  I add a column that uses an IF formula on the ID to only show a 1 on the first occurrence of the customer IE:  IF(A3=A2,0,1) (if a3 is the same as A2, show a 0, if it's not the same as A2 then show a 1).  This will give me a unique count of customers for one part of the report and will still show me how many purchase the customer made in another part of the report.</p>
  
  <p>I want to do this directly in the SQL query as I have a large set of data this needs to be done on, and adding any formulas in excel will make the sheet huge.  This will also make it easier to host the query results in ACCESS so excel can pull it from there.</p>
  
  <p>I have tried to find a solution to this for a while, but any searching on Google will usually return results on how to remove duplicates form a table or how to count the duplicates in a table.</p>
  
  <p>I am sorry if this is long question, but I wanted to be through so I do not waste anyone's time on back an fourth comments (I have seen this many times on here and else where when the OP asks a very cryptic question and expects everyone to understand them without further expiation).</p>