sigil Posted May 24, 2010 Posted May 24, 2010 (edited) Using SQLite, I have a table whose columns are type REAL. I want to round the values to integers, but I keep getting a trailing ".0" at the end of every value. For example: local $aresult,$irows,$icolumns $iRval = _SQLite_GetTable2d (-1, "SELECT round(2.52,0) FROM records;", $aResult, $iRows, $iColumns) _arraydisplay($aresult) returns 3.0. That is the correct result of rounding 2.52 to the nearest integer, but I don't want to display the trailing decimal. How can I make my query omit it? EDIT: never mind, solved it. Used cast(round(x) as integer). Edited May 24, 2010 by sigil
tehdon Posted May 24, 2010 Posted May 24, 2010 According to the SQLLite documentation here http://www.sqlite.org/lang_corefunc.html#round It would appear if you specify two arguments, a floating-point number is returned. If you only specify one argument, an integer is returned. Not sure how many operations you're doing, but it may be more efficient to call round() with one argument rather than CASTing every result.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now