vaibhavcoder Posted July 16, 2009 Share Posted July 16, 2009 Hello Folks, I am working on a auction site and need help in finding Unique low bid and Unique High Bid. Following is what I want. $0.01 255 $0.02 35 $0.03 1 ----->This is Unique Low Bid $0.04 18 $0.05 1 ----->This is Unique High Bid In my table I have following fields. item_id bid_rate user_id (and some more fields) I think these are the fields which I have to work. Please help me Thanks in advance Noddy Link to comment https://forums.phpfreaks.com/topic/166168-need-help-in-fatching-data/ Share on other sites More sharing options...
aschk Posted July 16, 2009 Share Posted July 16, 2009 Breaking it down for you: Count the number of entries by price SELECT price , COUNT(*) as 'num' FROM <insert table name here> GROUP BY price Find all UNIQUE bids SELECT price, COUNT(*)AS 'num' FROM <insert table name here> GROUP BY price HAVING num = 1 Select lowest minimum bid. SELECT MIN(price) FROM (SELECT price, COUNT(*)AS 'num' FROM <insert table name here> GROUP BY price HAVING num = 1) t1 Link to comment https://forums.phpfreaks.com/topic/166168-need-help-in-fatching-data/#findComment-876458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.