Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

How to add row to view that contains the total (MySQL)

$
0
0

I know this question has been asked before but I've been trying the solutions and I'm still getting errors.

I've created a view to view the quantity of life jackets by size:

---------------LIFE JACKET LIST------------

CREATE VIEW Life_Jacket_List AS

SELECT size,SUM(quantity) AS Quantity

FROM life_jackets LEFT JOIN equipment USING(model)

GROUP BY size with ROLLUP

Which looks like this:

sizeQuantity
L48
M39
S35
NULL122

Basically I just want to change the "null" to "Total". Here is what I've done so far:

CREATE VIEW Life_Jacket_List AS

SELECT size, size = ISNULL(size, ‘Total’), TotalLife = SUM(quantity), SUM(quantity AS Quantity

FROM life_jackets LEFT JOIN equipment USING(model)

GROUP BY size with ROLLUP

I'm getting an error though:

1582 - Incorrect parameter count in the call to native function 'ISNULL'

Any idea on how to fix this?


Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>