1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| SELECT DISTINCT bilans.id_bilan, personnes.id_personne, MAX(rendez_vous.fin_rendez_vous),
nom_personne, nom_prescripteur, interrompu_bilan, raison_interruption_bilan
FROM personnes, bilans, commandes, conventions, prescripteurs, rendez_vous
WHERE personnes.id_personne=bilans.id_personne
AND ((commandes.id_commande=bilans.id_commande AND commandes.id_prescripteur=prescripteurs.id_prescripteur)
OR (conventions.id_convention=bilans.id_convention AND conventions.id_prescripteur=prescripteurs.id_prescripteur
AND conventions.facture_convention='oui'))
AND (bilans.interrompu_bilan='oui' OR bilans.termine_bilan='oui')
AND bilans.facture_bilan <>'oui'
AND rendez_vous.id_bilan=bilans.id_bilan
GROUP BY bilans.id_bilan ORDER BY rendez_vous.fin_rendez_vous, nom_prescripteur, nom_personne |
Partager