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

sql ֪ʶ

 select datediff(month,'2009-11-02','2009-12-01')
²»ÖªµÀÄãÒªÔõô¸öÔ²îÒì
ÉÏÃæµÄÃüÁî½á¹ûÒ²ÊÇ1
µ«ÊÇÆäʵ°´ÕÕ³£Ê¶²îÒì²»ÊÇÒ»¸öÔ£¬ÊDzîÒ»ÌìÒ»¸öÔÂ
ÕâÓжÎÏֳɵĴúÂë¿ÉÒÔ°ïÖúÄãËã³ö³£Ê¶ÉϵIJîÒì
SQL code
declare @t table(a datetime,b datetime);
insert @t
select '2009-11-02','2009-12-01' UNION ALL
select '2009-11-01','2009-12-01'
-->??
select a,b,
ltrim(case
when (month(b)=month(a) and day(b)>=day(a)) or month(b)>month(a)
then datediff(year,a,b)
else
datediff(year,a,b)-1
end)+'Äê'
+ltrim(case
when day(b)>=day(a) --and month(b)>=month(a)
then datediff(month,a,b)%12
else
(datediff(month,a,b)-1)%12
end)+'ÔÂ'
+ltrim(case
when day(b)>=day(a)
then day(b)-day(a)
else
datediff(dd,convert(varchar(8),dateadd(mm,-1,b),120)+'01',b)+1-day(a)
end)+'ÈÕ' as 'ÈÕÆÚ²î'
from
(select (case when a>b then b else a end) as a,
(case when a>b then a else b end) as b from @t ) t;
a b ÈÕÆÚ²î
2009-11-02 00:00:00.000 2009-12-01 00:00:00.000 0Äê0ÔÂ29ÈÕ
2009-11-01 00:00:00.000 2009-12-01 00:00:00.000 0Äê1ÔÂ0ÈÕ


Ïà¹ØÎĵµ£º

sql 2005 ´æ´¢¹ý³Ì·ÖÒ³ java ´úÂë

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ ......

SQL_ѧÉú

 
µÚÒ»²¿·Ö
µ¥±í²éѯ
ÀýÒ»£º²éѯȫÌåѧÉúµÄѧºÅÓëÐÕÃû
SELECT Sno,Sname
from Student;
Àý¶þ£º²éѯȫÌåѧÉúµÄÐÕÃû¡¢Ñ§ºÅ¡¢ËùÔÚϵ
SELECT Sname,Sno,Sdept
from Student;
ÀýÈý£º²éѯȫÌåѧÉúµÄÏêϸ¼Ç¼
SELECT *
from Student;
µÈ¼ÛÓÚ£º
SELECT *
from Student;
ÀýËÄ£º²éѯȫÌåѧÉúµÄÐÕÃû¼°Æä³öÉúÄê·Ý ......

ORACLEPL/SQL»ù´¡

 ORACLEPL/SQL»ù´¡--ÓαêµÄѧϰÀ´Ô´£º
    Óαê×ÖÃæÀí½â¾ÍÊÇÓζ¯µÄ¹â±ê¡£
    ÓÃÊý¾Ý¿âÓïÑÔÀ´ÃèÊö£ºÓαêÊÇÓ³ÉäÔÚ½á¹û¼¯ÖÐÒ»ÐÐÊý¾ÝÉϵÄλÖÃʵÌ壬ÓÐÁËÓαêÓû§¾Í¿ÉÒÔ·ÃÎʽá¹û¼¯ÖеÄÈÎÒâÒ»ÐÐÊý¾ÝÁË£¬½«Óαê·ÅÖõ½Ä³Ðк󣬼´¿É¶Ô¸ÃÐÐÊý¾Ý½øÐвÙ×÷£¬ÀýÈçÌáÈ¡µ±Ç°ÐеÄÊý¾ÝµÈµÈ¡£
  ......

SQLÃæÊÔ

1.Ò»µÀSQLÓï¾äÃæÊÔÌ⣬¹ØÓÚgroup by
±íÄÚÈÝ£º
2005-05-09 ʤ
2005-05-09 ʤ
2005-05-09 ¸º
2005-05-09 ¸º
2005-05-10 ʤ
2005-05-10 ¸º
2005-05-10 ¸º
Èç¹ûÒªÉú³ÉÏÂÁнá¹û, ¸ÃÈçºÎдsqlÓï¾ä?
            ʤ ¸º
2005-05-09 2 2
2005-05-10 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ