0

My database schema is like following

table - X has following 3 columns docid(document id), terms(terms in document), count(number of terms of occurence of the term for specific docid)

docid
terms
count

How to extract the information as for the following The number of docid where sum of total words is more than 300 including duplicate words.

Surjya Narayana Padhi
  • 7,741
  • 25
  • 81
  • 130

2 Answers2

5

Like this:

SELECT term, SUM(count) AS Totalwords
FROM tablex
GROUP BY  term
HAVING SUM(count) > 300


Update: Try this:

SELECT docid, SUM(count)
FROM tablex
GROUP BY docid
HAVING SUM(count) > 300;

See it in action here:

Mahmoud Gamal
  • 78,257
  • 17
  • 139
  • 164
1

You can use

SELECT docid,SUM(COUNT) AS CNT
FROM X
GROUP BY docid
HAVING SUM(count) > 300
Rohan
  • 3,068
  • 1
  • 20
  • 26