1 Replies - 3764 Views - Last Post: 28 May 2014 - 04:46 PM

#1 Warsaw  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 79
  • Joined: 04-August 13

Problem with ListAgg() in joined tables

Posted 17 May 2014 - 01:03 AM

Hi,

I am having problems with using the Oracle ListAgg() function when querying data from multiple tables.

Here is the code:
SELECT
  STUDENT.S_ID "STUDENT ID", (STUDENT.S_FIRST || ' ' || STUDENT.S_LAST) "STUDENT NAME",
  TERM.TERM_DESC "TERM",
  LISTAGG(COURSE.COURSE_NAME, '; ') WITHIN GROUP (ORDER BY COURSE.COURSE_NO) "COURSE LIST"
FROM STUDENT
INNER JOIN ENROLLMENT ON ENROLLMENT.S_ID = STUDENT.S_ID
INNER JOIN COURSE_SECTION ON COURSE_SECTION.C_SEC_ID = ENROLLMENT.C_SEC_ID
INNER JOIN TERM ON TERM.TERM_ID = COURSE_SECTION.TERM_ID
INNER JOIN COURSE ON COURSE.COURSE_NO = COURSE_SECTION.COURSE_NO
GROUP BY STUDENT.S_ID, STUDENT.S_FIRST, STUDENT.S_LAST, TERM.TERM_DESC
HAVING TERM.TERM_DESC IN ('Spring 2013', 'Spring 2014');



It works but it bugs me that I keep getting a warning saying that the "Select list inconsistent with group by;". It tells me to change the group by clause to this:
GROUP BY STUDENT.S_ID, STUDENT.S_FIRST, (STUDENT.S_FIRST, STUDENT.S_LAST, TERM.TERM_DESC


...which doesn't make sense to me and is not even a complete sql statement. :(/>

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with ListAgg() in joined tables

#2 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 879
  • View blog
  • Posts: 1,893
  • Joined: 30-January 09

Re: Problem with ListAgg() in joined tables

Posted 28 May 2014 - 04:46 PM

Moving topic to Oracle forum
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1