mysql: name n rows, nonetheless wholly unparalleled values column
given information set:
id name city birthyear
1 egon spengler new york 1957
2 mac taylor new york 1955
3 sarah connor los angeles 1959
4 jean-luc picard la barre 2305
5 ellen ripley nostromo 2092
6 james t. kirk riverside 2233
7 henry jones chicago 1899
i need 3 oldest persons, nonetheless wholly each city.
if only 3 oldest, be...
- henry jones / chicago
- mac taylor / new york
- egon spengler / new york
however given both egon spengler mac taylor located new york, egon spengler dump out unbroken (sarah connor / los angeles) instead.
any glorious solutions?
update:
currently mutation pconroy best/fastest solution:
select p.*, count(*) ct
p
join (select min(birthyear) birthyear
organisation city) p2 p2.birthyear = p.birthyear
organisation p.city
method p.birthyear asc
border 10;
his uncanny query "in" extremly delayed large datasets (aborted after 5 minutes), nonetheless relocating subquery join speed adult lot. took 0.15 seconds approx. 1 mio rows exam environment. i have an index "city, birthyear" second only "birthyear".
note: associated to...
Comments
Post a Comment