Hello MySQL Users-

I am pretty sure this is a simple question and I am over thinking how to
solve the problem, so I am hoping the community can help.

I am selecting a pretty straightforward aggregation from a single stats
table with the following format:

SELECT
    Description
    LongDescription
    Detail
    SUM(Volume)
FROM StatsTable
GROUP BY Description
    LongDescription
    Detail

What I am trying to limit this query to is the top 100 details ordered by
SUM(Volume) DESC for each unique LongDescription
This is what I am trying now but its not quite correct, it simply returns
100 of the top details.

SELECT
    Description
    LongDescription
    Detail
    SUM(Volume)
FROM StatsTable
GROUP BY Description
    LongDescription
    Detail
ORDER BY SUM(Volume) DESC
LIMIT 100

What I believe would work is a function in MySQL that is equivalent to the
CUBE function in Oracle.

Any direction would be greatly appreciated!

David

Reply via email to