첫 번째 쿼리가 두 번째 쿼리와 동일한 오류로 실패하지 않는 이유 :
with w as (select 1 product_id, 10 units from dual union all select 2, 5 from dual)
select sum(units) from (select product_id, sum(units) units from w);
/*
SUM(UNITS)
----------
15
*/
with w as (select 1 product_id, 10 units from dual union all select 2, 5 from dual)
select product_id, sum(units) units from w;
/*
Error starting at line 7 in command:
with w as (select 1 product_id, 10 units from dual union all select 2, 5 from dual)
select product_id, sum(units) units from w
Error at Command Line:8 Column:8
Error report:
SQL Error: ORA-00937: not a single-group group function
00937. 00000 - "not a single-group group function"
*Cause:
*Action:
*/
편집 : 버전 정보 추가 :
select * from v$version;
/*
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
*/
편집 : 기본이 아닌 매개 변수가 추가되었습니다.
select name, value from v$parameter where isdefault = 'FALSE' order by name;
/*
NAME VALUE
--------------------------------- ----------------------------------------------------------------------------------------------------------------------------------
aq_tm_processes 1
archive_lag_target 3600
audit_file_dest /u01/app/oracle/admin/oracle/adump
audit_trail NONE
compatible 11.2.0.3
control_file_record_keep_time 31
control_files /home/oracle/cfile/controlfile.dat, +DATA/oracle/controlfile/current.915.730988607, +FRA/oracle/controlfile/current.970.730988607
core_dump_dest /u01/app/oracle/admin/oracle/cdump
db_block_size 4096
db_create_file_dest +DATA
db_domain
db_file_multiblock_read_count 1
db_name oracle
db_recovery_file_dest +FRA
db_recovery_file_dest_size 375809638400
diagnostic_dest /u01/app/oracle
dispatchers (PROTOCOL=TCP) (SERVICE=oracleXDB)
event
filesystemio_options setall
global_names TRUE
job_queue_processes 10
log_archive_dest_1
log_archive_dest_10 LOCATION=USE_DB_RECOVERY_FILE_DEST MANDATORY REOPEN=60
log_checkpoint_timeout 30
memory_max_target 36507222016
memory_target 36507222016
nls_language ENGLISH
nls_length_semantics BYTE
nls_territory UNITED KINGDOM
open_cursors 300
pga_aggregate_target 0
processes 150
remote_login_passwordfile EXCLUSIVE
sga_max_size 32212254720
sga_target 0
shared_pool_size 536870912
smtp_out_server mailout.redacted.com
streams_pool_size 1073741824
undo_management AUTO
undo_retention 900
undo_tablespace TS_UNDO
41 rows selected
*/
SQL 바이올린의 작은 데이터 세트에서 이것을 재현 할 수 있습니까?
—
Philᵀᴹ
Oracle11 파서 / 최적화 프로그램의 버그라고 생각합니다 (아마도 너무 똑똑하고
—
a1ex07
product_id
인라인보기에서는 무시합니다 ). 둘 다 Oracle10g에서 실패합니다 ( "단일 그룹 그룹 기능이 아님").
@ 잭 어떤 패치 레벨입니까?
—
Philᵀᴹ
@Phil SQLFiddle가 동일한주는 이상한 결과를 (그것의 11.2.0.2 XE, 나는 11.2.0.3 SE 64 비트 리눅스에있어)
—
잭 topanswers.xyz 시도라고
@ a1ex07 나는 그것이 당신이 맞다는 것을 확신합니다. 그것은 최적화 버그입니다 :
—
잭 topanswers.xyz 시도라고
select sum(units), avg(product_id) from (select product_id, sum(units) units from w);
예상대로 실패합니다.