Re: SELECT-UNION-SUM-ROUND question
Posted in 1996
That because the union of VAR = 2 retuned the same value for the two rows 11.08. When you union these two rows it's the same value so it only returned the 1 row (value) 11.08. Straight from the SQL tutorial page 3-38 December 1991 (for 5.X engine) "The UNION keyword selects all rows from the two queries, remove duplicates, and returns what is left" ------------------------------------------------------------------------- Cheryl Kendricks Internet:cherylk@prod1.jcdc.doleta.gov OR kendric@gwysmtp.jcdc.doleta.gov DTSI, Inc. Voice: 1-800-598-5008 Database Administrator - DOL Job Corps San Marcos, Texas ------------------------------------------------------------------------ On Wed, 8 May 1996, Valery Azbel wrote: } } Hi , } } 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 } } VAR = 1 Results : } (sum) } 11.10 } 11.08 } } VAR = 2 Results : } (sum) } 11.08 } 11.08 } } VAR = 3 Results : } (sum) } 11.08 ( only 1 row(s) retrieved. ?! ) } } 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 }