设为首页 加入收藏

TOP

某公司数据库笔试题(英文的)(二)
2014-11-23 22:32:54 来源: 作者: 【 】 浏览:10
Tags:公司 数据库 试题 英文
o #t from titles
select * from #t
drop table #t
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:不同点:执行时的事务数,处理时间,从客户端到服务器端传送的数据量大小
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’
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’)
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 test values (3 )
insert into test values (4 )
insert into test values (5 )
insert into test values (6 )
insert into test values (8 )
insert into test values (9 )
insert into test values (11)
insert into test values (12)
insert into test values (13)
insert into test values (14)
insert into test values (18)
insert into test values (19)
go
Now I want to list the result of the non-contignous row as below,how can I do it
Missing after Missing before
————- ————–
6 8
9 11


Answer 10:
select id from test t where not exists(select 1 from test where id=t.id+1)
or not exists(select 1 from test where id=t.id-1)
Question11: How can I list all book with prices greather than the average price of books of the same type
In database pubs, have a table named titles , its column named price mean the price of the book, and another named type mean the type of books.
Now I want to get the result as below:
type title price
———— ——————————————————————————– ———————
business The Busy Executive’s Database Guide 19.9900




Answer 11:
select a.type,a.title,a.price from titles a,
(select type,price=avg(price) from titles group by type)b
where a.type=b.type and a.price>b.price


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇河岸的距离 下一篇为什么我的自定义控件不能正确地..

评论

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