On Oct 7, 2:32 am, weird0 <[EMAIL PROTECTED]> wrote: > How can i calculate the sum of top 3 records in pl/sql ?? > > I able to sum up all of the records by using sum() aggregate function > and group by, but how do i restrict it to only top 3. > > Regards
lots of ways to do this .. here is a VERY SIMPLEMINDED way.. it is first thing in the morning after all select sum(the_value) from ( select the_value, rownum as therow from the_table order by the_value desc) where therow <=3 this method sucks rocks if your volume is very large and using rank() is a better solution but this one is very simple and requires nothing beyond very basic sql to implement Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Oracle PL/SQL" group. To post to this group, send email to Oracle-PLSQL@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Oracle-PLSQL?hl=en -~----------~----~----~----~------~----~------~--~---