Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Counting Strings in a Field
Message
De
05/03/2009 12:24:13
John White
Micro-Oriented Software Techniques, Inc.
Phoenix, Arizona, États-Unis
 
 
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
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01385278
Message ID:
01385887
Vues:
30
>>>I have a table with a field that contains one or more strings separtated by commas. I need a SPT that can count the number of strings. The table is a db2 file.
>>
>>Maybe I'm missing something but wouldn't this work:
>>
>>
>>Select PK, iif(empty(myfield),0,occurs(',',myfield)+1) as stringcnt from mytable group by 1 into cursor mycursor
>>calculate sum(stringcnt) to totalcnt
>>
>>
>>to get the number of strings in each record and a total count for the file. Of course, if all you need is a total count for the file:
>>
>>
>>Select SUM(iif(empty(myfield),0,occurs(',',myfield)+1)) as stringcnt from mytable into cursor mycursor
>>
>
>Except for the fact that there is no native OCCURS function in SQL Server and I'm not sure about DB2.

That would be what I was missing... TSQL vs Fox syntax.
John White [MOST]
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform