简体   繁体   中英

SQL : get row with MIN(date)

I want to get the row with the MIN(c.date_debut) , I did this, but I get a

Invalid use of group function

select distinct num_facture, s.nom, f.montant_ht, a.regle_client, a.date_reglement_effectif_client, a.type_ligne
from facture f, mission m, activite a, commande c , societe_client s
where f.activite_id = a.id and a.mission_id = m.id and m.id = c.mission_id 
and m.client_id = s.id
and min(c.date_debut)
and a.type_ligne in  ('Forfait','Presta')
and a.annee_id>=4
and s.nom like '%capgemini%'
group by num_facture, s.nom, f.montant_ht, a.regle_client, a.date_reglement_effectif_client, a.type_ligne

If anyone can help me on this...

Use order by and limit :

select . . .
from . . .
order by date asc
limit 1;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM