0
我实际上在这个问题中实现了两个方法,一个如下,另一个使用'with'来替代子查询,它们都不起作用。吮吸。 这其中,甲骨文一直显示来自padoctors P中的问题具有多个子查询的ORACLE SQL
第2行右外连接 * ERROR: 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;
这一个,我google'使用'在http://www.oracle-base.com/articles/misc/with-clause.php 仍然,不工作。
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;
没有挖进入它,它是选择'DISTINCT'不dinstinctive,你需要一个列表不同的'选择不同的药物,从月' – 2013-02-27 05:04:52