0

私は実際にこの質問に2つの方法を実装しています.1つは以下の通りです. 最悪。これ、オラクルは問題を示し続けました

from padoctors p right outer join * 行 2 のエラー: ORA-00936: 式がありません

それを手伝ってください

select distinctive *
from padoctors p right outer join
(select drug,month,max(drug_num) max_no
                from (select drug,count(*) as drug_num,to_char(prescdate,'MM') as month
                    from padoctors
                    where to_char(prescdate,'YYYY')='2012'
                    group by to_char(prescdate,'MM'),drug)
                    group by month,drug) dmax on p.drug=dmax.drug
full outer join
    (select drug,month,min(drug_num) min_no
                from (select drug,count(*) as drug_num,to_char(prescdate,'MM') as month
                    from padoctors
                    where to_char(prescdate,'YYYY')='2012'
                    group by to_char(prescdate,'MM'),drug)
                    group by month,drug) dmin on dmax.month=dmin.month and dmin.drug=p.drug
order by month asc;

これ、私はhttp://www.oracle-base.com/articles/misc/with-clause.phpで「with」の使用法をグーグルで調べましたが 、まだ機能していません。

with dmax as
(
 select drug,month,max(drug_num)
 from (select drug,count(*) as drug_num,to_char(prescdate,'MM') as month
       from padoctors
       where to_char(prescdate,'YYYY')='2012'
       group by to_char(prescdate,'MM'),drug
      )
 group by month,drug
),
dmin as
(
 select drug,month,min(drug_num)
 from (select drug, count(*) as drug_num, to_char(prescdate,'MM') as month
       from padoctors
       where to_char(prescdate,'YYYY')='2012'
       group by to_char(prescdate,'MM'),drug
      )
  group by month,drug
)
select distinctive *
from dmax join dmin on dmax.month=dmin.month
order by month asc;
4

1 に答える 1

0

Just Aguy の言うことを聞いて、私はそれで遊んで、 yes :
SELECT DISTINCTIVE * FROM Tableは " ORA-00936: missing expression "を与える
ので、必要になりますSELECT DISTINCT

于 2013-02-27T09:47:33.450 に答える