OracleDB - 子串(分组依据和排序依据)

时间:2014-04-17 20:04:00

标签: sql database oracle oracle-sqldeveloper

出于某种原因,我无法使此查询生效。

select substr(x.id, 4, 5)
from x
join y
on x.id=y.x_id 
where 1=1
group by substr(x.id, 4, 5)
order by substr(x.id, 4, 5) asc

它一直在说:     ORA-00979:不是GROUP BY表达式     00979. 00000 - "不是GROUP BY表达式"

这有效:

SELECT * FROM (
    select substr(x.id, 4, 5) as col
    from x
    join y
    on x.id=y.x_id 
    where 1=1
    group by substr(x.id, 4, 5)
)
order by col asc

是否可以在不使用子查询的情况下执行此操作?

0 个答案:

没有答案