设为首页 加入收藏

TOP

oracle面试题及其答案(九)
2014-11-24 02:23:02 来源: 作者: 【 】 浏览:351
Tags:oracle 试题 及其 答案
L Server!
How can I get the report about sale quality for each store and each quarter and the total sale quality for each quarter at year 1993
You can use the table sales and stores in datatabase pubs.
Table Sales record all sale detail item for each store. Column store_id is the id of each store, ord_date is the order date of each sale item, and column qty is the sale qulity. Table stores record all store information.
I want to get the result look like as below:
Output:
stor_name Total Qtr1 Qtr2 Qtr3 Qtr4
—————————————- ———– ———– ———– ———– ———–
Barnum’s 50 0 50 0 0
Bookbeat 55 25 30 0 0
Doc-U-Mat: Quality Laundry and Books 85 0 85 0 0
Fricative Bookshop 60 35 0 0 25
Total 250 60 165 0 25


Answer 4:用动态SQL实现
23. Question5: The Fastest Way to Recompile All Stored Procedures
I have a problem with a database running in SQL Server 6.5 (Service Pack 4). We moved the database (object transfer) from one machine to another last night, and an error (specific to a stored procedure) is cropping up. However, I can’t tell which procedure is causing it. Permissions are granted in all of our stored procedures; is there a way from the isql utility to force all stored procedures to recompile
Tips: sp_recompile can recomplie a store procedure each time
Answer 5:在执行存储过程时,使用 with recompile 选项强制编译新的计划;使用sp_recompile系统存储过程强制在下次运行时进行重新编译
24. Question6: How can I add row numbers to my result set
In database pubs, have a table titles , now I want the result shown as below,each row have a row number, how can you do that
Result:
line-no title_id
———– ——–
1 BU1032
2 BU1111
3 BU2075
4 BU7832
5 MC2222
6 MC3021
7 MC3026
8 PC1035
9 PC8888
10 PC9999
11 PS1372
12 PS2091
13 PS2106
14 PS3333
15 PS7777
16 TC3218
17 TC4203
18 TC7777
Answer 6:
–SQL 2005的写法
select row_number() as line_no ,title_id from titles
–SQL 2000的写法
select line_no identity(int,1,1),title_id into #t from titles
select * from #t
drop table #t
25. Question 7: Can you tell me what the difference of two SQL statements at performance of execution


Statement 1:
if NOT EXISTS ( select * from publishers where state = ‘NY’)
begin
SELECT ‘Sales force needs to penetrate New York market’
end
else
begin
SELECT ‘We have publishers in New York’
end
Statement 2:
if EXISTS ( select * from publishers where state = ‘NY’)
begin
SELECT ‘We have publishers in New York’
end
else
begin
SELECT ‘Sales force needs to penetrate New York market’
end
Answer 7:不同点:执行时的事务数,处理时间,从客户端到服务器端传送的数据量大小
26. Question8: How can I list all California authors regardless of whether they have written a book
In database pubs, have a table authors and titleauthor , table authors has a column state, and titleauhtor have books each author written.
CA behalf of california in table authors.
Answer 8:
select * from authors where state=’CA’
27. Question9: How can I get a list of the stores that have bought both ‘bussiness’ and ‘mod_cook’ type books
In database pubs, use three table stores,sales and titles to implement this requestment. Now I want to get the result as below:
stor_id stor_name
——- —————————————-

7896 Fricative Bookshop



Answer 9:
select distinct a.stor_id, a.stor_name from stores a,sales b,titles c
where a.stor_id=b.stor_id and b.title_id=c.title_id and c.type=’business’ and
exists(select 1 from sales k,titles g where stor_id=b.stor_id
and k.title_id=g.title_id and g.type=’mod_cook’)
28. Question10: How can I list non-contignous data
In database pubs, I create a table test using statement as below, and I insert several row as below
create table test
( id int primary key )
go
insert into test values (1 )
insert into test values (2 )
insert into tes

首页 上一页 6 7 8 9 下一页 尾页 9/9/9
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇如何判断一段程序是由 C 编译程序.. 下一篇用链表模拟大整数加法运算

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: