Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select-sql statement
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00614246
Message ID:
00614314
Views:
27
>>>>Hi All,
>>>> Is there a way to craft a select statement to list what is in a field and how many times what is in the field repeat?
>>>>Thanks,
>>>
SELECT field1, COUNT(*) FROM mytable GROUP BY 1
>>
>>Thanks Sergey, you are the greatest.
>
>Note, that starting with VFP3, COUNT(myField) tells you the number of records in your group with a non-NULL value for myField, while COUNT(*) will bring the number of records in the group. YMMV.

In case if there're nulls in the field1 in some records
SELECT field1, COUNT(field1) FROM mytable GROUP BY 1
would produce incorrect result because the count for group field1=Null would show 0 regardless of how many records are in this group.
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform