Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

NVL to return 0 even if no rows

Ryansun-OracleJun 18 2014 — edited Jun 18 2014

11g,

  Hi there,

Have an issue that I am struggling with

I have a query which returns counts based on some condition

{code}

select Type , nvl(cnt,0) from (

select 'type' Type, count(t.status) cnt from table1 t

where active = 'Y'

and code = 1

group by 'type')

{code}

However, if no records exist, I get no data found What I want as the output is

Type        Cnt

type         0

So if no data exists, still show me type and 0

Am I doing anything wrong?

Thanks,

ryan

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 16 2014
Added on Jun 18 2014
7 comments
20,049 views