ÇósqlÓï¾ä - Delphi / Êý¾Ý¿âÏà¹Ø
access±íÈçÏ£º
µØµã ÊýÁ¿ ÖÖÀà
a 2 ¼×
a 2 ÒÒ
b 2 ¼×
c 3 ¼×
c 3 ÒÒ
d 5 ¼×
d 3 ¼×
d 5 ÒÒ
e 1 ÒÒ
²éѯÓï¾ä1£ºSELECT µØµã,sum(ÊýÁ¿) from data group by µØµã
½á¹ûΪ£º
µØµã Expr1001
a 4
b 2
c 6
d 13
e 1
²éѯÓï¾ä2£ºSELECT µØµã,sum(ÊýÁ¿) from data where ÖÖÀà="¼×"group by µØµã
½á¹ûΪ£º
µØµã Expr1001
a 2
b 2
c 3
d 8
ÎÒÏëÒªµÄÊÇ£¬µ±²éѯÓï¾äÊÇ2µÄʱºò£¬µÃµ½ÈçϽá¹û£º
µØµã Expr1001
a 2
b 2
c 3
d 8
e 0
¾ÍÊÇ˵£ºµ±ÓÃÓï¾ä2µÄʱºò£¬µØµã×ֶεÄֵҪȫ²¿ÁгöÀ´£¬
Õâ¸öGroup BY ¿ÉÄÜÍêÔÚ²»ÁËÕâ¸ö¹¦ÄÜ£¬
×îºÃÔÙºÍËùÓеĵصã×Ö¶ÎJoinһϣ¬
SELECT * from ((SELECT DISTINCT µØµã from data) AS a LEFT JOIN (SELECT µØµã,sum(ÊýÁ¿) from data where ÖÖÀà="¼×"group by µØµã) as b ON a.µØµã=b.µØµã)
Óà having À´É¸Ñ¡
¿´´íÁË,Ä㻹ҪÏÔʾΪ0,ÄÇô¾ÍÓÃcaseÀ´´¦ÀíµÚ¶þÁÐ
SELECT µØµã,iif(sum(ÊýÁ¿),0,0,sum(ÊýÁ¿)) from data where ÖÖÀà="¼×"group by µØµã
IIf(expr, truepart, falsepart)
IIf º¯ÊýµÄÓï·¨°üº¬ÒÔϲÎÊý £¨²ÎÊý£ºÎª²Ù×÷¡¢Ê¼þ¡¢·½·¨¡¢ÊôÐÔ¡¢º¯Êý»ò¹ý³ÌÌṩÐÅÏ¢µÄÖµ¡££©
²ÎÊý ˵Ã÷
expr ±ØÑ¡¡£Òª¼ÆËãµÄ±í´ïʽ¡£
truepart ±ØÑ¡¡£expr Ϊ True ʱ·µ»ØµÄÖµ»ò±í´ïʽ¡£
falsepart ±ØÑ¡¡£expr Ϊ False ʱ·µ»ØµÄÖµ»ò±í´ïʽ¡£
˵Ã÷
ÓÉÓÚ IIf »á¼ÆËã tru
Ïà¹ØÎÊ´ð£º
Ö´ÐеÄ˳Ðò£º
1£©Îļþä¯ÀÀ¿ò£¨Ñ¡ÔñÎļþʹÓã©
Ñ¡ÔñºÃÎļþºó
µã»÷Ò»¸öµ¼Èë°´Å¥µÄʱºò £¬°ÑÉÏÃæÉÏ´«¿òÀïµÄcsvÎļþÒÔÒ»¸öIDΪÎļþÃû£¬ÉÏ´«µ½**/**Îļþ¼ÐÏÂ
2£©¶ÁÈ¡Õâ¸öÎļþ¼ÐϵÄcsvµÄÎļþ£¬×ª»»³Ésql
3 ......
ÒÑÖªPython ÖУº
s = unicode("²âÊÔ", "gb2312")
s = u'\u6d4b\u8bd5'
print s
²âÊÔ
ÔÚDelphiÀïÃæÈçºÎ½«\u6d4b\u8bd5ÕâÑùµÄ»¹Ô³ÉGb2312µÄºº×ÖÄØ£¿
ÕÒµ½¸ö·½·¨
......
ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......
1¡£ÔõÑùʹxp_cmdshellÄÜÍêÕûÊä³ö³¬¹ý255¸ö×Ö·ûµÄ×Ö·û´®¡£
2¡£select ʱ£¬¼ìË÷ËÙ¶ÈÊÇÓëfromºóµÄ TABLE˳ÐòÓйأ¬»¹ÊÇÓëwhereÌõ¼þµÄ˳ÐòÓйØ(TABLEÊý¾Ý¶àÉÙ )
ÔÚϵͳÊôÐÔÉ趨ÀïÓиöÑ¡Ïî,¿ÉÒÔÐ޸ĵ¥×Ö¶ÎÊä³ö×ÖÊýÏÞÖÆ. ......
ÕâÀïÏëÁ˽âÏ£¬¹ØÓÚSQL ServerÖзÖÒ³ºÍOracleÖзÖÒ³£»
ƽ³£Ð´Ó¦ÓóÌÐòµÄʱºò£¬±ÈÈçÓõÄÓïÑÔÊÇJava£¬ÓиöÁбíÒ³Ã棬ÐèÒª¶ÔÊý¾Ý·ÖÒ³ÏÔʾ£»
ÕâÀïÒª·ÖÒ³ÄѵÀ²»ÐèÒª½èÖúJava£¬¶øÖ±½ÓsqlÄÜÖªµÀ·ÖÒ³Âð£¬ÆðÂëÒ²Òª´«¸öÒ³Âë½ ......