Re: SELECT-UNION-SUM-ROUND question
Posted in 1996
Valery Azbel wrote: > > Could someone please explain this strange behavior of the > SELECT statement : [ ... ] > select sum( round(charge,<VAR>) ) > from double_test where sel_key =1 > union > select sum( charge ) > from double_test where sel_key =2 [ ... ] > 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 would expect different behavior. As documented in the manuals, the default behaviour of UNION is to remove duplicates. At VAR > 2 the two selects have the same result and only one row is returned. To get all rows returned regardless of their value use UNION ALL. Cosmo