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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ACCESS Query ? Multiple Counts Duplicates Sum

Status
Not open for further replies.

pat731

Technical User
Jan 12, 2003
39
US
I have two different tables and link them together to get
something that looks like this



ssn act code ppe emst
333-33-3333 02 33 1
333-33-3333 06 31 1
333-33-3333 09 1 1
444-33-3333 02 33 2
444-33-3333 06 32 2
444-33-3333 02 6 2


So what I need is the Sum of the ppe by SSN AND THEN KEEPING THE HIGHEST ACT CODE - BY THE HIGHEST ORGINAL PPE.
Can someone
 
the result i would need would be

333-33-3333 02 65 1


444-33-3333 02 71 2
I need to count the ssn by their activity code with the Highest PPE. Then sum the ppe in all activity codes;
does that help
 
Hmm

Code:
select ssn,(select actcode from t as t2 where ssn = t1.ssn
               and ppe = (select max(ppe) from t
                where ssn = t2.ssn) as MaxActCode,
       sum(ppe),emst from t as t1
 group by ssn,emst

I'm not sure that this what you want but maybe you can elaborate from here on.
 
can I do that from my querie view or should i do it with the sql view. thanks I am still learning
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top