Access×éºÏ²éѯµÄ¸ñʽ - Web ¿ª·¢ / ASP
ÏÖÔÚÓиöAccess±íÃûÊÇReturn£¬×ֶκÍÄÚÈÝΪ
Month PBU Count
Jan IDI 12
Feb IDI 15
Jan TST 12
Feb TST 15
......
ÒªÇóµÃµ½×ÜÄ꣨1-12Ô£©Ä³¸öPBUµÄ×ܺͣ¬»¹Óзֱð1-12ÔµÄ×ܺͣ¬Èç¹ûҪдһ¸öÊý¾Ý¿âËÑË÷µÄselect£¬Ó¦¸ÃÔõôд£¿
²Î¿¼ÍøÉϵÄsum¿ÉÒÔËÑË÷³öÒ»ÌõÒªÇó£¨Ò»¸öµ¥Ôª£©£¬±ÈÈç
sql="select sum(count) as a from return where pbu='idi'"
È»ºórs a
Õâ¸öÄÜÇóµÃpbuÊÇidiµÄ×ÜÄê×ܺͣ¬ÆäËûµÄÔ·ݿÉÒÔ·Ö±ðcloseÊý¾Ý¿â£¬È»ºóÔÙopen£¬select¡£µ«ÊÇÎÒ²»Ïëÿ¸öµ¥Ôª¼ÆË㶼ҪselectÒ»ÏÂÊý¾Ý¿â
ÍøÉÏÓÐÓÃsum caseÀ´·Ö±ðsum£¨£© as £¨£© from
±ÈÈçÔ¤ÏÈÉèÖúñäÁ¿£¬±ÈÈç
sum(count) as b from return where month='jan' and pbu='idi'
sum(count) as c from return where month='Feb' and pbu='idi'
È»ºó·Ö±ðrs b c...¾Í¿ÉÒÔÁË
µ«²»ÖªµÀÔõôд£¬Ð»Ð»¸÷λÌṩģ°åºÍ˼·
µ¥Ôª¸ñΪ£º
PBU Year Jan Feb Mar .......
IDI ×ÜºÍ ×ÜºÍ ×ܺÍ
TST ....
......
Ï£ÍûÍ·²¿Ð´Ò»Ìõselect£¬ÏÂÃ涼rs³öÀ´asµÄÖµ
²»ÖªµÀ±í´ïÊÇ·ñÇå³þ£¬Ð»Ð»
<%
Dim nmonArr(1 to 12)
Dim nSumArr
nSumArr=0
Set rs = Server.CreateObject("ADODB.Recordset")
for i=1 to 12
SQLcmd ="sum(count) as A from return where month=i and pbu='idi'"
rs.Open SQLcmd,conn,1,1
nMonArr(i)=rs("count")
rs.close
nSumArr=nSumArr+nMonArr(i)
next
set rs=Nothing
%&g
Ïà¹ØÎÊ´ð£º
ÎÊÌâÊÇÕâÑùµÄ,ÏÖÔÚÓÐÒ»¸ö¹¤×ʱí,ÊÇEXCELµÄ,ÎÒÒª°ÑËüµ¼ÈëACCESS,ÒòΪ Òª²éѯÿ¸öÈ˵Ť×Ê,¸ù¾Ý²»Í¬µÄ±àºÅ¿ÉÒÔ²éѯµ½Ïà¶ÔµÄÈË,
ÓÃASP Ôõô½«EXCELµ¼Èëµ½ACCESS,¶øÇÒÿÔ¶¼Óв»Í¬µÄ±í,
ÒýÓÃ
Æäʵ¾ÍÊÇ°ÑEXCELµ±³ÉÊý ......
oracle ´úÂ룺
select * from (select * row_number() over ( partition by ÁªÏµºÅÂë order by ÒµÎñºÅÂë ) rn from ºÅÂë²éѯ) where rn<2
Ч¹ûÊÇ£º½« ijһָ¶¨×ֶΠɾ³ýÖظ´µÄºÅÂ룬²¢±£Áô¸ÃºÅÂëÏà¹ØµÄÆäËûÐ ......
ʹÓÃACCESS×î´óµÄÒþ»¼¾ÍÊDz»°²È«¡£½ñÌì¶ÔACCESSÊý¾Ý¿âÉèÖÃÁËÒ»¸öÃÜÂ룬±ØÐëʹÓÃÃÜÂë²ÅÄÜ´ò¿ª£¬µ«ÊÇÔÚ³ÌÐòÖÐÈ´ÎÞ·¨Á¬½ÓÊý¾Ý¿âÁË¡£´ó¼ÒÖªµÀʹÓÃÓû§ÃûºÍÃÜÂ룬ÈçºÎÁ¬½ÓACCESSÊý¾Ý¿â£¿Ã²ËÆACCESSµÄÓû§Ãû»¹²»ÖªµÀ£¿Ö»Öª ......
Êý¾Ý¿â½á¹¹ÊÇÕâÑùµÄ ²éѯ³öÀ´ÊÇÒ»¸öͳ¼ÆЧ¹û
²éѯ³öÀ´¾ÍÊÇ µ±ÈÕÆÚΪʲôµÄʱºò ÕâÒ»ÌìËùÓÐÊý¾ÝµÄͳ¼Æ
sql = "select FScrq from TJlb "
Call OpenConn2
rs2.Open sql, cn2, 1, 1
D ......
string sql = "select * from [order] where @type like '%@keyword%'";
OleDbParameter[] paras = new OleDbParameter[]
{
new OleDbParameter(" ......