Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6773015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:37:01+00:00 2026-05-26T15:37:01+00:00

Currently I have written: SELECT IT_ID, SUBSTR (SYS_CONNECT_BY_PATH (grp , ‘,’), 2) GROUPS FROM

  • 0

Currently I have written:

SELECT IT_ID, SUBSTR (SYS_CONNECT_BY_PATH (grp , ','), 2) GROUPS
FROM (SELECT U.IT_ID, LAST_NAME, FIRST_NAME, GRP, ROW_NUMBER() OVER (ORDER BY U.IT_ID) rn, COUNT(*) OVER() cnt
FROM ECG_IT_USERS U
JOIN SECUREGROUPS G ON U.IT_ID = G.IT_ID)

START WITH rn = 1
CONNECT BY rn = PRIOR rn + 1

This returns:

IT_ID   GROUPS

afz23   ADMIN
afz23   ADMIN,QA
alv77   ADMIN,QA,USER
jaj23   ADMIN,QA,USER,USER
klo26   ADMIN,QA,USER,USER,PROD
klo26   ADMIN,QA,USER,USER,PROD,ADMIN
klo26   ADMIN,QA,USER,USER,PROD,ADMIN,QA
mav45   ADMIN,QA,USER,USER,PROD,ADMIN,QA,ADMIN

I can’t figure out how I can make it reset after a new user is encountered? It seems to be carrying over the previous groups, even if the user does not belong to them.

I need to see:

IT_ID   GROUPS

afz23   ADMIN,QA
alv77   USER
jaj23   USER
klo26   PROD,ADMIN,QA
mav45   ADMIN
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:37:01+00:00Added an answer on May 26, 2026 at 3:37 pm

    There are three things you need to do here.

    Firstly you need to add a partition to the row_number function so that it starts the numbering from 1 for each IT_ID. You also need to add the IT_ID column to the connect by so that it only takes rows with the same IT_ID value. Finally you need to group by the it_id column to remove the duplicate rows.

    The final query would be

    with ECG_IT_USERS as (
      select 'afz23' as it_id from dual union all
      select 'alv77' as it_id from dual union all
      select 'jaj23' as it_id from dual union all
      select 'klo26' as it_id from dual union all
      select 'mav45' as it_id from dual
    ),
    securegroups as (
      select 'afz23' as it_id, 'ADMIN' as grp from dual union all
      select 'afz23' as it_id, 'QA' as grp from dual union all
      select 'alv77' as it_id, 'USER' as grp from dual union all
      select 'jaj23' as it_id, 'USER' as grp from dual union all
      select 'klo26' as it_id, 'PROD' as grp from dual union all
      select 'klo26' as it_id, 'ADMIN' as grp from dual union all
      select 'klo26' as it_id, 'QA' as grp from dual union all
      select 'mav45' as it_id, 'ADMIN' as grp from dual
    )
    SELECT 
      IT_ID, 
      Max(SUBSTR (SYS_CONNECT_BY_PATH (grp , ','), 2)) GROUPS
    FROM (
      SELECT 
        U.IT_ID, 
    --    LAST_NAME, 
    --    BFIRST_NAME, 
        GRP, 
        ROW_NUMBER() OVER (partition by u.it_id ORDER BY U.IT_ID) rn, 
        COUNT(*) OVER() cnt
    FROM ECG_IT_USERS U
    JOIN SECUREGROUPS G ON (U.IT_ID = G.IT_ID))
    START WITH rn = 1
    CONNECT BY rn = PRIOR rn + 1 and it_id = prior it_id
    Group by it_id
    

    This produces the following output for me:

    IT_ID GROUPS
    ----- --------------------
    alv77 USER
    afz23 ADMIN,QA
    jaj23 USER
    mav45 ADMIN
    klo26 PROD,ADMIN,QA
    

    EDIT: I have added a with clause with some sample data and this runs for me without any problems although I did comment out the last_name and first_name columns since they don’t have an effect on the final query and I put some brackets around the join condition.

    Maybe it would pay to start with the query I’ve got above, check that it works for you initially and modify it as appropriate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, I have a table being read from like so: ps = con.prepareStatement(SELECT *
I have written a DQL query in Doctrine 2: $qb->select('r.position') ->from('\Entities\Races', 'r') ->where($qb->expr()->eq('r.entrantId', ':entrant_id'))
I have written code that opens 16 figures at once. Currently, they all open
I'm maintaining an in-house ORM written in C#, and it currently does not have
I have an application (currently written in Python as we iron out the specifics
I have a Delphi .CPL currently written with Delphi 7 which needs to update
I have a daemon app written in C and is currently running with no
I have recently inherited a website written in Classic ASP, and am currently trying
This is currently my MySQL UPDATE query, which is called from program written in
i am currently working on importing data from excel sheet to sql server.i have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.