Simple table looks somehting like:
key | name | addr
There are duplicate name address combos. I want the value of the key for the 'first' instance of rows that are either single occurances or multiple. So, if the data looks like....
1 | john | main st
2 | mary | 1st st
3 | peter | charles ave
4 | peter | charles ave
5 | john | main st
6 | sue | south ave
I want to extract keys 1,2,3 and 6.
I assume I'd do this with a query in a query but not an DB developer.
"Select distinct(name), addr from table" gives me the distinct names but not the key.
"Select distinct(name), addr, key from table" gives me everything because the key is always unique.
I think I want something like....
select min(a.key) from table a
where (select (distinct(a.name), a.addr from table a);
But this is wrong because I think I need to have the where = somthing else. But this doesn't work either...
select min(a.key) from table a
where (select (distinct(a.name), a.addr from table a) = select (distinct(b.name), b.addr from table b;
Pobably going down the wrong road altogether... so please help the novice again!
key | name | addr
There are duplicate name address combos. I want the value of the key for the 'first' instance of rows that are either single occurances or multiple. So, if the data looks like....
1 | john | main st
2 | mary | 1st st
3 | peter | charles ave
4 | peter | charles ave
5 | john | main st
6 | sue | south ave
I want to extract keys 1,2,3 and 6.
I assume I'd do this with a query in a query but not an DB developer.
"Select distinct(name), addr from table" gives me the distinct names but not the key.
"Select distinct(name), addr, key from table" gives me everything because the key is always unique.
I think I want something like....
select min(a.key) from table a
where (select (distinct(a.name), a.addr from table a);
But this is wrong because I think I need to have the where = somthing else. But this doesn't work either...
select min(a.key) from table a
where (select (distinct(a.name), a.addr from table a) = select (distinct(b.name), b.addr from table b;
Pobably going down the wrong road altogether... so please help the novice again!