Reputation: 15
I have query where there is COUNT(1) in select statement. I want to know what does it return. COUNT(*) will return the number of rows but COUNT(1) I have no idea. I tried to execute one statement in DB2 but got error saying COLUMN OR EXPRESSION IN THE SELECT LIST IS NOT VALID.
Upvotes: 1
Views: 1558
Reputation: 23793
Post your SQL statement.
I suspect you have something like
select customer, count(1)
from salesHistory
In which case, DB2 isn't complaining about count(1)
which is perfectly valid; but it's complaining because you've got a aggregate function in the select list along with a non-aggregate column. In order to do that, you have to include a GROUP BY
clause.
select customer, count(1)
from salesHistory
group by customer
Upvotes: 1