'Custom' group by in select
After some more time looking for a solution, I finally got it. I'll post an answer for future users to have access.
Solution:
With Sales As (
Select
Id_Product,
Sum(Qt_Sold) Sold_Amount,
Sum(Net_Value) Total_Net_Value,
Case Extract(Month From Date_Sale) || '' || Extract(Year From Date_Sale)
When Extract(Month From Current_TimeStamp) || '' || Extract(Year From Current_TimeStamp) Then 'MonthA'
When Extract(Month From DateAdd(Month, -1, Current_TimeStamp)) || '' || Extract(Year From DateAdd(Month, -1, Current_TimeStamp)) Then 'MonthB'
Else 'MonthC'
End Month_Of_Sale
From
Sale
Group By
Id_Product,
Month_Of_Sale
Order By
Id_Product,
Month_Of_Sale
)
Select
Id_Product,
Sum(Sold_Amount) Sold_Amount,
Sum(Total_Net_Value) Total_Net_Value,
Min(Month_Of_Sale) Month_Of_Sale
From
Sales
Group By
Id_Product
Order By
Id_Product