Jose Gomez-Dans escribió:
> Por ejemplo, supongamos que hay 5 filas:
> 010600999 ; 105
> 010600998 ; 110
> 010599000 ; 100
> 011000000 ; 50
> 011999999 ; 40
>
> la salida debería de ser (considerando la media, por ejemplo)
> 010 ; 105
> 011 ; 45.
> Una forma sería la de usar SUBSTRING,
select substring(..., col1), avg(col2)
from tabla
group by substring(..., col1);
--
Alvaro Herrera http://www.amazon.com/gp/registry/DXLWNGRJD34J
"On the other flipper, one wrong move and we're Fatal Exceptions"
(T.U.X.: Term Unit X - http://www.thelinuxreview.com/TUX/)