Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!
SELECT CASE WHEN Locations.[Location Name] IS NULL THEN @Location ELSE Locations.[Location Name] END AS Location, Calendar.Dt, CASE WHEN Sales.[Net Sales] IS NULL THEN 0 ELSE Sales.[Net Sales] END AS CurrentSales, LEFT(DATENAME(dw, Calendar.Dt), 3) AS DayName, DATEPART(isowk, Calendar.Dt) AS WeekNum FROM Locations LEFT OUTER JOIN Sales ON Locations.LocationNameOrig = Sales.[Location Name] RIGHT OUTER JOIN Calendar ON Sales.Date = Calendar.Dt WHERE (Locations.[Location Name] = @Location) AND (Calendar.Dt BETWEEN @Begin AND @End) OR (Locations.[Location Name] IS NULL) AND (Calendar.Dt BETWEEN @Begin AND @End) ORDER BY Calendar.Dt
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|Select question from MySQL||1||20|
|How can I use this function?||3||32|
|SQL Query incorrect syntax near the keyword ON any help would be appreciated||18||27|
|creating a permanent table from the results of a select statement in sql server 2016||5||30|