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 6785873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:10:44+00:00 2026-05-26T17:10:44+00:00

My SQL returns a list of user ID’s with their roles, the point is

  • 0

My SQL returns a list of user ID’s with their roles, the point is to concatenate all roles (groups) into one line. Currently, it returns everything, but I just need to return one entry per user, basically the entry per user with the largest rn (row number) for that user.

SELECT 
  IT_ID, 
  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

It returns:

IT_ID   GROUPS
afz23   ADMIN
afz23   ADMIN, QA
klf44   USER
klf44   USER, BUSINESS

I need to return

IT_ID   GROUPS
afz23   ADMIN, QA
klf44   USER, BUSINESS
  • 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-26T17:10:45+00:00Added an answer on May 26, 2026 at 5:10 pm

    This is a greatest-n-per-group problem. There’s a very comprehensive answer on the topic here: SQL Select only rows with Max Value on a Column

    Since time is now limited, I cannot work on your query. Not giving you the fish, but teaching how to fish.

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

Sidebar

Related Questions

I currently have a SQL query that returns a number of fields. I need
Question: I have an SQL function which returns a list of files now I
I have a sql database that stores some documents. A user can sign into
currently I'm using an OLE DB Source (SQL Server) to insert records into a
My PL/SQL procedure returns a cursor. It always returns data. I fetch (oci_fetch_assoc) it
I need a SQL query that returns ContactDate, SortName, City, ContactType, and Summary from
I have an Informix SQL query which returns a set of rows. It was
I have the following Sql Query that returns the type of results that I
I understand that SQL Server endpoint returns data using SOAP. Does anyone know if
i've got a SQL query which returns multiple rows, and i have : $data

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.