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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:27:59+00:00 2026-06-01T21:27:59+00:00

New to SQL and have a query pulling some data with a number of

  • 0

New to SQL and have a query pulling some data with a number of joins across a number of tables.

Sample Data:

PERSON_NAME FUNCTION_NAME  FUNCTION_ID  FUNCTION_GROUP

Bob         View Result    1            Editor
Bob         Edit Result    4            Editor
Bob         Delete Result  3            Editor
Bob         Email Result   8            Editor
Mary        Print Letter   45           Admin
Mary        Grant Access   37           Admin

Functions have IDs, and function_groups have numerous functions. I want to query the data so instead of how it appears similar to the example above, it would look like:

PERSON_NAME FUNCTION_NAME                             FUNCTION_ID     FUNCTION_GROUP

Bob         View Result,Edit Result, Delete Result   1,4,3,8          Editor
Mary        Print Letter,Grant Access                 45,37           Admin

“Bob belongs to Editor, editor has the following functions” as one result, rather than the initial example, where multiple line after line is returned.

Am I correct in thinking the unique or distinct keywords can help me?
Thanks!

EDIT: Now with code

select staff_member.person_name, function.function_name,staff_group_function.function_id, staff_group.function_group_name
 from staff_member
 inner join staff_group
 on staff_group.staff_group_id=staff_group_member.staff_group_id
 inner join staff_group_function
 on staff_group_function.staff_group_id=staff_group_member.staff_group_id
 inner join function
 on function.function_id=staff_group_function.function_group_name
  • 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-06-01T21:28:01+00:00Added an answer on June 1, 2026 at 9:28 pm

    Nope. What you need is LISTAGG() if you have Oracle 11g2. This could be your query:

    SELECT person_name,
           LISTAGG(function_name, ', ') WITHIN GROUP (ORDER BY 1) function_name,
           LISTAGG(function_id,   ', ') WITHIN GROUP (ORDER BY 1) function_id,
           function_group
    FROM my_table
    GROUP BY person_name, function_group
    

    alternatively (following your latest comment):

    SELECT person_name,
           LISTAGG(function_name,  ', ') WITHIN GROUP (ORDER BY 1) function_name,
           LISTAGG(function_id,    ', ') WITHIN GROUP (ORDER BY 1) function_id,
           LISTAGG(function_group, ', ') WITHIN GROUP (ORDER BY 1) function_group
    FROM my_table
    GROUP BY person_name
    

    For any version prior to 11g2, this interesting article holds the solution for you:

    http://www.oracle-base.com/articles/misc/string-aggregation-techniques.php

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

Sidebar

Related Questions

I'm new to python and have hit a problem with an SQL query I'm
I am new to sql and I have come across a problem on joining
I'm brand new to SQL Server 2008, and have some newbie questions about the
I have a MySQL query that selects data from multiple tables and then orders
I`m new to sql and have been stuck on the following issue for almost
I'm a bit new to SQL and have trouble constructing a select statement. I
I have SQL server 2000 dev edition. But it isn't compatible with my new
I'm pretty new to SQL. I have a database with records based on road/milepoints.
I'm quite new to sql and I'm having trouble writing this i have a
I'm rusty in SQL and completely new to SQL Alchemy , but have an

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.