Multiple results in a single record - Oracle

Asked

Viewed 883 times

3

I have the following situation: I have a select where I return that the patient TEST passed the clinic ABC, and performed procedure 01 and 02, however in the result of query he returns to me like this bold text:

Patient | Clinical | Procedure |

Test | ABC | 01 |
Test | ABC | 02 |

But I needed the following result:

Patient | Clinical | Procedure |

Test | ABC | 01 - 02 |

I’d like some help.

1 answer

4


  • Thanks for the tip, but in my case I’m not able to do group, it’s getting like this: test | patient | exam 1, exam 2 test | patient | exam 2, exam 1

  • Diogo, it is strange this behavior, because listagg will follow the grouping that is in the "group by", and the order within the listagg. There may be some other field outside the "group by" that causes this. Do not want to put the select you are using, the table structure and about 10 records as an example for analysis?

  • That worked, I re-checked the query and grouped, I only had a doubt, when I try to extract all records found, giving oracle error-01489, Would know told me if there is limit to concatenate ? Thank you for your help @fabioceron.

  • This limit is given by the bank, which considers this no select operation to be a varchar2 column with a limit of 4000 characters. If you, at runtime, change this column to clob, for example, does not give this error, but then you will have to treat the clob column. First, check that the requirements cannot be more restricted (shorter time interval, shorter clinic/patient interval, etc).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.