Skip to content

Instantly share code, notes, and snippets.

@rpastorelle
Last active December 14, 2015 11:59
Show Gist options
  • Save rpastorelle/5083561 to your computer and use it in GitHub Desktop.
Save rpastorelle/5083561 to your computer and use it in GitHub Desktop.
Query Product Reviews for previous 7 day period.
SELECT p.ProductCode, p.ProductName,
r.ReviewTitle, r.Rate, r.ReviewDescription,
r.LastModified
FROM Products p
INNER JOIN Reviews r ON r.ProductCode = p.ProductCode
WHERE r.LastModified
BETWEEN CONVERT( VARCHAR(10) DATEADD(day, -7, GETDATE()), 101 ) + ' 0:00'
AND CONVERT( VARCHAR(10) DATEADD(day, -1, GETDATE()), 101 ) + ' 23:59'
ORDER BY r.LastModified DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment