Skip to content
Advertisement

Tag: window-functions

SQL query grouping by range

Hi have a table A with the following data: I’d like to have the following result: My DB is DB2/400. I have tried with ROW_NUMBER partitioning, subqueries but I can’t figure out how to solve this. Answer I understand this as a gaps-and-island problem, where you want to group together adjacent rows that have the same PA. Here is an

Rank based on cumulative value

I want to rank on ID and value columns based on ascending order of UID. Expected output has to change once value column has a different value than the previous value. Ranks has to restart on each new ID Here is a sample dataset that I have created: Answer I think that the simplest approach to this gaps-and-islands problem is

Advertisement