I'm using SQL 2008 to query using inner join:
SELECT t2.intencion_id,t2.numpago,t3.orden,t2.importe
,SUM([importeaplicado]) AS importeaplicado
,t3.intfinanciamiento_interes
,t1.[estatus] FROM [APLICACIONES] as t1
inner join movcargos as t2 on t1.idmovcargo=t2.idmovcargo
inner join intenciones_financiamiento as t3 on (t2.intencion_id=t3.intencion_id and t2.numpago=t3.intFinanciamiento_pagoNumero) where t2.idtipomovimiento=1 and t1.estatus='A' GROUP BY t2.intencion_id,numpago,importe,t1.estatus,intfinanciamiento_interes,t3.orden order by intencion_id,numpago,orden desc
among the columns that this query returns, there are 3 that are repetitive series: intencion_id, numpago and orden but I want you to show the records of all the intencion_id, all the numpago but only the higher order
How can I do this filtering?