Currently I am working on a query to get the Date with the least made profit. The table, that I am using for this is this one:
The query I came up with finds the date with the least made profit, but doesnt show the SUM of the amount made in that day:
SELECT MIN(PRICE*QUANTITY) AS UMSATZ, ORDER_DATE
FROM FACT_ORDER
GROUP BY ORDER_DATE
ORDER BY UMSATZ
LIMIT 1;
Which query could show the SUM amount of the profit made that day in addition (not with an additional column)? Thank you very much in advance!
Which query could show the SUM amount of the profit made that day in addition (not with an additional column)?
To get the total:
SELECT DISTINCT ORDER_DATE,
SUM(PRICE*QUANTITY) OVER(PARTITION BY ORDER_DATE) AS UMSATZ
FROM FACT_ORDER
QUALIFY (PRICE*QUANTITY) = MIN(PRICE*QUANTITY) OVER(PARTITION BY ORDER_DATE);