I gave a query that I want to use to select MachineName, Analyte, TestDate and IdealConcentration for all the percentage diviation > 60 and < -30 and make the -60 be 'Over 60% and -30 be 'Below -30%. and also filtering the data to generate a list for test date within the past 7 days. so far I have the below query but it does not limit the data for the past 7 days
SELECT MachineName,Analyte,TestDate, IdealConcentration,
CASE WHEN PercentageDiviation > 60 THEN 'Over 60%'
WHEN PercentageDiviation < -30 THEN 'Below -30%'
ELSE 'Good'
END AS OutsideDiv_Range
FROM [ReportStagingDB_E].[dbo].[LeveyJenningReport_Negative]
WHERE PercentageDiviation > 60 or PercentageDiviation < -30
AND TestDate between dateadd(day,-7,getdate()) and getdate()
GROUP BY MachineName,Analyte,PercentageDiviation,TestDate,IdealConcentration.
Thanks