Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
mysql rullup with ifnull?
2 queries
A: select ifnull(products,'all') `company products` ,count(qty) from orders group by products with rollup
we'll have something like
----------------------
| milk | 3|
| cheese | 7|
| Butter | 8|
| all | 18|
----------------------------------
however if
B: select ifnull(products,'all') `company products` ,count(qty) from orders group by `company products` with rollup -- Or group by 1
we'll have something like
----------------------
| milk | 3|
| cheese | 7|
| Butter | 8|
| (NULL) | 18|
----------------------------------
why what happens and what is the difference
1 Answer
- Anonymous8 years agoFavorite Answer
The difference is the order in which the rollup happens. In the first example, first you do the rollup. The rollup adds a null column and then you convert the null column to "all"
In the second example, you're grouping by the output of "ifnull". THEN you do the rollup, which adds a new NULL value (the total of everything).