SQL's ability to make sense of large sets of data by using simple functions that allow you to aggregate data is a major tool that every programmer should master. Learn how to make the most of SQL's aggregate functions.
Written by Rafael Victória-Pereira
How do you calculate a total amount based on detail records in RPG? You probably read each record, add the respective amount to a work variable, and move on to the next record, until the file (or subset of records) ends. Well, in SQL you can do the same with a single instruction. Let's explore the awesome power and flexibility of SQL's aggregate functions, making use of what I explained before about the Select SQL instruction. In that article, I introduced an Inventory Master Table, which I have been using in most examples. This table's name is InvMst, and its description is presented in the table below: