Thread
#exposed
    Sergio Casero

    Sergio Casero

    3 years ago
    Hello guys! Just small and noob question, how can I retrieve the "sum" value in the result row when using groupBy?
    For example like this:
    ProductVo.slice(ProductVo.reference,ProductVo.quantity.sum())
                    .selectAll()
                    .groupBy(Prouct.reference)
    I can retrieve productVo.reference with:
    map { it[ProductVo.reference] }
    But no the "quantity sum" value, I've tested with alias but didn't work
    I can get the value by using
    data[1]
    but... it's a workaround
    orangy

    orangy

    3 years ago
    groupBy
    is a map from key to list of values, you might want
    associateBy
    Sergio Casero

    Sergio Casero

    3 years ago
    Will take a look
    tapac

    tapac

    3 years ago
    val qSum = ProductVo.quantity.sum()
    ProductVo.slice(ProductVo.reference, qSum)
                    .selectAll()
                    .groupBy(ProductVo.reference)
                   .map{ it[qSum] }
    Sergio Casero

    Sergio Casero

    3 years ago
    ahhhhh, thanks! I'm stupid haha