Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[CAP] min and max functions

Since there is nothing in the official CAP documentation about min and max functions, I figured out the following syntax:

    const result1 = await cds.run(`SELECT *, MAX(seqNr) FROM ${myTable} LIMIT 1`) //returns array

    const result2 = await SELECT.one.from(myTable, [`MAX(seqNr)`]).columns('*') //returns object 

    const result3 = await SELECT.one.from(myTable).columns('MAX(seqNr)') //returns object containing only the max counter value

One comment

  1. Pingback: [CAP] Select max with group by – nocin.eu

Leave a Reply

Your email address will not be published. Required fields are marked *