Could you please tell me how I can use explicit type conversion from say the output of the COUNT() function, to type REAL?
Of what type are your field1 & field2?On Wed, Nov 04, 2009 at 06:09:07PM -0500, Roman Sokolyuk wrote:
> Hi,
>
> I am encountering the following issue:
>
> SELECT
> field1, //returns 4
> field2, //returns 1
> ( ( field2 / field1) * 100) //this returns zero - not what I want - I am
> looking for 25
>
> Am I doing something wrong with type conversion (integer/floating point)?
If they are integer types, the result you get seems to be as expected with
integer arithmetics --- unless the SQL standard requires implicit convertion
to floating point when processing integer data --- I'm not sure about that.
In case integer arithmetics is indeed what the SQL standard requires, you'll
need to rewrite your query to explicitly convert the integers to decimals,
floats or doubles to force decimal or floating point arithmetics.
Alterntatively, you could simply apply arithmetic rules to rewrite the term
to, say, ((100 * field2) / field1), obviously risking an overflow in case
field2 can be larger than 1/100 of the respective integer type domain.
In case the SQL standard strictly requires decimal/loating point arithmetics
also with integer types, please file a bug report via our bug tracker on
SourceForge.
Stefan
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> MonetDB-users mailing list
> MonetDB-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/monetdb-users
--
| Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl |
| CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ |
| 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 |
| The Netherlands | Fax : +31 (20) 592-4312 |
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
MonetDB-users mailing list
MonetDB-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/monetdb-users