Let One Row Represent a Group, Take 2
October 27, 2010 Ted Holt
Let’s return to a problem I wrote about a few months ago. The technique I illustrated in that article works for most implementations of SQL. Today it’s my pleasure to share a technique you can use with versions of SQL that include certain OLAP functions, such as DB2 for i V5R4 or above. You’ve been asked to list customer orders that have not been fully shipped, but you are to only show the first unshipped line of each order. Use the RANK() function to assign a sequential number to each row for each order, like this: select OrderNo, LineNo, |