Hi Could somebody please help
I have the below query:
select frf.EDGE_RECURRENCE_KEY, min(td.sql_date)
from future_revenue_fact frf, EMBEDDED_EDGE_REV_ITEMS eeri, attribution_dimension ad, attribution_units_fact au, time_dimension td
where frf.ATTRIBUTION_TRANSACTION_KEY = ad.ATTRIBUTION_TRANSACTION_KEY
and ad.ATTRIBUTION_ROLE = 'Salesperson'
and ad.ATTR_UNIT_TRANSACTION_KEY = au.ATTR_UNIT_TRANSACTION_KEY
and frf.EDGE_RECURRENCE_KEY = eeri.EMBEDDED_EDGE_ID
and eeri.EMBEDDED_EDGE_VERSION_NO = 0
and frf.REVENUE_RECORD_TIME_KEY = td.TIME_KEY
and frf.REVENUE_TYPE = 'Embedded Edge'
and au.ATTRIBUTION_UNIT_NAME = 'Darren Starr'
group by frf.EDGE_RECURRENCE_KEY
This query works fine, however I need to somehow just return min(td.sql_date) in the select statement and not frf.EDGE_RECURRENCE_KEY as the min(td.sql_date) needs to feed as into another query eg:
select *
from table x
where sql_date in ----> here i need to return the min(sql_date) using the first query.
Is there anyway around this, besides using a stored proc??