I have a below query which gives me data for past X days. Instead of that I wanted to get data in between two dates which should be configurable if possible? Is there any way to do it?
SELECT processId,
houroftheday,
minuteofhour,
listagg(clientId, ',') within group (order by minuteofhour) as clientIds,
count(*) as psg
FROM data.process
where kite = 'BULLS'
and code is null
and timestampinepochsecond > date_part(epoch, sysdate) - X*24*60*60
group by 1, 2, 3
timestampinepochsecond
column has this value - 1599608655
How can I use timestampinepochsecond
column to get data in between two dates? Something like below:
timestampinepochsecond between 2020-12-01 AND 2021-01-05
Update
I am trying to declare two variables and use those in my query as shown below but it doesn't work-
CREATE TEMP TABLE tmp_variables AS SELECT
cast(DATEDIFF(s, '1970-01-01 00:00:00.000', '2016-12-09 16:22:17.897' ) as bigint) AS StartDate,
cast(DATEDIFF(s, '1970-01-01 00:00:00.000', '2016-12-10 16:22:17.897' ) as bigint) AS EndDate,
5556::BIGINT AS some_id;
SELECT StartDate, EndDate FROM tmp_variables;