Do you know how I can get the total of a GROUP BY
?. Let me explain: a grouping is made by plan and each plan has its total; I need to get the total of all that.
An example is
(plan) (cantidad usuarios no admin) costo plan total
admin 5 4 (5*4 = 20)
silver 7 5 (7*5 = 35)
gold 20 10 (10*20 = 200)
----------------------------------------------------------------------
gran total = 255
I tried ROLLUP BUT it doesn't work. it gives me an erroneous result
The grand total is what I want to get and now if you see that you know it's because each one has a different cost. What I need is the query that gets grand total.
I recommend using
SELECT
nesting, as it allows you to separate the operations.For example, consider the following simple table called
planes
:To get only the grand total, the query would be like this:
Result
If you want to obtain a table as (almost) as the one shown in your example, the query would be:
Result:
This solution could be
but I don't know why it would be necessary to go through a group by if you only want the grand total, the sql could be simpler:
You can also make a combination between both queries:
to get a result like this: