Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grouping and Count of subset only
Message
 
 
À
18/06/2004 09:48:28
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00915008
Message ID:
00915025
Vues:
13
This message has been marked as the solution to the initial question of the thread.
Jay,

Try
SELECT myfield, ;
		IIF(myfield = "AAA", STR(0), STR(RECNO())) AS group ;
	FROM mytable ;
	INTO CURSOR crsTemp
SELECT myfield, COUNT(*) ;
	FROM crsTemp ;
	GROUP BY myfield, group
>Not sorting perse, but grouping. Let's say there is only 1 field and it contains either AAA or BBB. I want to group/count only the AAA records, but not the BBB records. One resulting record for all AAA with a count, but a one-for-one match on the BBB's. I think your SQL would give me:
>
>AAA 3
>BBB 2
>
>Where what I want is:
>
>AAA 3
>BBB 1
>BBB 1
>
>>Would this work? If not, can you explain sorting rules.
SELECT myfield, COUNT(*) ;
>>  FROM mytable;
>>  GROUP BY 1
>>>How would I do the following?
>>>
>>>Raw Data:
>>>
>>>AAA
>>>AAA
>>>BBB
>>>AAA
>>>BBB
>>>
>>>Result Desired:
>>>
>>>AAA 3
>>>BBB 1
>>>BBB 1
>>>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform