Jump to content

Need help in fatching data


vaibhavcoder

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.