Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem to make a report
Message
 
 
À
01/06/2009 15:15:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01403052
Message ID:
01403055
Vues:
58
>ok i have 3 table in my databases. TB_ACCOUNT(containt all the customer account),TB_INVOICE(containt all the customer invoices),TB_SALESMAN(containt all my salesman). In the tb_account in a field name tr_idsalemans. and in the invoice i have a field name tr_idaccount. so i want to be able when i select a salesment to have all of the account that he have and have the last invoice amount that the customer ordered. it is possible to make it in one sql statement or more. how can i do it thanks

Try
select S.*, AC.*, In.* from Tb_Salesman S LEFT JOIN TB_Account Ac on S.tr_idsalemans = Ac.tr_idsalemans 
LEFT JOIN 
(select tr_idaccount, Amount from TB_INVOICE Inv1 
INNER JOIN (select tr_idaccount, max(Inv_Date) as MaxInDate) MaxDates ON 
Inv1.tr_idaccount = MaxDates.tr_idaccount and Inv1.Date = MaxDates.MaxInDate) In
on Ac.tr_idaccount =In.tr_idaccount
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform