Last active
January 31, 2018 21:42
-
-
Save eugene-sh/690c3d7c5d94abdd46333c245e81218a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
[Name], * | |
FROM | |
Customer AS c | |
inner join | |
Purchaise AS p | |
ON c.CustomerId = p.CustomerId | |
WHERE | |
p.ProductNameN = N'Молоко' | |
and c.CustomerId not in | |
( | |
SELECT | |
CustomerId | |
FROM | |
Purchaise | |
WHERE | |
datepart(m, PurchaiseDatetime) = datepart(m, dateadd(m, - 1, getdate())) | |
AND datepart(yyyy, PurchaiseDatetime) = datepart(yyyy, dateadd(m, - 1, getdate())) | |
and ProductNameN = N'Сметана' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment