Getting frequency counts from a table

Post Reply
Mr. Bigglesworth
Posts: 56
Joined: Fri Feb 16, 2001 6:54 pm

Getting frequency counts from a table

Post by Mr. Bigglesworth »

A client has asked me to see if we can run a query against one of our texis tables, to find the most frequent terms in the database.

We have an all-fields metamorph index on the table, and would likely be looking for the top 100 terms in the index, along with a count of how often they appear. Any chance you could sketch out a query we might run to accomplish this? thanks.
User avatar
Kai
Site Admin
Posts: 1272
Joined: Tue Apr 25, 2000 1:27 pm

Getting frequency counts from a table

Post by Kai »

Set indexaccess=1, and you can select from an index as if it were a table. For a Metamorph index, you'll get Word and Count fields, which are the indexed word and the count of rows that it occurs in. You could order by Count desc to get the top N rows (may take a few seconds as there is no "index" on the Count "field"). Eg.:

tsql -l 100 "set indexaccess=1; select * from mymetamorphindex order by Count desc"
Mr. Bigglesworth
Posts: 56
Joined: Fri Feb 16, 2001 6:54 pm

Getting frequency counts from a table

Post by Mr. Bigglesworth »

Sounds like just what we need-- thanks!
Post Reply