首页 > 解决方案 > ORA-00979: 不是 GROUP BY 表达式 | 用户定义函数

问题描述

我有以下使用用户定义函数的查询。由于使用listagg,我必须使用 ,group by但我认为由于用户定义的功能,它在远程数据库中失败:

    select p.player_code, 
           team_name,
           listagg(case 
                       when player_type = 'Def' and player_status in ('Fit', 'Mid-Fit') 
                       then player_group_name
                       else null 
                   end, ', ') within group (order by player_group_name) ctg, 
           schema_name.get_player_type_code@db_link(player_type, 'c')
    from schema_name.team@db_link t
    join schema_name.player@db_link p on t.team_id = p.player_team_id
    left join(select distinct player_id, player_group_name
              from schema_name.player@db_link i 
              join schema_name.player_sel@db_link ps on i.player_id = ps.player_sel_player_id
              join schema_name.player_queue@db_link pq on ps.player_sel_queue_id = pq.queue_id 
              join schema_name.player_queue_group pqg on pq.queue_id = pqg.player_queue_group_queue_id
              join schema_name.player_group pg on pqg.player_queue_group_group_id = player_group_id) ctg on p.player_id = ctg.player_id
    group by p.player_code, 
             team_name, 
             schema_name.get_player_type_code@db_link(player_type, 'c');

此查询在我的主数据库中运行良好(不使用数据库链接)。但是,当我在远程数据库中运行它(使用数据库链接)时,它给了我以下错误: ORA-00979: not a GROUP BY expression

如果我从我的查询中删除该功能(存在于主数据库中并且远程数据库具有执行此功能的正确权限。我可以毫无问题地从远程数据库执行该功能),它将在远程数据库中正常工作。但是当我把它放回查询中时,它会显示同样的错误。

想法?

标签: oraclefunctiongroup-by

解决方案


推荐阅读