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

SQL CASEµÄÓ÷¨£¬±ÈÏëÏóÖеÄÇ¿´ó

±íÈçÏÂ
Ò»ÌõÓï¾äÏÔʾËùÓдóÓÚ25ËêºÍϵÄÈË£¬ÒÔÉϵÄÈËÏÔ'´óÁä'
select case when age>25 then '´óÁä' else 'СÁä' end as ÄêÁä¼¶±ð,count(*) as ÈËÊý from infor group by case when age>25 then '´óÁä' else 'СÁä' end
 


Ïà¹ØÎĵµ£º

Ò»¶ÎsqlÓï¾äµÄ·ÖÎö

--µ±Ç°Ê¹ÓõÄÊý¾Ý¿âÊÇ ÏµÍ³×Ô´øµÄ master
create database temp1
go --´Ë´¦²»¼ÓgoµÄ»°ÏÂÃæuse temp1 »á±¨´í£ºÕÒ²»µ½´æ´¢¹ý³Ì 'temp1'¡£
use temp1
set xact_abort on
begin tran
create table [order]( --orderÊǹؼü×Ö±ØÐëÓÃ[ ]£»
id int
)
create table fOrder(
id int
)
-- ÏÂÃæµÄ²Ù×÷Ö÷ÒªÊÇΪÁËʵÏÖfO ......

SQLʵÏÖÍêÈ«ÅÅÁÐ×éºÏ

---SQLʵÏÖÍêÈ«ÅÅÁÐ×éºÏ
create function F_strSpit(@s varchar(200)) returns table
as
return(
select value=substring(@s,i,num)+substring(@s,num-1+j,1)
from (select num=number from spt_values where type='p' and number<len(@s) and number>0)TA,
(select i=number+1 from spt_values where type='p ......

³£ÓÃSqlÓï¾ä

ʹÓà TRUNCATE TABLE ɾ³ýËùÓÐÐÐ
ÈôҪɾ³ý±íÖеÄËùÓÐÐУ¬Ôò TRUNCATE TABLE Óï¾äÊÇÒ»ÖÖ¿ìËÙ¡¢ÓÐЧµÄ·½·¨¡£TRUNCATE TABLE Óë²»º¬ WHERE ×Ó¾äµÄ DELETE Óï¾äÀàËÆ¡£µ«ÊÇ£¬TRUNCATE TABLE Ëٶȸü¿ì£¬²¢ÇÒʹÓøüÉÙµÄϵͳ×ÊÔ´ºÍÊÂÎñÈÕÖ¾×ÊÔ´¡£
Óë DELETE Óï¾äÏàͬ£¬Ê¹Óà TRUNCATE TABLE Çå¿ÕµÄ±íµÄ¶¨ÒåÓëÆäË÷ÒýºÍÆäËû¹ØÁª¶ÔÏóÒ ......

accessÓëSqlServer ֮ʱ¼äÓëÈÕÆÚ¼°ÆäËüSQLÓï¾ä±È½Ï

1¡¢Datediff£º
1.1Ëã³öÈÕÆÚ²î£º
1.access:       datediff('d',fixdate,getdate())
2.sqlserver:    datediff(day,fixdate,getdate())
ACCESSʵÀý£º    select * from table where data=datediff('d',fixdate,getdate())
sqlserverʵÀý£º select * from ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ