Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Added on June 10, 2020 8:56PM
Likes: 0
Replies: 1
I want to calculate the last day of a column in a dataset and use it dynamically in my SQL recipe. I'm not using Python so I don't know how to set it as a variable. Is there a way to call the metric straight from the SQL recipe? Or send the metrics to global variables after the dataset build?
Hi @gblack686
If you're using SQL for your recipe and the statement looks something like this:
SELECT column_1 , column_2 , column_date FROM table
you can just modify this to be
SELECT column_1 , column_2 , column_date , (SELECT MAX(column_date) FROM table) AS column_date_max FROM table
This syntax can sometimes be inefficient if dealing with many such columns on large and non-indexed tables, but it's simple to follow without needing joins.