Fact table for sales product - oracle I have sales fact table (which has quantity - price measures) and dimensions (product - customer -time)
my table schema:

I need a query to get best selling product; then show list of amount paid for buying this product in each year and month like this example

Year    Month        AmountOfMoney
====    =====        =============
-       -            14040.00
1988    -            130.00
1998    March        130.00
I do not use Oracle, but using a STD syntax it should work:

/* aggregated sales by year-month */
SELECT
    T.CALENDAR_YEAR AS Year,
    T.CALENDAR_MONTH_DESC AS Month,
    SUM(S.AMOUNT_SOLD) AS AmountOfMoney
FROM
    SALES S
JOIN
    TIMES T
    ON T.TIME_ID = S.TIME_ID
WHERE S.PROD_ID = (SELECT PROD_ID
                   FROM (
                         SELECT 
                            S.PROD_ID,
                            SUM(S.AMOUNT_SOLD) AMOUNT
                         FROM
                            SALES S
                         GROUP BY S.PROD_ID
                         ORDER BY SUM(S.AMOUNT_SOLD) DESC
                        ) BS
                   WHERE ROWNUM = 1
                  )  
GROUP BY
    T.CALENDAR_YEAR,
    T.CALENDAR_MONTH_DESC
ORDER BY
    T.CALENDAR_YEAR,
    T.CALENDAR_MONTH_DESC;


db&lt;>fiddle here