Forum Discussion

PSTyler's avatar
PSTyler
Occasional Contributor
9 years ago

How to get a database result of Sum of Amount column from database result?

I tried this

    def q2 = "Select SUM(Amount) from abcd dabase.Data.FeeInstance where value= x"
    def result1 = db.rows(q2)
    assert result1.size() == 1
    dbAmount = result1.get(0)
   log.info "Total Fee Charged on Payment Account is -->"+"---"+dbAmount

Out put prints like this Total Fee Charged on Payment Account is -->---[:5.3200]

and I am expecting $5.32

 

2 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi PSoni,

     

    I’m not familiar with Groovy. However, I suspect that you see this because of the string conversion issue. You need to convert the value you got to the string with the needed format before posting it to the log. Many languages provide special functions to convert strings – check this.

    • PSTyler's avatar
      PSTyler
      Occasional Contributor

      I tried all available convert functions but it's in the database so not getting any success. You said check this and I assume you were trying to provide some link for conver string function.