select prod_id,prod_type_name,
min(prod_id) KEEP( dense_rank first ORDER BY res)
--max(prod_id) KEEP(dense_rank LAST ORDER BY res)
from prod 
where res like '%服务区%';错误提示:ora-00923: from keyword not found where expected我看语法应该是:
FIRST/LAST Syntax
These functions have the following syntax:aggregate_function KEEP
( DENSE_RANK LAST ORDER BY
  expr [ DESC | ASC ] [NULLS { FIRST | LAST }]
  [, expr [ DESC | ASC ] [NULLS { FIRST | LAST }]]...
)
[OVER query_partitioning_clause]似乎没有问题,为什么会出错呢,麻烦各位帮我分析下,谢谢!

解决方案 »

  1.   

    好像应该还有OVER吧
    select   prod_id,prod_type_name, 
    min(prod_id)   KEEP(   dense_rank   first   ORDER   BY   res)  over () (order by res)
    --max(prod_id)   KEEP(dense_rank   LAST   ORDER   BY   res) over () (order by res)from   prod   
    where   res   like   '%服务区%'; 
      

  2.   

    没法编辑帖子,我接下来发
    SQL>  select id,mc,sl,
      2  min(mc) keep (DENSE_RANK first ORDER BY sl) over(partition by id),
      3  max(mc) keep (DENSE_RANK last ORDER BY sl) over(partition by id)
      4  from tyj_test;
    min(mc) keep (DENSE_RANK first ORDER BY sl) over(partition by id),
                 *
    ERROR at line 2:
    ORA-00923: FROM keyword not found where expected我用网友推荐的试了下,也是报一下的错,难道是版本问题吗 我的是oracle 9i的