
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we get the summary output of a column in MySQL result set itself?
We can get the summary output of a column in MySQL result set by using the “WITH ROLLUP” modifier. This modifier is used with GROUP BY CLAUSE. It gives the summary output to include extra rows that represent higher-level summary operations.
Example
In this example, the WITH ROLLUP modifier gave the summary output with total cost value in the extra row.
mysql> Select Item_name, SUM(Cost) AS Total_cost from Item_list GROUP BY Item_name WITH ROLLUP; +-----------+------------+ | Item_name | Total_cost | +-----------+------------+ | Notebook | 45.00 | | Pen | 31.70 | | Pencilbox | 125.20 | | NULL | 201.90 | +-----------+------------+ 4 rows in set (0.00 sec)
- Related Questions & Answers
- How can we get only unique values of a column in MySQL result set?
- How can we get all the unique rows in MySQL result set?
- How can we get the sorted MySQL output?
- In MySQL, how can we randomize set of rows or values in the result set?
- How can we handle a result set inside MySQL stored procedure?
- How to sort MySQL output on the basis of the column which is not in the result set?
- How can we divide the result set returned by MySQL into groups?
- How can we get an idea about the server performance from the output of MySQL?
- How can we get the structure of a MySQL view as we can get the structure of a MySQL table?
- How can we get the definition of a MySQL view as we can get the definition of a MySQL table?
- Can we replace a number with a String in a MySQL result set?
- How to round the summary output in R?
- How can I get the records from MySQL table in result set in a particular way?
- How can we fetch a MySQL SET column as a list of integer offset?
- How can we apply filtering criteria at group levels of the result set returned by MySQL?
Advertisements