Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL Óï¾äÁ·Ï°


–1¡¢²éÕÒÔ±¹¤µÄ±àºÅ¡¢ÐÕÃû¡¢²¿ÃźͳöÉúÈÕÆÚ£¬Èç¹û³öÉúÈÕÆÚΪ¿ÕÖµ£¬ÏÔʾÈÕÆÚ²»Ïê,²¢°´²¿ÃÅÅÅÐòÊä³ö,ÈÕÆÚ¸ñʽΪyyyy-mm-dd¡£
select emp_no,emp_name,dept,isnull(convert(char(10),birthday,120),’ÈÕÆÚ²»Ïê’) birthday
from employee
order by dept
–2¡¢²éÕÒÓëÓ÷×ÔÇ¿ÔÚͬһ¸öµ¥Î»µÄÔ±¹¤ÐÕÃû¡¢ÐԱ𡢲¿ÃźÍÖ°³Æ
select emp_no,emp_name,dept,title
from employee
where emp_name<>’Ó÷×ÔÇ¿’ and dept in
(select dept from employee
where emp_name=’Ó÷×ÔÇ¿’)
–3¡¢°´²¿ÃŽøÐлã×Ü£¬Í³¼Æÿ¸ö²¿ÃŵÄ×ܹ¤×Ê
select dept,sum(salary)
from employee
group by dept
–4¡¢²éÕÒÉÌÆ·Ãû³ÆΪ14´çÏÔʾÆ÷ÉÌÆ·µÄÏúÊÛÇé¿ö£¬ÏÔʾ¸ÃÉÌÆ·µÄ±àºÅ¡¢ÏúÊÛÊýÁ¿¡¢µ¥¼ÛºÍ½ð¶î
select a.prod_id,qty,unit_price,unit_price*qty totprice
from sale_item a,product b
where a.prod_id=b.prod_id and prod_name=’14´çÏÔʾÆ÷’
–5¡¢ÔÚÏúÊÛÃ÷ϸ±íÖа´²úÆ·±àºÅ½øÐлã×Ü£¬Í³¼ÆÿÖÖ²úÆ·µÄÏúÊÛÊýÁ¿ºÍ½ð¶î
select prod_id,sum(qty) totqty,sum(qty*unit_price) totprice
from sale_item
group by prod_id
–6¡¢Ê¹ÓÃconvertº¯Êý°´¿Í»§±àºÅͳ¼Æÿ¸ö¿Í»§1996ÄêµÄ¶©µ¥×ܽð¶î
select cust_id,sum(tot_amt) totprice
from sales
where convert(char(4),order_date,120)=’1996′
group by cust_id
–7¡¢²éÕÒÓÐÏúÊۼǼµÄ¿Í»§±àºÅ¡¢Ãû³ÆºÍ¶©µ¥×ܶî
select a.cust_id,cust_name,sum(tot_amt) totprice
from customer a,sales b
where a.cust_id=b.cust_id
group by a.cust_id,cust_name
–8¡¢²éÕÒÔÚ1997ÄêÖÐÓÐÏúÊۼǼµÄ¿Í»§±àºÅ¡¢Ãû³ÆºÍ¶©µ¥×ܶî
select a.cust_id,cust_name,sum(tot_amt) totprice
from customer a,sales b
where a.cust_id=b.cust_id and convert(char(4),order_date,120)=’1997′
group by a.cust_id,cust_name
–9¡¢²éÕÒÒ»´ÎÏúÊÛ×î´óµÄÏúÊۼǼ
select order_no,cust_id,sale_id,tot_amt
from sales
where tot_amt=
(select max(tot_amt)
from sales)
–10¡¢²éÕÒÖÁÉÙÓÐ3´ÎÏúÊÛµÄÒµÎñÔ±Ãûµ¥ºÍÏúÊÛÈÕÆÚ
select emp_name,order_date
from employee a,sales b
where emp_no=sale_id and a.emp_no in
(select sale_id
from sales
group by sale_id
having count(*)>=3)
order by emp_na


Ïà¹ØÎĵµ£º

SQL Server 2008¼¸ÏîÐÂÌØÐÔ¸ÅÊö

¼Æ»®ÓÚ2008ÄêµÚÒ»¼¾¶È·¢²¼µÄSQL Server 2008²»½ö¶ÔÔ­ÓÐÐÔÄܽøÐÐÁ˸Ľø£¬»¹Ìí¼ÓÁËÐí¶àÐÂÌØÐÔ£¬±ÈÈçÐÂÌíÁËÊý¾Ý¼¯³É¹¦ÄÜ£¬¸Ä½øÁË·ÖÎö·þÎñ£¬±¨¸æ·þÎñ£¬ÒÔ¼°Office¼¯³ÉµÈµÈ¡£
¡¡¡¡SQL Server¼¯³É·þÎñ
¡¡¡¡SSIS(SQL Server¼¯³É·þÎñ)ÊÇÒ»¸öǶÈëʽӦÓóÌÐò£¬ÓÃÓÚ¿ª·¢ºÍÖ´ÐÐETL(½âѹËõ¡¢×ª»»ºÍ¼ÓÔØ)°ü¡£SSIS´úÌæÁËSQL 2000µÄDTS¡£Õ ......

SQLÂß¼­²éѯ´¦Àí˳Ðò

SQL²»Í¬ÓÚÆäËû±à³ÌÓïÑÔµÄ×îÃ÷ÏÔÌØÕ÷ÊÇ´¦Àí´úÂëµÄ˳Ðò¡£ÔÚ´ó¶àÊý¾Ý¿âÓïÑÔÖУ¬´úÂë°´±àÂë˳Ðò±»´¦Àí¡£µ«ÔÚSQLÓï¾äÖУ¬µÚÒ»¸ö±»´¦ÀíµÄ×Ó¾äʽfrom£¬¶ø²»ÊǵÚÒ»³öÏÖµÄSELECT¡£SQL²éѯ´¦ÀíµÄ²½ÖèÐòºÅ£º
      
view source
< id="highlighter_299531_clipboard" title="copy to clipboard" clas ......

SQL Server JDBC Çý¶¯·â×°

1¡¢½¨Á¢Ò»¸öjdbc.jsp Îļþ£º
2¡¢½«ÏÂÃæÏàÓ¦µÄ´úÂ븴ÖƵ½jdbc.jspÖÐ
3¡¢±àдҪÁ¬½Óµ½Êý¾Ý¿âµÄjspÎļþʱ£¬Ö»Ð轫jdbc.jspÎļþ°üº¬µ½¸ÃjspÎļþÖоÍÐÐÁË
·½·¨£ºÌí¼Ó<%@  include file="jdbc.jsp">µ½jspÎļþÖм´¿É
//sql server2005:
<%@ page language="java" import ="java.util.*"%>
 
<%
& ......

Windows Azureƽ̨¼ò½é(ËÄ)£ºSQL AzureÒÔ¼°ÆäËû·þÎñ


¹«¸æ£º±¾²©¿ÍΪ΢ÈíÔƼÆËãÖÐÎIJ©¿ÍµÄ¾µÏñ²©¿Í£¬²¢²»±£Ö¤Á´½Ó¿ÉÓÃÐÔ£¬ÎªÁ˱£Ö¤ÔĶÁÌåÑ飬Çë·ÃÎÊhttp://blogs.msdn.com/azchina¡£
 
 
SQL AzureÊÇÒ»¸ö²¿ÊðÔÚÔƶ˵ĹØϵÐÍÊý¾Ý¿âÒýÇ棬ËüÖ§³ÖSQL ServerÖоø´ó¶àÊýºÍ¿ª·¢ÓйصŦÄÜ¡£×÷Ϊһ¸ö²¿ÊðÔÚÔƶ˵ÄÊý¾Ý¿âÒýÇ棬¾ø´ó¶àÊýµÄ¹ÜÀí¹¤×÷¶¼ÓÉ΢ÈíΪÄãÍê³É£¬Òò´Ë ......

SQL ÖÐWith as µÄÓ÷¨

Ò»£®WITH ASµÄº¬Òå
WITH AS¶ÌÓҲ½Ð×ö×Ó²éѯ²¿·Ö£¨subquery factoring£©£¬¿ÉÒÔÈÃÄã×öºÜ¶àÊÂÇ飬¶¨ÒåÒ»¸öSQLƬ¶Ï£¬¸ÃSQLƬ¶Ï»á±»Õû¸öSQLÓï¾äËùÓõ½¡£ÓеÄʱºò£¬ÊÇΪÁËÈÃSQLÓï¾äµÄ¿É¶ÁÐÔ¸ü¸ßЩ£¬Ò²ÓпÉÄÜÊÇÔÚUNION ALLµÄ²»Í¬²¿·Ö£¬×÷ΪÌṩÊý¾ÝµÄ²¿·Ö¡£
Ìرð¶ÔÓÚUNION ALL±È½ÏÓÐÓá£ÒòΪUNION ALLµÄÿ¸ö²¿·Ö¿ÉÄÜÏàͬ£¬µ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ