I think you're just looking for HAVING
:
select units, count(*)
from old_table
group by units
having count(*) > 2000
题
I'm trying to select all but the first 2000 rows using the code below, but I get the following error.
new_table = sqldf("select units, count(*)
from old_table
group by units
where count(*) > 2000")
Error in sqliteExecStatement(con, statement, bind.data) :
RS-DBI driver: (error in statement: near "where": syntax error)
解决方案
I think you're just looking for HAVING
:
select units, count(*)
from old_table
group by units
having count(*) > 2000
其他提示
Any where statement that references a value created in the current query needs to be embedded in a subquery.
Instead, you could use:
select * from
(
select units, count(*) as count
from old_table
group by units
)
where count > 2000