Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select Count Distinct
Message
De
24/09/2014 19:51:51
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Select Count Distinct
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01608230
Message ID:
01608230
Vues:
54
Having a senior moment.........

I have a table with the following data
OWNER          DEPT
1                          A
1                          A
1                          A
2                          A
2                          B
3                          B
3                          B
3                          B
3                          C
and I need to get a count of how many departments there are for each owner
OWNER       NUM_DEPTS
1                        1     (A)
2                        2     (A/B)
3                        2     (B/C)
In VFP 9 I would do something like
SELECT aa.owner,COUNT(*) AS num_depts FROM (select DISTINCT owner,dept FROM myCursor) aa GROUP BY 1
but I'm having trouble remembering how to do this in one statement in VFP 8

All replies welcome.

Thanks............Rich
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform