DROP TABLE IF EXISTS tmp1_variables;
CREATE TEMPORARY TABLE tmp1_variables AS (
SELECT
'2016-10-29'::date as start_date,
'2017-01-28'::date as end_date2,
dateadd(day,-13,getdate())::date as end_date);
SELECT cobrand_id, sum(calc) AS a, sum(count) AS b FROM jwn_calc s, tmp1_variables
where s.optimized_transaction_date > start_date
AND s.optimized_transaction_date <= min(end_date,end_date2)
I'm specifically getting the error at the min(end_date,end_date2)
, with error:
[42883] ERROR: function min(date, date) does not exist Hint: No function matches the given name and argument types. You may need to add explicit type casts.