Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!
CREATE PROCEDURE spx @BeginDate DATETIME @EndDate DATETIME AS SELECT StoreNumber, Date, Sales, DateComp, SalesComp, Labor, CashOS, Comment, (Sales-SalesComp)/nullif(SalesComp,0)*100 AS DCompPercent FROM (SELECT T1.StoreNumber, T1.Date, T1.Sales, DateAdd(DAY,-371,T1.Date) AS DateComp, (Select Sum (Sales) FROM Sales WHERE T1.StoreNumber = Sales.StoreNumber and Sales.Date = DateAdd(DAY,-371,T1.Date)) AS SalesComp, T1.Labor, T1.CashOS, T1.Comment FROM Sales AS T1) S Where Date BETWEEN @BeginDate and @EndDate ORDER BY Date DESC, StoreNumber ASC
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.