Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Wednesday, April 16, 2014

SQL - First and last day of the month

-- First day of the last month
SELECT DATEADD(mm, DATEDIFF(m,0,GETDATE())-1,0);

-- Last day of the last month
SELECT DATEADD(d,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())  ,0));

SQL - Mixing INNER and OUTER Joins [external link]

When mixing INNER and OUTER joins, it's important to understand the risks involed and this article describe it very clearly:
http://weblogs.sqlteam.com/jeffs/archive/2007/10/11/mixing-inner-outer-joins-sql.aspx