Hi Kortni, You can define an aggregate function for this and write custom code.
Thanks and Regards, Sonal www.meghsoft.com http://in.linkedin.com/in/sonalgoyal On Wed, May 26, 2010 at 12:43 AM, Kortni Smith <[email protected]> wrote: > Hi, > > > > Is there a hive equivalent to Oracle’s rownum, row_number() or the ability > to loop through a resultset? > > > > I have been struggling to create a hive query that will give me max X > records, per something, when sorted by something. For example, I have book > data, multiple records for any given isbn, and want the lowest 5 priced > books per isbn. > > > > I can accomplish this in oracle with the following: > > > > select isbn, price from > > ( > > select isbn, price, row_number() over (partition by isbn order by price asc) > rn > > from kstest > > ) > > where rn <= 5; > > > > Any ideas would be greatly appreciated. > > Thank you, > > > > Kortni Smith | Software Developer > AbeBooks.com Passion for books. > > [email protected] > phone: 250.412.3272 | fax: 250.475.6014 > > Suite 500 - 655 Tyee Rd. Victoria, BC. Canada V9A 6X5 > > www.abebooks.com | www.abebooks.co.uk | www.abebooks.de > www.abebooks.fr | www.abebooks.it | www.iberlibro.com > >
