Good I have a query where I have to make a select that gives me the maximum of one column depending on the maximum of another, I explain myself better with the following example
my table would be like this:
|nrocon|ordren|ordamp|
| 1 | 1 | 0 |
| 1 | 1 | 1 |
| 1 | 1 | 2 |
| 1 | 1 | 3 |
| 1 | 2 | 0 |
| 1 | 2 | 1 |
| 1 | 2 | 2 |
| 1 | 3 | 0 |
| 1 | 3 | 1 |
| 2 | 1 | 0 |
| 2 | 2 | 0 |
| 2 | 2 | 1 |
| 2 | 2 | 2 |
| 3 | 1 | 0 |
| 3 | 1 | 1 |
So, what I would need is that when doing the selection, give me the following information:
|nrocon|ordren|ordamp|
| 1 | 3 | 1 |
| 2 | 2 | 2 |
| 3 | 1 | 1 |
In other words, it would be the maximum ordamp of the maximum ordren of each node.
If anyone could give me a hand how I could do it, I'd appreciate it
Try the following:
select NroCon, max(ordren), max(ordamp) from Polizas
group by NroCon
But with this the table is like this:
|nrocon|ordren|ordamp|
| 1 | 3 | 3 |
| 2 | 2 | 2 |
| 3 | 1 | 1 |
in this example the difference would be in the nrocon 1, that the ordamp puts 3 instead of 1 which is the maximum of the ordren 3. I hope with this I understand better