Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trouble getting result from join query
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Trouble getting result from join query
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 7
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01545667
Message ID:
01545667
Vues:
81
Hi UT,

I am having trouble getting result from a join query. I have 2 tables that contain following information:
Table 1:  Person

personid       lname
1              Tom
2              Stacy


Table 2:   Pinfo

personid            workhour
1                      3
1                      2
1                      3
2                      1
2                      5
2                      4
I am writng following query where I need a count from Person table and a sum from Pinfo table. Here is my query:
SELECT count(person.lname), sum(pinfo.workhour) FROM Person INNER JOIN ;
Pinfo ON person.personid = pinfo.personid WHERE person.personid = 1 ;
or person.personid = 2 
The result I am getting is 6 for the person.lname count and 18 for the sum of workhour. It seems like my person.lname count is count the number of records in Pinfo table. What I really need is a count of 2 for number of person records found and a sum of 18 for the workhours found. Can someone help me figure out why my count for person.lname is wrong and how I should formulate this query.

thanks
Nick
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform