what I need to test for on my table is if there are rows for a given user id and order id on two separate days (DATETIME field for a timestamp).
I’m pretty sure I’d need a having clause and that’s why I’m here…that frightens me terribly.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Having shouldn’t scare you, it is just a “Where” on an aggregated field:
That’ll give you all the Users that have multiple orders.
will give you the count if there are multiple records for the user id in @UserID and null if not.
will return a 1 if there are multiple records for the User, 0 if not.
Update: Didn’t realize that you could have multiple orders per day. This query will do what you want: