Click to See Complete Forum and Search --> : duplict fields


joby
02-14-2008, 02:41 AM
Please see the query

select distinct city,numb from res where id=10 and _date='2008-05-02' order by numb,city;

out put is

city | numb
---------------+---------------
DELHI | 10
DELHI | 11
AGRA | 12

I want to avoid duplicate cities .(DELHI)

That is the out put will be

city |
------------------
DELHI |
AGRA |

Make sure DELHI will be in the first record . because its numb is less than that of AGRA.

How to rewrite the query.

chazzy
02-14-2008, 11:53 AM
what about...

select city,min(numb) as numb from res where id=10 and _date='2008-05-02' group by city order by numb,city;


?

joby
02-14-2008, 11:27 PM
Thank u. It is working fine.
but I want to display only cites.

chazzy
02-15-2008, 08:44 AM
you always display exactly what the query returns?

anyways, you could just drop the column in the column clause...