易截截图软件、单文件、免安装、纯绿色、仅160KB

某外企SQL Server面試題

--> Title  : 某外企SQL Server面試題
--> Author : wufeng4552
--> Date   : 2010-1-15
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 cro


相关文档:

航空公司管理系统(VC++ 与SQL 2005)

系统环境:Windows 7
软件环境:Visual C++ 2008 SP1 +SQL Server 2005
本次目的:编写一个航空管理系统
      这是数据库课程设计的成果,虽然成绩不佳,但是作为我用VC++ 以来编写的最大程序还是传到网上,以供参考。用VC++ 做数据库设计并不容易,但也不是不可能。以下是我的程序界面,后面 ......

sql choch02

ch02
--3-4
select * from orders
where 'México D.F.' in
(select City
from Customers
where Orders.CustomerID = Customers.CustomerID )
--3-5
select * from orders
where 'usa' =
(select Country
from Customers
where Orders.CustomerID = Customers.CustomerID )
--4-1
select * from or ......

sql关于between的用法改进

最近用到日期范围的查询,用到了between,但是发现如果日期带时间的话,BETWEEN '2010-1-4' AND 
       '2010-1-4'这样的语句是查不到数据的,后来想到了一种改进方法,供大家参考。
如下:
BETWEEN '2010-1-4' AND DATEADD(day, 1, '2010-1-4')
用了DATEADD以后,效果很不错 ......

SQL Server数据库设计表和字段的经验

转自:http://tech.ddvip.com/2007-05/117955341625057.html
检查各种变化
  我在设计数据库的时候会考虑到哪些数据字段将来可能会发生变更。比方说,姓氏就是如此(注意是西方人的姓氏,比如女性结婚后从夫姓等)。所以,在建立系统存储客户信息时,我倾向于在单独的一个数据表里存储姓氏字段,而且还附加起始日和终止 ......

SQL 设计模式

1、SQL是一种说明性语言,不是过程化语言。类似“检索->检查->插入->更新”的过程化步骤的顺序是没有意义的。应该以行集的方式思考,以描述一个逻辑的语言方式思考。
2、在设计数据库表字段时,一个行描述应该包含一个事实,而且是全部事实。例如考勤卡的设计,
不要设计为:[ userId, puchTime, even ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号