ijÍâÆóSQL ServerÃæ試題
--> Title : ijÍâÆó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
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃæ£¬ºóÃæ ......
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 ......
SELECT ROWNUM AS ID
,TO_CHAR(SYSDATE + ROWNUM / 24 / 3600, 'yyyy-mm-dd hh24:mi:ss') AS INC_DATETIME
,TRUNC(DBMS_RANDOM.VALUE(0, 100)) AS RANDOM_ID
,DBMS_RANDOM.STRING('x', 20) RANDOM_STRING
from DUAL
CONNECT BY LEVEL <= 10;
SELECT '('||WMSYS.WM_CONCAT(':P' || ROWNUM)| ......
×î½üÔÚ×öÒ»¸ö×¢²á³ÌÐò£¬µÃÓõÃÃÜÂëµÄMD5¼ÓÃÜ£¬Ö±½ÓÔÚ´æ´¢¹ý³ÌÖнøÐÐ×¢²á¡£
²éÕҵõ½£¬¿ÉÓÃÒÔÏ·½·¨½øÐмÓÃÜ£º
print RIGHT(sys.fn_VarBinToHexStr(hashbytes('MD5','ANSEN')),32)
Êý¾Ý¿âÊÇÓÃSQL SERVER 2005£¬ÆäËûµÄÊý¾Ý¿âÓ¦¸ÃÒ²²î²»µ½ÄÄÈ¥~~ ......
À´×Ôhttp://hi.baidu.com/zcy60156/blog/item/42b6c5802a33859af603a685.html
ÍÆ¼öÊÇÓô洢¹ý³Ì¼ÓÊÂÎñʵÏÖ.»òÖ±½ÓÔÚaspÀïд¼ÓÉÏÊÂÎñ¾Í¿ÉÒÔͬʱµÄ²åÈëÁË.Èç¹ûÖмä³ö´íµÄ»°»¹Äܻعö,¿É±£³ÖÊý¾ÝµÄÒ»ÖÂÐÔ.È¥baiduÉÏËÑË÷Ò»ÏÂÊÂÎñµÈµÄÏà¹Ø×ÊÁϺܶàµÄ.
ÔÚ¿ª·¢WebÓ¦ÓÃʱ£¬ÎÞÒ»ÀýÍâµØÐèÒª·ÃÎÊÊý¾Ý¿â£¬ÒÔÍê³É¶ÔÊý¾ÝµÄ²éѯ¡¢²åÈë¡¢¸ ......