2

I'm trying to understand COUNT(*), and therefore I created a testing query:

 SELECT COUNT(*)
 WHERE COUNT(UITLENINGEN.LLNR) >= 30;

When I click Execute, I get the following error:

Syntax error (operator missing) in query-expression COUNT(*) WHERE COUNT(UITLENINGEN.LLNR) >= 30.

What am I doing wrong?

3
  • Where is the table name? Commented Nov 27, 2012 at 8:56
  • The table name is UITLENINGEN, I put it in between the COUNT brackets. Commented Nov 27, 2012 at 8:57
  • SELECT COUNT(*) FROM UITLENINGEN WHERE COUNT(UITLENINGEN.LLNR) >= 30; Commented Nov 27, 2012 at 8:58

5 Answers 5

1

Try this

SELECT COUNT(*) FROM UITLENINGEN GROUP BY LLNR HAVING COUNT(UITLENINGEN.LLNR) >= 30;
Sign up to request clarification or add additional context in comments.

2 Comments

I get the following error (translated from Dutch): You cannot use a statistic function in a WHERE-component (COUNT(UITLENINGEN.LLNR) >= 30). Should I perhaps try HAVING?
select count(*) from UITLENINGEN having count(UITLENINGEN.LLNR) >= 30;
1

I don't understand what you're trying to do. The query below is based on a table which includes a field named category_id. And it uses GROUP BY category_id to count the number of rows within each such group. The HAVING clause limits the result set to only those groups whose count is at least 30.

SELECT category_id, COUNT(*)
FROM YourTable
GROUP BY category_id
HAVING COUNT(*) >= 30;

If that is nothing like what you're trying to accomplish, please give us more detailed information so we may better understand your situation. A brief set of sample data, and the output you want based on that sample, would help tremendously.

Comments

0

You have not specified the table from which the data should be retrieved. Try the following

 SELECT COUNT(*) from tableName
    WHERE COUNT(UITLENINGEN.LLNR) >= 30;

Comments

0

Add your table name to the query.

SELECT COUNT(*) FROM UITLENINGEN WHERE COUNT(UITLENINGEN.LLNR) >= 30;

2 Comments

I get the following error (translated from Dutch): You cannot use a statistic function in a WHERE-component (COUNT(UITLENINGEN.LLNR) >= 30). Should I perhaps try HAVING?
@Tanno what exactly do you want to do?
0

Please, add table name and use having statement where aggregation funcion required. E.g.:

select count(*) 
from UITLENINGEN
having count(UITLENINGEN.LLNR) >= 30;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.