I have a table in a database that contains two columns username and bids.I want to select the unique and lowest value from the bids column.I tried using SELECT DISTINCT and then limiting with one,it shows the lowest value but the value is repeated a number of times in the column.What i want is the unique lowest value.Please help me out.

Recommended Answers

All 4 Replies

where bid value is stored, what is ur table structure

#   Name      Type          Collation       
 1  username  varchar(20)   latin1_swedish_ci        
 2  bid       float         No  

    there are two columns username and bids,i wanna select the unique and lowest from the bids column
select username, bid from tablename a inner join 
     select min(b.bid) minbid from (select bid,count(*) cnt from tablename group by bid having     count(*)=1 )b 
) c on a.bid=c.minbid

It works!!Thank you so much urtrivedi.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.