某外企SQL Server面试题

河南南阳南召南

河南南阳南召南

2016-01-29 15:56

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

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))))

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

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

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://m.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    

展开更多 50%)
分享

猜你喜欢

某外企SQL Server面试题

SQLServer
某外企SQL Server面试题

JAVA面试题集

编程语言 网络编程
JAVA面试题集

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

PHP的面试题集

Web开发
PHP的面试题集

外企面试常见问题 外企英语面试问题

面试 面试技巧
外企面试常见问题 外企英语面试问题

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

看看你能过关吗-J2EE面试题集锦

编程语言 网络编程
看看你能过关吗-J2EE面试题集锦

探讨Java中最常见的十道面试题(超经典)

编程语言 网络编程
探讨Java中最常见的十道面试题(超经典)

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

SQL Server到Oracle连接服务器的实现

SQL Server到Oracle连接服务器的实现

《全民小镇》攻略之绿化度的提升方法

《全民小镇》攻略之绿化度的提升方法
下拉加载更多内容 ↓