Skip to content

How to implement a special top-N group function? #494

@shenjianrong

Description

@shenjianrong

The table orders has some fields as following:
orderkey, product, amount, order_month, ......
I want to implement a UDF to use like:
select product, udf_topN(amount, -5) from orders group by product
this query means selecting the top 5 records by amount descending sort in each product group.
Can I implement this function using PL/Java and how to do? Please tell me where I can find such documents or information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions