Skip to content
Advertisement

Extract only dates for first Day of Month from a daily Date Dimension Table without nesting

I am using SQL Server 2014 and I have the following T-SQL query which retrieves the dates of the first day of each month (based on my filters) from a Date Dimension Table:

The output is as follows:

I have used a nested query to achieve this. My question is whether I can achieve the same result without using the nested query. My Date Dimension table is a table with daily dates.

Advertisement

Answer

Just repeat the date calculation part inside GROUP BY:

PS: this:

could be written as:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement