question

eddd83 avatar image
eddd83 asked

how to include multiple conditions in a single query

Here's a hypothetical question Rule to determine Nike shoes buyer: 9 purchase days or less must have 100% Nike shoe purchases. At 10+ purchase days, if 95%or more purchase days are Nike, then buyer is a Nike buyer. Examples of Nike Buyer ---------------------- 1) Joe buys Nike shoes for 8 days. Only buys Nike. 2) Troy buys Nike shoes for 100 days. 95 of those days, he bought Nike shoes. Examples of **non**-Nike Buyer ------------------------------ 3) Bill buys Nike shoes for 7 days, but on two days, he also bought Adidas shoes. 4) John buys Nike shoes for 100 days. 94 of those days, he bought Nike shoes. Tables: ------- Nike Adidas Fields/Columns: --------------- UserID (both tables) date of purchase (both tables) Nike purchase amount Adidas purchase amount Is there any way of incorporating all of the above into a single query? When I try using a case statement, I can't seem to use formulas after "WHEN"
sql
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

JohnM avatar image JohnM commented ·
Can you post what you've tried so far? Is this on SQL Server or some other RDBMS platform?
0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.