Sign in to follow this  

[web] SQL query: adding multiple values from different entries and returning the sum

This topic is 3597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I have a table that stores the frequency of words from a particular text file. It has the values (filename, word, frequency), to correspond each word to the file it is found in, and the number of times it occurs in that file. I want a query that can take *multiple words*, and will return the *total* frequency of all those words in a given file. For example, if I search for "hello" and "how", and file1 contains "hello" 3 times, and "how" 2 times, it will return <file1, 5> and so on for all files in the database. I'm not really sure how to construct this SQL query in a way that will automatically add the values together. Is it possible in a single query? I also have to sort the results by count and then lexocographically, but I think I can handle that much...

Share this post


Link to post
Share on other sites

This topic is 3597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this