Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count items only one time..no duplicates 1

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
Hello folks! I have a set of data that looks something like this:

Item Component PU
12H1234 1234 20 (count)
12H1234 4567 20 (count)
12H1234 8901 20 (count)
12H1234 1234 25 (count)
12H1234 4567 20 (don't count)

50Z6789 1234 25 (count)
50Z6789 9867 25 (count)
50Z6789 5687 20 (count)
50Z6789 4567 25 (count)
50z6789 4567 25 (don't count)

I'm trying to count the unique Items for each component where the PU is different. Desired results would by

ITEM COUNTOFCOMPONENT
12H1234 4
50Z6789 4

I've tried but I can't get the query to count the way I've shown above. I get all the components.

I tried to have patience but it took to long! :) -DW
 
Code:
select Item
     , count(*) as components
  from (
       select distinct
              Item
            , Component 
            , PU
         from daTable
       ) sa data
group
    by Item

r937.com | rudy.ca
 
Thanks rudy! I think that did the trick!

I tried to have patience but it took to long! :) -DW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top