Re: SELECT-UNION-SUM-ROUND question
Posted in 1996
In article: <4mq6up$13c@cssun.mathcs.emory.edu>
valery@milcse.cig.mot.com (Valery Azbel) writes:
> Could someone please explain this strange behavior of the
> SELECT statement :
>
> create table double_test ( sel_key integer, charge float );
> insert into double_test values( 2, 5.02);
> insert into double_test values( 2, 6.064);
> insert into double_test values( 1, 5.02);
> insert into double_test values( 1, 6.064);>
> select sum( round(charge,<VAR>) )
> from double_test where sel_key =1
> union
> select sum( charge )
> from double_test where sel_key =2
>
>
> VAR = 0 Results :
> (sum)
> 11.00
> 11.08
This one seems ok.
> VAR = 1 Results :
> (sum)
> 11.10
> 11.08
This one too.
> VAR = 2 Results :
> (sum)
> 11.08
> 11.08
Its only being displayed to 2 DP so this is right too.
(try changing DBFORMAT ?)
> VAR = 3 Results :
> (sum)
> 11.08 ( only 1 row(s) retrieved. ?! )
Ah, now the wonders of the union - the two are the same
so only one is pulled back - try using "UNION ALL"
> VAR = 4 Results :
> (sum)
> 11.08 ( only 1 row(s) retrieved. ?! )
>
> I've checked it on 5.02.UC8 and 7.11.UC1( Solaris 2.4 ) and
got
> the same results.
>
> I would expect different behavior.
>
>
> Thanks in advance
> Valery
>
>
--
Mike Aubury _\\?/_
|O O|
+----------oOOO-\\_/-OOOo---------+----------------------------
-+
| Heisenberg may have been here | mike@aubury.demon.co.uk
|
| | http://www.flash.net/~aubit
|
+--------------------------------+----------------------------
-+