我需要在我的视图中有一个唯一的数字字段,所以我尝试使用row_num()
,但我不断获得"window error"
这是用于创建视图的语法:
create or replace view DASHBOARD_P_PEILUT_NIDRESHET
as (
select ROW_NUMBER() over(order by d.mahoz_name) rownum1 ,
d.MAHOZ_NAME,d.PEILUT_NIDRESHET,g.shape ,COUNT(objectid) cnt_obj
from dashboard_mehoz_spatial_join d,sde_user.GiS_MEHOZ g
where d.mahoz_name=g.mahoz_name
group by ROW_NUMBER() , d.MAHOZ_NAME, d.PEILUT_NIDRESHET, g.shape
);
这是错误:
Error starting at line : 4 in command -
create or replace view DASHBOARD_P_PEILUT_NIDRESHET as (select ROW_NUMBER() over(order by d.mahoz_name) rownum1 ,d.MAHOZ_NAME,d.PEILUT_NIDRESHET,g.shape ,COUNT(objectid) cnt_obj
from dashboard_mehoz_spatial_join d,sde_user.GiS_MEHOZ g
where d.mahoz_name=g.mahoz_name
group by ROW_NUMBER() , d.MAHOZ_NAME, d.PEILUT_NIDRESHET, g.shape )
Error at Command Line : 7 Column : 10
Error report -
SQL Error: ORA-30484: missing window specification for this function
30484. 00000 - "missing window specification for this function"
*Cause: All window functions should be followed by window specification,
like <function>(<argument list>) OVER (<window specification>)
*Action:
我做错了什么?
答案 0 :(得分:3)
您无法group by
分析功能。但无论如何都没有必要。试试这个:
create or replace view DASHBOARD_P_PEILUT_NIDRESHET as
select ROW_NUMBER() over (order by d.mahoz_name) as rownum1 ,
d.MAHOZ_NAME, d.PEILUT_NIDRESHET, g.shape, COUNT(objectid) cnt_obj
from dashboard_mehoz_spatial_join d join
sde_user.GiS_MEHOZ g
on d.mahoz_name = g.mahoz_name
group by d.MAHOZ_NAME, d.PEILUT_NIDRESHET, g.shape ;