haibec Posted August 29, 2006 Share Posted August 29, 2006 Hi Guys!I have two table Member includes : ID , Name and Product includes ID,ProductID,Name,Price . Both table related by ID . Make stuation : with a Member only buy maximum are 3 product . I want query exact amount member have Product and Price >=500$ Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 29, 2006 Share Posted August 29, 2006 I don't understand, could you rephrase that? Link to comment Share on other sites More sharing options...
haibec Posted August 29, 2006 Author Share Posted August 29, 2006 I don't understand, could you rephrase that?Example :User 1 buy three product : product1 have Price >=500$,product2 have Price >=500$,product3 have Price >=500$User 2 buy two product : product3 have Price >=500$,product4User 3 buy product5 have Price >=500$User 4 not buyI want select : How many member buy at least a Product have Price >=500$ Link to comment Share on other sites More sharing options...
justsomeguy Posted August 29, 2006 Share Posted August 29, 2006 Try this:SELECT COUNT(DISTINCT(users.ID)) AS num FROM users, orders WHERE users.ID=orders.ID AND orders.ID>=500The field you will get back will be called "num", and should contain the number of users who have bought at least one product with a price at least 500. Link to comment Share on other sites More sharing options...
haibec Posted August 30, 2006 Author Share Posted August 30, 2006 Try this:SELECT COUNT(DISTINCT(users.ID)) AS num FROM users, orders WHERE users.ID=orders.ID AND orders.ID>=500The field you will get back will be called "num", and should contain the number of users who have bought at least one product with a price at least 500.Yeahhhhh!Thank you very much! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now