Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL sum syntax
Message
 
 
À
14/09/2011 16:06:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01523537
Message ID:
01523540
Vues:
66
This message has been marked as the solution to the initial question of the thread.
>I have a simple payroll table with multiple entries for each employee. Something like;
>
>Empno empname gross
>1 jack $500
>1 jack $500
>2 Jill $100
>2 Jill $100
>2 Jill $100
>
>etc...
>
>I'd like to create a table like this;
>Empno empname gross
>1 jack $1000
>2 jill $300
>
>where the gross has been summed for each employee.
>
>In the past I have done this with scan/endscan and calculate sum , old method.
>
>Can someone show me an example of a simpler method, I suspect SQL select.
>
>Thanks, I apologize for being so elementary but my vfp usage has been almost nihl for the past year.
>
>Steve

You just need to add GROUP BY and SUM:
Select EmpNo, EmpName, SUM(Gross) as [Total Gross]
From dbo.EmployeeIncome
GROUP BY EmpNo, EmpName
ORDER BY EmpNo
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform