'not a single-group group function' in oracle when using LISTAGG

Ajoe

My query is using LISTAGG and it is showing an error 00937. 00000 - "not a single-group group function" I have gone through many stackoverflow questions similar to this error and those answers are using some subquery for resolving the issue. I don't want to write a subquery in this query

SELECT DISTINCT AMD.UNID AS APPLICATION_REF_ID, 
LISTAGG(LOC.PLT,',') WITHIN GROUP (ORDER BY LOC.PLT ) AS MYLOC  
FROM TAB1 AMD
LEFT JOIN TAB2 PER
ON NVL (AMD.PERMITNEWID, AMD.PERMITID) = PER.UNID
LEFT JOIN TAB3 LOC
ON NVL(AMD.PERMITNEWID, AMD.PERMITID) = LOC.PERMITID
WHERE NVL (AMD.PERMITNEWID, AMD.PERMITID) = PER.UNID
Ed Bangga

you have a missing group by, you don't need distinct() if you are grouping by UNID

SELECT AMD.UNID AS APPLICATION_REF_ID, 
LISTAGG(LOC.PLT,',') WITHIN GROUP (ORDER BY LOC.PLT ) AS MYLOC  
FROM TAB1 AMD
LEFT JOIN TAB2 PER
ON NVL (AMD.PERMITNEWID, AMD.PERMITID) = PER.UNID
LEFT JOIN TAB3 LOC
ON NVL(AMD.PERMITNEWID, AMD.PERMITID) = LOC.PERMITID
WHERE NVL (AMD.PERMITNEWID, AMD.PERMITID) = PER.UNID
GROUP BY AMD.UNID

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Why when using MIN function and selecting another column, we require GROUP BY clause? Doesn't MIN return single record?

分類Dev

Using ifelse function by group

分類Dev

Why I got Not a single-group group function in sql

分類Dev

Oracle SQLのgroupとlistaggを使用して、列と行を連結します

分類Dev

Oracle:Listagg

分類Dev

Access Group By Month Names Using Format Function

分類Dev

Using OR in a GROUP BY

分類Dev

Missing dates when using GROUP BY date

分類Dev

Group by -SQL ORACLE

分類Dev

Not a GROUP BY expression (Oracle)

分類Dev

Oracle GRoup by 7 Days

分類Dev

Oracle SQL Group By if

分類Dev

ORACLE MAX GROUP BY

分類Dev

Oracle Error message: not a GROUP BY expression when adding another 'Select' clause

分類Dev

Single boxplot for multiple group comparison

分類Dev

Use Group by with mutate, case_when, any() and all() function in R

分類Dev

Fast group rank() function

分類Dev

NLS Function By Group

分類Dev

MYSQL query with group function

分類Dev

How to group all anagrams together using a custom comparator function?

分類Dev

Oracle SQL - Group by distinct columns

分類Dev

An error regarding the GROUP BY clause in Oracle

分類Dev

Oracle Db Group By Two Columns

分類Dev

ORACLE SQL Group By STILL Guplicates

分類Dev

BigQuery Group By Case When

分類Dev

In proc sql when using SELECT * and GROUP BY, the result is not collapsed

分類Dev

Error when including a contact to group using People API

分類Dev

Oracle Listagg Sub query

分類Dev

Using command "chage" for everyone in the group group