octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SQL like question.


From: John W. Eaton
Subject: SQL like question.
Date: Fri, 05 Sep 2008 14:00:24 -0400

On  5-Sep-2008, Levente Torok wrote:

| Hi All,
| 
| Last time Jaroslav helped me a lot with a little trick but this time I am a 
little bit jammed.
| 
| I would like to get solved a simple thing again and I cannot find a fast 
solution to it.
| 
| I have a matrix as
| m = [
| 1 2; 
| 1 1; 
| 2 3; 
| 2 4 ];
| 
| I would like to make a unique of its first column but I would like to have 
the minimum of second column nearby.
| So it would look like:
| [ 1 1; 
|   2 3 ]
| 
| This is something like SELECT first_col, min(second_col) FROM m GROUP BY 
first_col;
| 
| If I can be sure that the second nargout of unique() always points always to 
the last index of the same 
| selector item then the solution would be something like:
| 
| m = sort( m, 'descend' );
| [u,i,j] = unique( m(:,1) );
| m(i,:)
| 
| but 
| 1) can I be sure about it?
| 2) what if I would want to make aggregate functions such as avg()  or var()

I think the help list might be a better place for questions like
this.  I'd really like to keep discussions on the maintainers list
focused on development issues.

Thanks,

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]