Subject Help with DISTINCT predicate
Author sasidhardoc
I have a stored procedure as follows:
BEGIN
/* Procedure body */
for
SELECT VisitICD_ID, VisitICD_Description FROM CHRT_VisitICD
WHERE Patient_ID = :Patient_ID_IN
AND CHRT_VisitICD.VisitICD_Chronic = 0 AND
CHRT_VisitICD.VisitICD_WasDeleted IS NULL

INTO
:VISITICD_ID,
:VISITICD_DESCRIPTION

do
SUSPEND;
END

VisitICD_ID is a primary key field that uses a generator. An example
output of the above SP is:
--------
100 Asthma
102 Heart Failure
103 Asthma
104 Lung Cancer
--------
I want to remove the duplicate entry VisitICD_Description = "Asthma"
so that the ouput looks like this:
--------
100 Asthma
102 Heart Failure
104 Lung Cancer
--------
The problem with using DISTINCT is that it makes no difference since
the primary key field is always unique. My application requires both
fields.
Is there an alternate way - perhaps using temporary tables? TIA