2015-05-30 54 views
1

此:为什么Count函数不适用于这个子查询?

enter image description here

输出如下:

enter image description here

现在我想在上面的表格申请计数功能,对于我执行下面的查询。

select count(date1) from (
select date1 from tmp where 
current_date > date1 
); 

而得到这个错误:

Error code 20000, SQL state 42X01: Syntax error: Encountered "" at line 4, column 1.

注:我使用的Java DB

+0

尝试使用count(*) –

+0

@JoaozitoPolo仍然得到同样的错误 – user4913383

回答

3

子查询通常需要一个别名,尝试

select count(date1) from (
    select date1 from tmp where 
    current_date > date1 
) a ; 
1

我不知道JavaDB之外,但要尽量让你的嵌套查询语句的别名:

从(选择date1 from tmp where current_date> date1)选择count(*)cnt a

相关问题