Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to omit first and last comma when using sys_connect_by_path function in oracle?
    primarykey
    data
    text
    <p>so this is my table--</p> <pre><code>create table student ( stu_id int, s_name nvarchar(max), s_subject nvarchar(max), marks varchar(20) ) </code></pre> <p>and the values are</p> <pre><code>insert into student values(123,'pammy','English','88'); insert into student values(123,'pammy','Maths','56'); insert into student values(124,'watts','Biology','98'); insert into student values(125,'Tom','Physics','90'); insert into student values(125,'Tom','Computer','95'); insert into student values(125,'Tom','ED','75'); </code></pre> <p>so what i have done is extracted data which occurred thrice. and then concatenated the string values using sys_connect_by_path. My code is--</p> <pre><code> select stu_id,s_name, max(sys_connect_by_path(s_subject, ', ' )) s_subject, max(sys_connect_by_path(marks, ', ' )) marks from (select stu_id,s_name,s_subject,marks, row_number() over (partition by stu_id order by s_subject) rn from student ) start with rn = 1 connect by prior rn = rn-1 and prior stu_id = stu_id group by stu_id,s_name having stu_id in ( select stu_id from student group by stu_id having count(stu_id) &gt;3 ) order by stu_id,s_name </code></pre> <p>output of my code is --</p> <pre><code>stu_id s_name s_subject marks 125 Tom ,Physics,Computer,ED, ,90,95,75, </code></pre> <p>the code is working perfectly, but I am using comma as seprator, and i just want to get rid of comma at the start and at the end. in s_subject column.</p> <p>what I wants is </p> <p>stu_id s_name s_subject marks 125 Tom Physics,Computer,ED 90,95,75</p> <p>I tried trim function, but i could not get success. I can substr the sys connect by path if my data is fixed, but here data is not fixed. So pls help..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload