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

SQLÖд¦Àíʱ¼äÎÊÌâ°¸Àý

1. »ñÈ¡Êý¾Ý¿âÖе±Ç°Ô·ݵÄÏà¹ØÊý¾Ý
SELECT WorkerSortID, SUM(WorkerCount) AS WorkerMothCount
from WorkerRecord
WHERE (YEAR(WorkerTime) = YEAR({ fn NOW() })) AND (MONTH(WorkerTime)
      = MONTH({ fn NOW() })) AND (WorkerCount > 0) AND (WorkerID = 'wy')
GROUP BY WorkerSortID
2. »ñÈ¡Êý¾Ý¿âÖеĴæÔÚʱ¼äÊý¾Ý£¬Ê±¼ä¸ñʽΪ£º1999-11
SELECT CONVERT(varchar(10), YEAR(WorkerTime)) + '-' + CONVERT(varchar(10),
      MONTH(WorkerTime)) AS WorkTime
from WorkerRecord
GROUP BY CONVERT(varchar(10), YEAR(WorkerTime)) + '-' + CONVERT(varchar(10),
      MONTH(WorkerTime))
3. »ñÈ¡Êý¾Ý¿âÖÐÖ¸¶¨Ê±¼ä¶ÎµÄÏà¹ØÊý¾Ý
SELECT WorkerSortID, SUM(WorkerCount) AS WorkerMothCount
from WorkerRecord
WHERE (WorkerCount > 0) AND (WorkerTime < CONVERT(varchar(30), '2008-12-31', 101)) AND (WorkerID = 'wy')
GROUP BY WorkerSortID


Ïà¹ØÎĵµ£º

SQL LEFT JOIN ¹Ø¼ü×Ö

SQL LEFT JOIN ¹Ø¼ü×Ö
 
SQL LEFT JOIN ¹Ø¼ü×Ö
LEFT JOIN ¹Ø¼ü×Ö»á´Ó×ó±í (table_name1) ÄÇÀï·µ»ØËùÓеÄÐУ¬¼´Ê¹ÔÚÓÒ±í (table_name2) ÖÐûÓÐÆ¥ÅäµÄÐС£
LEFT JOIN ¹Ø¼ü×ÖÓï·¨
SELECT column_name(s)
from table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
×¢ÊÍ£ºÔÚÄ ......

SQL RIGHT JOIN ¹Ø¼ü×Ö

SQL RIGHT JOIN ¹Ø¼ü×Ö
SQL RIGHT JOIN ¹Ø¼ü×Ö
RIGHT JOIN ¹Ø¼ü×Ö»áÓÒ±í (table_name2) ÄÇÀï·µ»ØËùÓеÄÐУ¬¼´Ê¹ÔÚ×ó±í (table_name1) ÖÐûÓÐÆ¥ÅäµÄÐС£
RIGHT JOIN ¹Ø¼ü×ÖÓï·¨
SELECT column_name(s)
from table_name1
RIGHT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
×¢ÊÍ£ºÔÚijЩÊý ......

ÎåÖÖÌá¸ß SQL ÐÔÄܵķ½·¨

ÎåÖÖÌá¸ß SQL ÐÔÄܵķ½·¨
ÓÐʱ£¬ ΪÁËÈÃÓ¦ÓóÌÐòÔËÐеøü¿ì£¬Ëù×öµÄÈ«²¿¹¤×÷¾ÍÊÇÔÚÕâÀï»òÄÇÀï×öһЩºÜСµ÷Õû¡£°¡£¬µ«¹Ø¼üÔÚÓÚÈ·¶¨ÈçºÎ½øÐе÷Õû£¡³ÙÔçÄú»áÓöµ½ÕâÖÖÇé¿ö£ºÓ¦ÓóÌÐòÖÐµÄ SQL ²éѯ²»ÄÜ°´ÕÕÄúÏëÒªµÄ·½Ê½½øÐÐÏìÓ¦¡£ËüҪô²»·µ»ØÊý¾Ý£¬ÒªÃ´ºÄ·ÑµÄʱ¼ä³¤µÃ³öÆæ¡£Èç¹ûËü½µµÍÁ˱¨¸æ»òÄúµÄÆóÒµÓ¦ÓóÌÐòµÄËٶȣ¬Óû§±ØÐ ......

SQL JOINÖ®ÍêÈ«Ó÷¨

×î½üÔÚ×ömysqlµÄÐÔÄÜÓÇ»¯£¬×öµ½¶à±íÁ¬½Ó²éѯ£¬±È½ÏÍ·ÌÛ£¬¿´ÁËһЩjoinµÄ×ÊÁÏ£¬ÖÕÓڸ㶨£¬ÕâÀï·ÖÏí³öÀ´£¡
ÍâÁª½Ó¡£ÍâÁª½Ó¿ÉÒÔÊÇ×óÏòÍâÁª½Ó¡¢ÓÒÏòÍâÁª½Ó»òÍêÕûÍⲿÁª½Ó¡£    
  ÔÚ   from   ×Ó¾äÖÐÖ¸¶¨ÍâÁª½Óʱ£¬¿ÉÒÔÓÉÏÂÁм¸×é¹Ø¼ü×ÖÖеÄÒ»×éÖ¸¶¨£º  
 &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ