My WAG would be you need to group on empcode & cycles in order to have 
the TOP clause give you what you want.

Tracy Pearson wrote:
> WAG
>
> Select empcode, (select sum(gross) from table1 sumtable where
> sumtable.empcode = table1.empcode top 52 order by cycle desc) as grosssum
> from table1 group by empcode
>
> Tracy
>   
>> -----Original Message-----
>> From: Sytze de Boer
>> Sent: Wednesday, January 17, 2007 1:39 PM
>>
>> Hi folk
>> I have a table where amongst other fields, I have empcode
>> C(10), gross N(10,2), cycle N(5) empcode is the employee
>> code, gross is total pay, cycle is the pay number
>>
>> I want to:
>> select empcode, sum(gross) from mytable order by empcode
>> group by empcode into table newtable BUT I ONLY WANT THE LAST
>> 52 CYCLES (Some may have 300 cycles) Some may only have (say)
>> 30 cycles
>>
>> Is this feasible ?
>>
>> Regards
>> Sytze
>>     

-- 
Richard Kaye
Vice President
Artfact/RFC Systems
Voice: 617.219.1038
Fax:  617.219.1001

For the fastest response time, please send your support
queries to:

Technical Support - [EMAIL PROTECTED]
Australian Support - [EMAIL PROTECTED]
Internet Support - [EMAIL PROTECTED]
All Other Requests - [EMAIL PROTECTED]

---------------------------------------------------------
This message has been checked for viruses before sending.
---------------------------------------------------------



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to