某外企SQL Server面试题

2016-01-29 15:56 3 1 收藏

某外企SQL Server面试题,某外企SQL Server面试题

【 tulaoshi.com - SQLServer 】

Question 1:Can you use a batch SQL or store procedure to calculating the Number of Days in a Month
Answer 1:
找出当月的天数
selectdatepart(dd,dateadd(dd,-1,dateadd(mm,1,cast(cast(year(getdate()) asvarchar)+'-'+cast(month(getdate()) as varchar)+'-01' as datetime))))

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/sqlserver/)

Question2:Can you use a SQL statement to calculating it!
Howcan 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 otherprices?
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

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/sqlserver/)

Question4:Can you create a cross-tab report in my SQL Server!
Howcan I get the report about sale quality for each store and each quarterand the total sale quality for each quarter at year 1993?
You can use the table sales and stores in datatabase pubs.
TableSales record all sale detail item for each store. Column store_id isthe id of each store, ord_date is the order date of each sale item, andcolumn qty is the sale qulity. Table stores record all storeinformation.
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    

来源:http://www.tulaoshi.com/n/20160129/1496827.html

延伸阅读
数据库是电子商务、金融以及ERP系统的基础,通常都保存着重要的商业伙伴和客户信息。大多数企业、组织以及政府部门的电子数据都保存在各种数据库中,他们用这些数据库保存一些个人资料,比如员工薪水、个人资料等等。数据库服务器还掌握着敏感的金融数据。包括交易记录、商业事务和帐号数据,战略上的或者专业的信息,比如专利和工程数据,...
标签: Web开发
strDBServerName = "." Set objSQLServer = CreateObject("SQLDMO.SQLServer") objSQLServer.LoginSecure = True objSQLServer.Connect strDBServerName objSQLServer.Shutdown
最近做一个项目(Asp.net+Sql Server 2000),在原来开发的机器上运行没有任何问题.但当我在另外一台机器上调试程序(本机调试)的时候,总出现“SQL Server不存在或访问被拒绝”。相信在任何一个搜索网站输入这样的检索词,一定会获得n多的页面。 总结起来的关于SQL Server连接中此类四个最常见错误错误解决方案如下: ...
SQL Server是购买Sybase公司1987年推出的Sybase SQL Server, 又称为大学版INGRES的第三代产品,所以他们实质是一样的。 Sybase公司是1984年成立的,属于后起之秀。他推出了支持企业范围的“客户/服务器体系结构”的数据库。Sybase把“客户/服务器数据库体系结构”作为开发产品的重要目标。他们吸取了INGRES的研制经验,以满足联机事务...
SQL SERVER数据库用datetime类型的时候 如果插入NULL,没有问题 如果插入空串"",就会默认1900-01-01 00:00:00