输出1到100之间素数的和,这个比较有意思,写了一个太过于复杂,去论坛找到一个简单的,共同分享下,呵呵。
with t as
(select level a from dual connect by level < 101)
select sum (A)
from (select
from t t1
where not exists (select 1
from t t2, t t3
where t2a > 1
and t2a <= sqrt(t1a)
and t3a >= sqrt(t1a)
and t2a t3a = t1a)
and a > 1)
1
product主键id
顾客表主键acid
商品交易表为联合主键(acid+id),同时acid和id分别是顾客表和商品表的外键
2
select bacname,bacadress
from product a,customer b,order c where aid=cid and bacid=cacid
and aname='李子'
3
select t1acname
from
(select bacname
from product a,customer b,order c where aid=cid and bacid=cacid
and aname='李子') t1,
(select bacname
from product a,customer b,order c where aid=cid and bacid=cacid
and aname='苹果') t2
where t1acname=t2acname
4
select bacname,
sum(case when type='家电' then apricecamount else 0 end) as 家电价格,
sum(case when type='水果' then apricecamount else 0 end) as 水果价格
from product a,customer b,order c where aid=cid and bacid=cacid
group by bacname
create
or
replace
view
temp_v1
as
select
部门号,max(成绩)
as
成绩
from
Employee
group
by
部门号;
--在临时视图1的基础上建立临时视图2,检索第二名分数
create
or
replace
view
temp_v2
as
select
部门号,max(成绩)
as
成绩
from
Employee
where
(部门号,成绩)
not
in
(select
from
temp_v1)
group
by
部门号;
--联合两个临时视图的查询结果,建立临时视图3
create
or
replace
view
temp_v3
as
select
from
(select
from
temp_v1
union
select
from
temp_v2)
order
by
部门号,成绩;
--建立目标视图
create
or
replace
view
VdepEm2
as
select
部门号,员工号,成绩
from
Employee
where(部门号,成绩)
in
(select
from
temp_v3);
昨天有点事情耽搁了,这个应该可以实现你的要求。如果不允许建立临时视图的话,你把这几个临时视图糅进去就可以了。
以上就是关于oracle数据库有几题不会做,请oracle数据库高手过来帮忙看看。谢谢!全部的内容,包括:oracle数据库有几题不会做,请oracle数据库高手过来帮忙看看。谢谢!、oracle数据库面试题,如下,求解!、Oracle数据库的数据提取(一道面试题)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)