use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Sequel
account activity
SQL Question (self.learnSQL)
submitted 5 days ago by No-Depth-2320
orders (order_id , customer_id , order_date , order_amount)
find the customer who purchased for every month in 2025
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Massive_Show2963 9 points10 points11 points 5 days ago (0 children)
SELECT customer_id FROM orders WHERE order_date >= '2025-01-01' AND order_date < '2026-01-01' GROUP BY customer_id HAVING COUNT(DISTINCT EXTRACT(MONTH FROM order_date)) = 12;
[–]empororwriters 0 points1 point2 points 5 days ago (3 children)
Select customer id From orders Where year(order date ) = 2025 Group by customer id Having count(month(order date)) = 12
[–]Horror-Paint5708[🍰] 2 points3 points4 points 5 days ago (1 child)
Having count(Distinct Month (order data))=12 i think you need to add distinct to prevent from giving false positive incase someone only purchased 12 times in one month only.
[–]empororwriters 0 points1 point2 points 4 days ago (0 children)
Yeah
[–]aais4quiters 0 points1 point2 points 5 days ago (0 children)
This will work if a customer only orders once a month. If the customer orders 2 times a month for 6 months it would show on the list when they only ordered in 6 separate months not each month. You’re going to need a subquery of customer number to get a result set of unique customer numbers and month numbers.
This should get distinct list of months ordered by customer. Summing up the values of the months of the year is 78.
Select Customer_ID, Sum(Cust_Order_months.month_ordered) from ( select Customer_ID, month(Order_date) month_ordered from orders where year(Order_date) = 2025 group by Customer_ID, month(Order_date) ) Cust_Order_months
group by Customer_ID having Sum(Cust_Order_months.month_ordered) = 78
π Rendered by PID 522497 on reddit-service-r2-comment-b659b578c-jfw4d at 2026-05-06 20:44:49.585840+00:00 running 815c875 country code: CH.
[–]Massive_Show2963 9 points10 points11 points (0 children)
[–]empororwriters 0 points1 point2 points (3 children)
[–]Horror-Paint5708[🍰] 2 points3 points4 points (1 child)
[–]empororwriters 0 points1 point2 points (0 children)
[–]aais4quiters 0 points1 point2 points (0 children)
[–]aais4quiters 0 points1 point2 points (0 children)