¼¼Êõ µã
- ¼¼Êõ
- µã
- V±Ò
- µã
- »ý·Ö
- 4973
|
±¾Ìû×îºóÓÉ ÔÛ¼ÒÊÇè ÓÚ 2011-10-24 22:59 ±à¼
¼¸¸öÅóÓÑÔÚACCESS HOMEȺÀïÎʹØÓÚ·þ×°³ßÂëÓëÑÕÉ«¶àÊôÐÔ½»²æ²éѯ³öÀ´µÄ½á¹û,³ßÂë×öΪÁбêÌâºó˳ÐòÎÞ·¨´ÓXSµ½XXXL×Ô¶¯ÅÅÐò.
ÔÊý¾Ý±íÊý¾ÝÈçÏÂͼ:
ÏëµÃµ½µÄ²éѯ½á¹ûÈçÏÂͼ:
ÓÚÊÇÎÒ×öÁ˸öÀý×Ó¸øËûÃÇ,ÎÒÏëÕâÖÖÖ÷ÌâÔÚÂÛ̳ÉÏÇ°±²¿Ï¶¨ÔçÒÑÓз¢¹ý,µ«¼ÈÈ»Àý×ÓÒ²×ö³öÀ´ÁË,¾ÍË÷ÐÔÔÙ¾ßÌå½²ÏÂÈçºÎʵÏÖ°É.
Ê×ÏÈ,ÎÒÃÇ¿ÉÒÔÀûÓòéѯÏòµ¼Éú³ÉÒ»¸ö½»²æ²éѯ(µ±È»,Ò²¿ÉÒÔ×Ô¼ºÔÚ²éѯÉè¼ÆÍø¸ñÖбà¼Ò»¸ö),ÏÂÃæÒÀ¾ÝÕÕ¹ËÐÂÊÖµÄÔÔò,ÎÒÌû³öÓòéѯÏòµ¼ÖÆ×÷µÄ²½Öèͼ.
1 ²éѯÏòµ¼°´Å¥ÔÚAccess 2010ÀïµÄλÖÃ,µã»÷Ëü.
2 ÔÚ²éѯÏòµ¼µÄµÚÒ»²½ÀïÑ¡Ôñ½»²æ²éѯ,È»ºóÈ·¶¨
2.5 ºÇºÇ...·¢ÍêÌû×Ó·¢ÏÖÌøÁËÒ»·ù½Øͼ,ÄÇËü¾ÍÊÇ2.5²½Öè°É. ÕâÒ»²½ÆäʵÊÇÑ¡ÔñÊý¾ÝÀ´Ô´,ÕâÀý×ÓÖоÍÖ»ÓÐÒ»¸ö±íÁË.
3 Ñ¡ÔñÒÔ"ÑÕÉ«"×öÐбêÌâ,È»ºóÏÂÒ»²½.
4 Ñ¡ÔñÒÔ"³ßÂë"ΪÁбêÌâ,È»ºóÏÂÒ»²½:
5 Ñ¡ÔñÒÔ"ÊýÁ¿"µÄºÏ¼Æ(Sum)Ϊֵ,È»ºóÏÂÒ»²½:
6 ×îºóÍê³É,´ò¿ª²é¿´²éѯ½á¹û.
7 Õâ¾ÍÊÇÀûÓÃÏòµ¼µÄÒýµ¼ÏÂÖÆ×÷µÄÒ»¸ö½»²æ²éѯµÄ½á¹û:
8 ÏÖÔھͷ¢ÏÖ,ÉÏÃæµÄÁбêÌâÓеãÂÒ,²»ÊÇ×Ô¼ºÏëÒªµÄ´Ó×îСµ½×î´ó³ßÂëµÄÅÅÁÐ˳Ðò,Ôõô°ì?
´ò¿ª¸Õ¸ÕÉú³ÉµÄ½»²æ²éѯµÄÉè¼ÆÊÓͼ(ÈçºÎ´ò¿ªÉè¼ÆÊÓͼ?Äã¿ÉÒÔÔÚ²éѯÃûÉÏÓÃÓÒ¼üµ¥»÷,»áÓÐ"Éè¼ÆÊÓͼ"ÃüÁîµÄ.),È»ºóÔÚÇл»µ½SQLÊÓͼ.ÈçºÎÇл»,¿´ÏÂͼÕÒµ½SQLÊÓͼÇл»°´Å¥.
9 ÖÁ´Ë,ÎÒÃǻῴµ½¼¸ÐÐSQLÓï¾ä,Õâ¾ÍÊǸոÕÄǸö½»²æ²éѯµÄÓï¾ä,Óï¾äÈçÏÂ:
TRANSFORM Sum(ÎïÆ·¿â´æ±í.[ÊýÁ¿]) AS ÊýÁ¿Ö®ºÏ¼Æ
SELECT ÎïÆ·¿â´æ±í.[ÑÕÉ«], Sum(ÎïÆ·¿â´æ±í.[ÊýÁ¿]) AS [×Ü¼Æ ÊýÁ¿]
FROM ÎïÆ·¿â´æ±í
GROUP BY ÎïÆ·¿â´æ±í.[ÑÕÉ«]
PIVOT ÎïÆ·¿â´æ±í.³ß´ç;
ÔÚÓï¾äµÄ×îºóÒ»ÐÐ,ÊÇ"PIVOT"ÐÐ,ÏÖÔÚ,ÎÒÃÇÔÚËüµÄ"PIVOT"ÖÐÇ¿ÐÐÉ趨¶ÔÁеÄ˳Ðò,°Ñ×îºóÒ»ÐиijÉ:
PIVOT ÎïÆ·¿â´æ±í.³ß´ç IN ("XS","S","M","L","XL","XXL","XXXL")
OK,±£´æ²éѯÉè¼Æ,¹Ø±Õ²éѯÉè¼Æ,ÔÙ´ò¿ªÄǸö²éѯ.¾Í³ÉÁËÌû×Ó¿ªÍ·µÄÂúÒâµÄ½á¹ûÁË.
¸³ÉÏÀý×Ó,Á½¸öAccess°æ±¾µÄ,2003Óë2007/2010µÄ.
|
±¾Ìû×ÓÖаüº¬¸ü¶à×ÊÔ´
ÄúÐèÒª µÇ¼ ²Å¿ÉÒÔÏÂÔØ»ò²é¿´£¬Ã»ÓÐÕʺţ¿×¢²á
x
|