SELECT SalesOrderID, OrderDate, Week_Day FROM Sales.SalesOrderHeader CROSS APPLY (SELECT DATEPART(weekday, DATEADD(day, @@DATEFIRST - 7, OrderDate)) AS Week_Day) AS A WHERE Week_Day NOT IN (1, 7);
http://sqlmag.com/blog/tip-apply-and-reuse-column-aliases
0 comments:
Post a Comment