CREATE OR REPLACE FORCE VIEW email_parent_report_v
(report_id   
,report_name 
,report_title
,printable   
,emailable   
,child_exists)
AS
SELECT  r.report_id    AS report_id   
       ,r.report_name  AS report_name 
       ,r.report_title AS report_title
       ,r.printable    AS printable   
       ,r.emailable    AS emailable   
       ,'N'            AS child_exists
  FROM reports r
 WHERE parent_report_id IS NULL
   AND NOT EXISTS (SELECT 'X'
                     FROM reports r1
                    WHERE r1.parent_report_id = r.report_id)
UNION ALL
SELECT  r.report_id    AS report_id   
       ,r.report_name  AS report_name 
       ,r.report_title AS report_title
       ,r.printable    AS printable   
       ,r.emailable    AS emailable   
       ,'Y'            AS child_exists
  FROM reports r
 WHERE parent_report_id IS NULL
   AND EXISTS (SELECT 'X'
                     FROM reports r1
                    WHERE r1.parent_report_id = r.report_id);
                     