I have a dataset with an ID and value. For each value I want to get its corresponding frequency in the dataset. What is the most efficient pure SQL query-based solution? (that is not using java etc…) Or would it be more efficient to use Java with SQL?
- I am using Derby SQL
This is my previous solution for this problem
- Get all distinct values in a new table and add a frequency column
- Write Java code to iterate through all distinct values in this new table and run a counting query against the original dataset
I would really like to avoid the extra Java code…
All help is appreciated!
1 Answer