0
votes

J'ai besoin du dernier enregistrement de la table SQL

J'ai une table comme suivi de xxx

et j'ai besoin du dernier enregistrement de cust_id résultat similaire à xxx

et j'ai essayé la requête comme celle-ci xxx


1 commentaires

Bien sûr, vous avez fait vos recherches, s'il vous plaît partagez votre tentative et où vous êtes coincé.


3 Réponses :


1
votes

Vous pouvez essayer d'utiliser row_number () xxx


0 commentaires

0
votes

Utilisez Row_Number () CODE>

 select t1.* from table t1
  where t1.Amount= (select max(Amount) from table t2 
                     where t1.cust_id=t2.cust_id)


0 commentaires

0
votes

Vous pouvez également essayer comme suit

select id,cust_id,amount
from YourTable t1
where id =(select max(t2.id) from YourTable  t2 where t2.Cust_ID=t1.Cust_ID)
order by id


0 commentaires