Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Character Counts 1

Status
Not open for further replies.

theif68

Technical User
Apr 3, 2005
39
US
Is there a way to get charater counts of a feild in a table.

So if I have a company feild I want to get a count on how many are under or over 50 charaters long.





 
SELECT YourTable.Company, Len([Company]) AS Expr1
FROM YourTable
WHERE (((Len([Company]))>50));
 
Thank you that is perfect. Is there a way to get counts of a field.

Say I run a query on the company field and i want a layout something like this. Where length is the number of characters and count is the number of records that are that length.

Lenth Count
10 1
20 5
30 3
 
SELECT Len([Company]) AS Length, Count(YourTable.Company) AS CountOfData
FROM YourTable
GROUP BY Len([Company]);
 
Can this be done in a Report? This way I can see counts on multiple fields instead of running multiple queries?

SELECT Len([COMPANY]) AS Length, Count(tblStandardLayout.COMPANY) AS CountOfData
FROM tblStandardLayout
GROUP BY Len([COMPANY]);

and

SELECT Len([TITLE]) AS Length, Count(tblStandardLayout.TITLE) AS CountOfData
FROM tblStandardLayout
GROUP BY Len([TITLE]);

 
You could do a UNION query with your two queries, though if you want to be able to keep your Company length counts and Title length counts separate, you will need to add an addition field to your queries.

SELECT 'COMPANY' as Type, Len([COMPANY]) AS Length, Count(tblStandardLayout.COMPANY) AS CountOfData
FROM tblStandardLayout
GROUP BY Len([COMPANY])

UNION

SELECT 'Title' as Type, Len([TITLE]) AS Length, Count(tblStandardLayout.TITLE) AS CountOfData
FROM tblStandardLayout
GROUP BY Len([TITLE])

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top