Oracle 5.0 Reference Manual page 994

Table of Contents

Advertisement

| 2000 | Finland | Computer
| 2000 | Finland | Phone
| 2000 | Finland | NULL
| 2000 | India
| Calculator |
| 2000 | India
| Computer
| 2000 | India
| NULL
| 2000 | USA
| Calculator |
| 2000 | USA
| Computer
| 2000 | USA
| NULL
| 2000 | NULL
| NULL
| 2001 | Finland | Phone
| 2001 | Finland | NULL
| 2001 | USA
| Calculator |
| 2001 | USA
| Computer
| 2001 | USA
| TV
| 2001 | USA
| NULL
| 2001 | NULL
| NULL
| NULL | NULL
| NULL
+------+---------+------------+-------------+
For this query, adding
analysis, not just one. Here is how to interpret the
• Following each set of product rows for a given year and country, an extra summary row is produced
showing the total for all products. These rows have the
• Following each set of rows for a given year, an extra summary row is produced showing the total for
all countries and products. These rows have the
• Finally, following all other rows, an extra summary row is produced showing the grand total for all
years, countries, and products. This row has the year, country, and
NULL.
Other Considerations When using
The following items list some behaviors specific to the MySQL implementation of ROLLUP:
When you use ROLLUP, you cannot also use an
and
ROLLUP
ORDER BY
in MySQL sorts results, and you can use explicit
GROUP BY
named in the
GROUP BY
rows added by
ROLLUP
order.)
can be used to restrict the number of rows returned to the client.
LIMIT
ROLLUP, so the limit applies against the extra rows added by ROLLUP. For example:
mysql>
SELECT year, country, product, SUM(profit)
->
FROM sales
->
GROUP BY year, country, product WITH ROLLUP
->
LIMIT 5;
+------+---------+------------+-------------+
| year | country | product
+------+---------+------------+-------------+
| 2000 | Finland | Computer
| 2000 | Finland | Phone
| 2000 | Finland | NULL
| 2000 | India
| Calculator |
| 2000 | India
| Computer
+------+---------+------------+-------------+
Using
with
LIMIT
ROLLUP
less context for understanding the super-aggregate rows.
The
indicators in each super-aggregate row are produced when the row is sent to the client.
NULL
The server looks at the columns named in the
GROUP BY
|
1500 |
|
100 |
|
1600 |
150 |
|
1200 |
|
1350 |
75 |
|
1500 |
|
1575 |
|
4525 |
|
10 |
|
10 |
50 |
|
2700 |
|
250 |
|
3000 |
|
3010 |
|
7535 |
causes the output to include summary information at four levels of
ROLLUP
ROLLUP
are mutually exclusive. However, you still have some control over sort order.
list to specify sort order for individual columns. (The higher-level summary
still appear after the rows from which they are calculated, regardless of the sort
| SUM(profit) |
|
1500 |
|
100 |
|
1600 |
150 |
|
1200 |
may produce results that are more difficult to interpret, because you have
974
Modifiers
output:
ROLLUP
column set to NULL.
product
and
country
products
clause to sort the results. In other words,
ORDER BY
and
ASC
clause following the leftmost one that has
GROUP BY
columns set to NULL.
columns set to
products
keywords with columns
DESC
is applied after
LIMIT

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents