Search code examples
sqlderbyjavadb

Why Count function is not working on this sub query?


This:

enter image description here

outputs following:

enter image description here

Now I want to apply count function on above table, for that I executed following query.

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

And got this error:

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

Note: I am using Java DB


Solution

  • Sub query usually needs an alias, try

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