December 31, 2015 at 7:07 am
I would like to SELECT only dates from my dimDate table that are less than or equal to the latest date in my factTable. Any syntax for this would be greatly appreciated.
December 31, 2015 at 8:07 am
joeshu26 (12/31/2015)
I would like to SELECT only dates from my dimDate table that are less than or equal to the latest date in my factTable. Any syntax for this would be greatly appreciated.
This will return a distinct result of dates which are equal to or less than the most recent sales transaction date.
SELECT FullDate
FROM DimDate
WHERE DateKey <= (SELECT MAX(SaleDateKey) FROM FactSales);
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
December 31, 2015 at 8:08 am
joeshu26 (12/31/2015)
I would like to SELECT only dates from my dimDate table that are less than or equal to the latest date in my factTable. Any syntax for this would be greatly appreciated.
You could select the MAX(date) from your fact table and store it in a variable. You can then use that in WHERE clause, or JOIN statement, of the query where you use the dimDate table.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
December 31, 2015 at 8:38 am
This worked great Thank you!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply