Вопрос

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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top