sql server³£ÓÃÓï¾ä
1¡¢°´Ê±¼äÅÅÐò
select * from tbl_lms_loginhistory order by loginhistory_logintime desc
2¡¢
ÔÚÒ»¸öÊý¾Ý¿âÖÐÊÇÏÂÁеÄÑù×Ó
³µ´Î Éí·ÝÖ¤ºÅ
27 1
27 2
45 1
25 1
45 2
ÏÖÔÚÎÒÏë »ñµÃµÄÊÇ
³µ´Î ³Ë×ø´ÎÊý
25 1
27 3
45 2
ÇëÎÊ£¬ÎÒµÄSQLÓï¾ä¸ÃÔõôд£¿
select ³µ´Î£¬sum(Éí·ÝÖ¤ºÅ£©as ³Ë×ø´ÎÊý from ±íÃû group by ³µ´Î
3¡¢countÓëdistinct
select count(*) from tbl_lms_loginhistory
select count(distinct loginhistory_emp_fk) from tbl_lms_loginhistory
Ïà¹ØÎĵµ£º
SQL ServerÓû§×Ô¶¨Ò庯ÊýºÍ´æ´¢¹ý³ÌÓÐÀàËƵŦÄÜ£¬¶¼¿ÉÒÔ´´½¨À¦°óSQLÓï¾ä£¬´æ´¢ÔÚserverÖй©ÒÔºóʹÓá£ÕâÑùÄܹ»¼«´óµØÌá¸ß¹¤×÷ЧÂÊ£¬Í¨¹ýÒÔϵĸ÷ÖÖ×ö·¨¿ÉÒÔ¼õÉÙ±à³ÌËùÐèµÄʱ¼ä£º
¡¡¡¡ 1 Öظ´Ê¹Óñà³Ì´úÂ룬¼õÉÙ±à³Ì¿ª·¢Ê±¼ä¡£
¡¡¡¡ 2 Òþ²ØSQLϸ½Ú£¬°ÑSQL·±ËöµÄ¹¤×÷Áô¸øÊý¾Ý¿â¿ª·¢ÈËÔ±£¬¶ø³ÌÐò¿ª·¢Ô±Ôò¼¯Öд¦Àí¸ß¼¶±à³Ì ......
ÊÂÎñÈÕÖ¾½áβ¾³£Ìá½»Êý¾Ý¿âδ±¸·ÝµÄÊÂÎñÈÕÖ¾ÄÚÈÝ¡£»ù±¾ÉÏ£¬Ã¿Ò»´ÎÄãÖ´ÐÐÊÂÎñÈÕÖ¾±¸·Ýʱ£¬Ä㶼ÔÚÖ´ÐÐÊÂÎñÈÕÖ¾½áβµÄ±¸·Ý¡£
ÄÇΪʲô»áÕâôÉè¼ÆÄØ£¿ÒòΪҲÐíÓÉÓÚ½éÖʵÄË𻵣¬µ±Êý¾Ý¿âÒѾ²»ÔÙ¿ÉÓÃʱ£¬Âé·³¾ÍÀ´ÁË¡£Èç¹ûÏÂÒ»¸öÂß¼²½ÖèÕýºÃ¾ÍÊÇÒª±¸·Ýµ±Ç°ÊÂÎñÈÕÖ¾µÄ»°£¬¿ÉÒÔÓ¦ÓÃÕâ¸ö±¸·ÝÀ´Ê¹Êý¾Ý¿â´¦Óڵȴý(Standby)״̬¡£ÄãÉ ......
1ʹÓò»´ø²ÎÊýµÄ´æ´¢¹ý³Ì
¡¡¡¡Ê¹Óà JDBC Çý¶¯³ÌÐòµ÷Óò»´ø²ÎÊýµÄ´æ´¢¹ý³Ìʱ£¬±ØÐëʹÓà call SQL תÒåÐòÁС£²»´ø²ÎÊýµÄ call תÒåÐòÁеÄÓï·¨ÈçÏÂËùʾ£º
¡¡¡¡
ÒÔÏÂÊÇÒýÓÃƬ¶Î£º
{call procedure-name}
¡¡¡¡×÷ΪʵÀý£¬ÔÚ SQL Server 2005 AdventureWorks ʾÀýÊý¾Ý¿âÖд´½¨ÒÔÏ´洢¹ý³Ì£º
¡¡¡¡
ÒÔÏÂÊÇÒýÓÃƬ¶Î£º
......
1.
select top m * from tablename where id not in (select top n id from tablename)
2.
select top & ......
¸ñʽ:
CONVERT(data_type,expression[,style])
˵Ã÷:
´ËÑùʽһ°ãÔÚʱ¼äÀàÐÍ(datetime,smalldatetime)Óë×Ö·û´®ÀàÐÍ(nchar,nvarchar,char,varchar)
Ï໥ת»»µÄʱºò²ÅÓõ½.
Àý×Ó:
SELECT CONVERT(varchar(30),getdate(),101) now
½á¹ûΪ:
now
---------------------------------------
|09/15/2001
===== ......