I have two select statements that I need to blend together. They are actually the same tables but with different criteria. I have tried to do a nested select but don't really know what I'm doing and also the union. The union works but I get to many records and it only seems to be reporting from the last select statement.
In this system is is possible to have comments but not have the comment flag turned on yet (internal comments only) so I need a report that will list all the records that have comments and if there are comments but the comment flag = "n" then return only 1 line not all records.
What I expect on output is:
ppn submittal # MtgDate Yflag Comment
1 1 1/1/07 Y comment 1
1 1 1/1/07 Y comment 2
2 1 10/1/07 N dEFAULT comment
3 1 10/1/07 Y COMMENT 1
Where ppn Number 2 actually could have multiple comments or none. Either way, I only one to return the one record.
Thanks
lhuffst
In this system is is possible to have comments but not have the comment flag turned on yet (internal comments only) so I need a report that will list all the records that have comments and if there are comments but the comment flag = "n" then return only 1 line not all records.
Code:
the code I tried is:
Select
a.ppn,
a.submittal_number,
To_Char(a.meeting_date,'YY/MM/DD') as MtgDate,
a.comment_flag as YFlag,
Substr(b.comment_desc,1,20)
FROM ParkNPlan a, PPN_Comment b
Where a.ppn = b.ppn and
a.submittal_number = b.submittal_number AND
a.comment_flag = 'Y'
union all
Select DISTINCT
a.ppn,
a.submittal_number,
To_Char(a.meeting_date,'YY/MM/DD') as MtgDate,
a.comment_flag as NFlag,
Substr(b.comment_desc,1,20)
FROM ParkNPlan a, PPN_Comment b
Where a.comment_flag = 'N'
What I expect on output is:
ppn submittal # MtgDate Yflag Comment
1 1 1/1/07 Y comment 1
1 1 1/1/07 Y comment 2
2 1 10/1/07 N dEFAULT comment
3 1 10/1/07 Y COMMENT 1
Where ppn Number 2 actually could have multiple comments or none. Either way, I only one to return the one record.
Thanks
lhuffst