MySQL Forums
Forum List  »  Docs

Group by .. with rollup having
Posted by: KimSeong Loh
Date: August 02, 2006 07:42PM

Taking the example from http://dev.mysql.com/doc/refman/5.0/en/group-by-modifiers.html

mysql> SELECT year, SUM(profit) FROM sales GROUP BY year WITH ROLLUP;
+------+-------------+
| year | SUM(profit) |
+------+-------------+
| 2000 | 4525 |
| 2001 | 3010 |
| NULL | 7535 |
+------+-------------+

What is the expected behaviour if it is changed to
mysql> SELECT year, SUM(profit) as S FROM sales GROUP BY year WITH ROLLUP HAVING s > 4000;
+------+-------------+
| year | SUM(profit) |
+------+-------------+
| 2000 | 4525 |
| NULL | 7535 |
+------+-------------+
Should it be 4525 or 7535?
I believe I get 7535.

Maybe the exact behaviour on such situation should be documented.

Options: ReplyQuote


Subject
Views
Written By
Posted
Group by .. with rollup having
29148
August 02, 2006 07:42PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.