I have such a SQL segment SELECT DataTime,
ROUND(SUM(Hotavg)/1000,0)
and the purpose is clear. I write them in the honeysql way (h/select :DataTime [(sql/call :round (/ (sql/call :sum :Hotavg) 1000) 0) :Hotavg])
but it doesn't work. I get error message
honeysql.types.SqlCall cannot be cast to java.lang.Number
I wonder is there anyway to use SQL Arithmetic Operators in honysql select component?
I know I can finish my task by executing raw sql or do the arithmetic operations in the logic code. But my purpose is to find out whether honeysql support SQL Arithmetic Operators.
Any help will be appreciated!
I looked into the tests and this test seems to express something similar:
So my guess would be that
(/ (sql/call :sum :Hotavg) 1000)
must be rewritten as(sql/call :/ (sql/call :sum :HotAvg) 1000)
.Use
sql/format
to test if your query is correct.