How to use ROUND() function

Sep 24, 2013 at 4:07 PM
Hi guys,

I am trying to convert the query below using this library but I fail.
SELECT ChargeValue AS charge FROM forms.charges WHERE ROUND(@amount,2) BETWEEN MinAmount AND MaxAmount AND `type` = @type;
I need help guys. Thank you.
Coordinator
Sep 28, 2013 at 11:08 AM
Edited Sep 28, 2013 at 11:10 AM
Looks like you captured a bug for me.
The custom functions were not generating as they should. Just checked in an update and you should now be able to provide custom function names.

So....going back to the Round function
DBParam amount = DBParam.ParamWithValue("amount",10);
DBQuery sel = DBQuery.SelectAll()
         .Where(DBFunction.Function("Round", amount, DBConst.Int32(2)), Compare.GreaterThanEqual, DBField.Field("MinAmount"))
        .AndWhere(DBFunction.Function("Round", amount, DBConst.Int32(2)), Compare.LessThanEqual, DBField.Field("MaxAmount"));
Will give you something like this...
 SELECT *
    WHERE  ( (ROUND(@amount, 2)  >= [MinAmount])  AND  (ROUND(@amount, 2)  <= [MaxAmount]) ) ;