Can show columns in Druid to range by time?

Hi,
As an example:
Imagine we have a sale table and we want one of our columns to show a sum of sales history for our recent week and the beside column shows sales history from begging of the month till now.

Can we make this functionality for Druid and subsequently, create a table report in Superset.
As much as I know, Superset gives us those functionalities according to the dataset we bring from,
So, I suppose, If I solve this problem from Druid side, I could make a report in Superset appropriately.
Unless it could be solved from the Superset side.

Welcome @msbeigiai! Are you thinking about multiple search conditions within a SQL WHERE clause?

I think this can be done in druid SQL. Say you have a ‘sales’ column. You could query the latest 40 days, say, and have two columns included in the query. I’ll write how I think it would work, but it would need to be tested for syntax and correctness:

SELECT … ,
SUM(CASE TIME_EXTRACT(__time,‘MONTH’) WHEN TIME_EXTRACT(CURRENT_TIMESTAMP,‘MONTH’) THEN sales ELSE 0 END) AS “MonthSales”,
SUM(CASE TIME_EXTRACT(__time,‘WEEK’) WHEN TIME_EXTRACT(CURRENT_TIMESTAMP,‘WEEK’) THEN sales ELSE 0 END) AS “MonthSales”, …

If you don’t want the current week, but the previous, or other variations, it shouldn’t be hard to adapt the logic.

Yes. It solved. It did by using SQL.
Thanks, @Mark_Herrera, and @Ben_Krug

Awesome, glad to hear it, thanks!