I would like to make a query that dynamically filters to only include the last available monthly date.
The only values to be left in the screenshot below should be the last available value of the month.
You can see 4 April values available here, but only the last one should be visible and have the date value if the first of the month.
The result should be as following
Help would be greatly appreciated
2条答案
按热度按时间az31mfrm1#
We can use
ROW_NUMBER
along with a calculation to find the first of the month:pxyaymoc2#
You can use window function and Cte to solve the problem
you use FORMAT to find part YYYY MM of date
You can insert the basic data with the following statements: