I want to be able to return a row of none, none, 0
if no row is returned from query. I have this SQL:
select first, last, count(address)
from employee
where last in ('james', 'smith', 'hankers')
group by first, last
union all
select 'none', 'none', 0
from dual
where not exists (select * from employee where last in ('james', 'smith', 'hankers'));
From DB, an entry for james
and smith
exists but no entry exists for hankers
.
But this query only returns for when an entry exists. Does not return none, none, 0
.
What am I doing wrong here?
EDIT: In this example, I am passing 3 hard coded values as last
, but I would like to know a work-around if we were passing the values in as a list parameter like so (:last)
through getJdbcTemplate.