- 浏览: 531557 次
- 性别:
- 来自: 天津
文章分类
- 全部博客 (230)
- java (87)
- c/c++/c# (39)
- ASP.net MVC (4)
- eclipse/visual studio (3)
- tomcat/weblogic/jetty (13)
- linux/unix/windows (20)
- html/javascript/jquery/kendo/bootstrap/layui/vue/react (31)
- hibernate/struts/spring/mybatis/springboot (21)
- lucene/solr/ELK (2)
- shiro (0)
- oracle/sqlserver/mysql/postgresql (23)
- shell/python/ruby (6)
- android (0)
- maven/ant (1)
- freemarker/thymeleaf/velocity (1)
- open source project (41)
- cache/memcached/redis (0)
- nosql/hadoop/hbase/mongodb (0)
- system architecture/dubbo/zookeeper (0)
- software testing (0)
- system optimization (0)
- system security (0)
- tcp/udp/http (2)
- roller/wordpress (2)
- 工具收藏 (8)
- 文摘 (4)
- 生活 (0)
最新评论
-
coconut_zhang:
这个demo 非常完整了,是指下面说的那个html 模版,模版 ...
flying sauser, thymeleaf实现PDF文件下载 -
a93456:
你好,你有完整的demo吗? String template这 ...
flying sauser, thymeleaf实现PDF文件下载 -
yujiaao:
fn 函数循环是没有必要的啊,可以改成
protecte ...
Java 笛卡尔积算法的简单实现 -
安静听歌:
设置了.setUseTemporaryFileDuringWr ...
使用jxl导出大数据量EXCEL时内存溢出的解决办法 -
q280499693:
写的很详细,但是我现在想知道他们是怎么定位log4j.prop ...
关于SLF4J结合Log4j使用时日志输出与指定的log4j.properties不同
Question 1:Can you use a batch SQL or store procedure to calculating the Number of Days in a Month
Answer 1:找出当月的天数
select datepart(dd,dateadd(dd,-1,dateadd(mm,1,cast(cast(year(getdate()) as varchar)+'-'+cast(month(getdate()) as varchar)+'-01' as datetime))))
Question2:Can you use a SQL statement to calculating it!
How can I print "10 to 20" for books that sell for between $10 and $20,"unknown" for books whose price is null, and "other" for all other prices?
Answer 2:
select bookid,bookname,price=case when price is null then 'unknown'
when price between 10 and 20 then '10 to 20' else price end
from books
Question3:Can you use a SQL statement to finding duplicate values!
How can I find authors with the same last name?
You can use the table authors in datatabase pubs. I want to get the result as below:
Output:
au_lname number_dups
---------------------------------------- -----------
Ringer 2
(1 row(s) affected)
Answer 3
select au_lname,number_dups=count(1) from authors group by au_lname
Question4:Can you create a cross-tab report in my SQL 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实现
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系统存储过程强制在下次运行时进行重新编译
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
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
试题点评:通览整个试题,我们不难发现,这份试题是针对SQL Server数据库人员的。而从难度分析上来看,这份试题也属于同类试题中比较难的了。之所以说它难,首先是限定时间的全英文试题;其次,尽管这份试题主要是考核开发能力,但却涉及到了算法的选择和性能的调优;最后,这份试题还夹进了SQL Server数据库的升级问题。因此,综上所述,我们估计这是一家从事程序外包工作的外企招聘后台开发或与后台开发相关的SQL Server高级程序员的试题。
Answer 1:找出当月的天数
select datepart(dd,dateadd(dd,-1,dateadd(mm,1,cast(cast(year(getdate()) as varchar)+'-'+cast(month(getdate()) as varchar)+'-01' as datetime))))
Question2:Can you use a SQL statement to calculating it!
How can I print "10 to 20" for books that sell for between $10 and $20,"unknown" for books whose price is null, and "other" for all other prices?
Answer 2:
select bookid,bookname,price=case when price is null then 'unknown'
when price between 10 and 20 then '10 to 20' else price end
from books
Question3:Can you use a SQL statement to finding duplicate values!
How can I find authors with the same last name?
You can use the table authors in datatabase pubs. I want to get the result as below:
Output:
au_lname number_dups
---------------------------------------- -----------
Ringer 2
(1 row(s) affected)
Answer 3
select au_lname,number_dups=count(1) from authors group by au_lname
Question4:Can you create a cross-tab report in my SQL 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实现
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系统存储过程强制在下次运行时进行重新编译
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
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
试题点评:通览整个试题,我们不难发现,这份试题是针对SQL Server数据库人员的。而从难度分析上来看,这份试题也属于同类试题中比较难的了。之所以说它难,首先是限定时间的全英文试题;其次,尽管这份试题主要是考核开发能力,但却涉及到了算法的选择和性能的调优;最后,这份试题还夹进了SQL Server数据库的升级问题。因此,综上所述,我们估计这是一家从事程序外包工作的外企招聘后台开发或与后台开发相关的SQL Server高级程序员的试题。
发表评论
-
MySQL 5.6 for Windows 解压缩版配置安装
2016-04-22 09:55 413MySQL是一个小巧玲珑但功能强大的数据库, ... -
PL/SQL编程
2011-04-10 20:00 1108《PL/SQL编程》 ... -
EXP-××××: 问题处理方法(整理中..)
2011-01-30 10:31 15401.EXP-00091: Exporting question ... -
oracle 10g备份与还原总结
2010-06-18 15:49 1626核心提示:一.总述 1.数据库归档模式: * 非归档模式: ... -
oem 报错“java.lang.Exception: IOException in send……”
2010-04-26 13:47 2208oracle 10g R2 登陆EM管理控制台,题头报错如下: ... -
修改Oracle最大连接数
2010-04-26 08:48 10211、修改Oracle最大连接数的方法 a、以sysd ... -
oracle更改字符集步骤方法
2010-04-26 08:45 1496oracle9204更改字符集步骤方法(WE8ISO8859P ... -
oracle触发器使用笔记
2009-12-01 11:17 1132语法规则: Create [or repla ... -
TKPROF使用学习
2009-11-19 15:16 2631Tkprof工具可用来格式化s ... -
卸载Oracle,重新安装Oracle
2009-08-10 12:51 14231、 开始->设置->控制面板->管理工具->服务 ... -
Oracle中用Rowid查找和删除重复记录
2009-07-30 13:38 1272平时工作中可能会碰到当试图对库表中的某一列或几列创建唯一索引时 ... -
数据库设计多对多关系的几种形态
2009-06-29 13:37 2254前言:多对多关系至少需要3个表,我们把一个表叫做主表,一个叫做 ... -
Oracle中用exp/imp命令快速导入导出数据(整理)
2009-06-11 14:28 2101【用 exp 数 据 导 出】 ... -
Oracle创建自增字段方法-ORACLE SEQUENCE的简单介绍
2009-06-11 14:15 1171先假设有这么一个表: ... -
一些不错的sql语句
2008-12-02 17:34 21661、说明:复制表(只复制结构,源表名:a 新表名:b) ... -
表操作
2009-01-12 11:23 1031新建表:create table [表名]([自动编号字段] ... -
通用数据库存储过程代码--高效分页存储过程
2009-04-04 23:38 1304-- 获取指定页的数据 Create PROCEDURE p ... -
千万数量级分页存储过程
2009-04-04 23:36 1081参数说明: 1.Tables :表名称,视图 2.Primar ... -
存储过程编写经验和优化措施
2009-04-04 23:34 938一、前言:在经过一段 ... -
数据库面试(Oracle与Sql专题)
2009-04-04 23:16 1874oracle Certification Program (O ...
相关推荐
SQLServer数据库 DBA面试题 最新试卷 SQL面试题 京华志&精华志出品 希望大家互相学习,互相进步 支持CSDN 支持微软
SQL_Server 面试笔试试题及答案 经典SQL数据库 DBA数据库管理员 数据库优化人员面试题
SQL面试题
DBA_SQL查询面试题.doc DBA_SQL查询面试题.doc DBA_SQL查询面试题.doc
SQL_Server数据库管理员面试题(DBA)
国外DBA面试题 Oracle DBA面试题
DBA面试题 oracle 1:列举几种表连接方式 2:不借助第三方工具,怎样查看sql的执行计划....
某名企数据库面试问题答案(答案仅供参考!)
SQL数据库面试题及答案,希望有帮助!有志于成为sql dba的可以看看。谢谢
sql 面试题 很好的sql面试题哦,DBA面试的题目, 内容很丰富,面试中会出现考的问题都有,掌握了面试就没问题了
char、varchar、nvarchar之间的区别(包括用途和空间占用);xml类型查找某个节点的数据有哪些方法,哪个效率高;使用存储 等系列问题等你回答
1:SQL调整最关注的是什么? 2:Oracle的系统进程有哪些?作用是什么? 3:本地管理表空间和字典管理表空间的特点,ASSM有什么特点? 4:备份如何分类? 5:如果一个表被drop,在有完善的归档和备份的情况下,...
数据库面试题(SQL ORACLE)-DBA数据库管理员JAVA程序员架构师必看
很好的sql面试题哦,DBA面试的题目, 内容很丰富,面试中会出现考的问题都有,掌握了面试就没问题了。
数据库面试题(SQL+ORACLE)-DBA数据库管理员JAVA程序员架构师必看.pdf
数据库面试题(SQL+ORACLE)-DBA数据库管理员JAVA程序员架构师必看.doc
1.1 1、MySQL 的复制原理以及流程 (1)、复制基本原理流程 1. 主:binlog 线程——记录下所有改变了数据库数据的语句,放进master 上的binlog 中; 2. 从:io 线程——在使用start slave...更多面试题,请下载附件......
数据库工程师常见面试题
ORACLE面试题库, ORACLE面试题库, ORACLE面试题库, ORACLE面试题库, ORACLE面试题库, ORACLE面试题库, ORACLE面试题库,
数据库面试题(SQL+ORACLE)-DBA数据库管理员JAVA程序员架构师必看.pdf,这是一份不错的文件