ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] VBA SQL»yªk¬ÛÃö¸ß°Ý

[µo°Ý] VBA SQL»yªk¬ÛÃö¸ß°Ý

·Q½Ð±Ð¦U¦ì¤j¯«...
¥ý«e¦b¼´¤j¶q¸ê®Æªº±¡ªp¤U¡A¨Ï¥Îfor°j°é¡A¸ûµL¨Ï¥ÎSQL¨³³t¡C

¥Ø«e¦bselsect¸ê®Æ¹Lµ{¤¤¡A·|¥d¦bµLªk±NªÅ¥Õ¸ê®Æ¤]¤@¨Ö´£¥X¡C
·|¸õ¥X¿ù»~µøµ¡¡GµL­È´£¨Ñµ¹¤@©Î¦h­Ó¥²­n°Ñ¼Æ¡C
¦³¿ìªk¥i¥H¨Ï¥ÎSQL»Pªk¿ì¨ì¶Ü¡H


¥»©«³Ì«á¥Ñ singo1232001 ©ó 2024-2-15 11:35 ½s¿è

¦^´_ 1# »a³·


­YÄæ¦ì¦WºÙªÅ¥Õ
AÄæ ´N¬OF1
BÄæ´N¬O F2     

Fªº·N«ä´N¬OFileds

°²³]¤u§@ªí1 A,B,C,D ¥|Äæ¦ì
¥N¸¹,(ªÅ¥Õ),°Ó«~,ª÷-ÃB

¨Ò¦p select *  form [¤u§@ªí1$A1:D]

¥i§ï¦¨ select ¥N¸¹,F2,°Ó«~,[ª÷-ÃB]    from  [¤u§@ªí1$A1:D]

TOP

¦^´_ 2# singo1232001


    §e¤WÃD
­Y °Ó«~ ¦³ªÅ­È ·Q§ï¬°0
¥i§ï¦¨ select ¥N¸¹,F2,iif(IsNull(°Ó«~),0,°Ó«~) as °Ó«~ ,[ª÷-ÃB]    from  [¤u§@ªí1$A1:D]


¥t¥~ ­ì©l¸ê®Æªí »P ¦s©ñ¸ê®Æªº½d³ò¤£¯à¬Û¦P

TOP

¥»©«³Ì«á¥Ñ »a³· ©ó 2024-2-15 22:39 ½s¿è

¦^´_ 3# singo1232001


    ©Ò­n§ìªº¸ê®Æ¦³¼ÐÃDÄæ¡A¼ÐÃDÄæ¤U¦³ªÅ­È¡C
    ¦Ó§Úªº§PÂ_¦¡¬O¦bªí®æ«á¤è¦³"V"ªº·|±N¸Ó¦Cªº¸ê®Æ(¥]§tªÅ­È)¤@¨ÖÂà¦Ü¥t¥~¤@­ÓSheet¡C
    ¦b¹Á¸Õ¨Ï¥Îiif(IsNull(¼ÐÃDÄæ¦WºÙ),0,¼ÐÃDÄæ¦WºÙ) as ¼ÐÃDÄæ¦WºÙ¡A¹J¨ì¥H¤U±¡ªp¡G
   

    20:38¡ô­è­è¦³µo²{°ÝÃDÂI¡A¼ÐÃD¦WºÙ¦³´«¦æ°Ê§@¡A²M°£´«¦æ¤§«á¡A¨Ï¥Î¸Ó»yªkÁÙ¬O¦^¨ì#1ªº±¡ªp

    ³o¬O¼g¦bVBA¤ºªº¸ê®Æ
  1. sql = "select ­û¤u½s¸¹,©m¦W,¥X¶Ô¤é´Á,¬P´Á,¯Z§O¥N¸¹,¯Z§O¦WºÙ,À³¤W¯Z®É¶¡,À³¤U¯Z®É¶¡,¤W¯Z®É¶¡,¤U¯Z®É¶¡,°²§O¥N¸¹,°²§O¦WºÙ,½Ð°_®É¶¡,½Ð°W®É¶¡,¥ð°²­ì¦],½Ð°²®É¼Æ,¥Ó½Ð¥[¯Z§O,¥[°_®É¶¡,¥[°W®É¶¡,¥[¯Z­ì¦],¥[¯Z®É¼Æ from [¥X¶Ôñ¨ì$] where ¿z¿ï±ø¥ó='V'"
½Æ»s¥N½X

TOP

¦^´_ 4# »a³·


    ¬¡­¶Ã¯2.zip (21.41 KB)

TOP

¦^´_ 5# singo1232001


    ·PÁÂsingo1232001ªº¸Ñµª¡A¤w¶¶§Q±N°ÝÃD±Æ°£¡C
    ¥Ñ©ó¡A¬O±µ¤â¥L¤HExcel®æ¦¡±N¥¨¶°­l¥Í¥X¨Ó¡C
    «áÄò±q¤¤µo²{¡A¦³³\¦h¼ÐÃDÄæ¬Ò¦³¤À¦æ¡A¾É­PSQL»yªk§P©w¤W²§±`¡A±N¨ä­×¥¿«á¤w¥i¥¿±`¹B§@¡C

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2024-2-19 12:01 ½s¿è

¦^´_ 4# »a³·


    ­è¬Ý¨ì¹Ï¤ù
­Y­nª½±µ¬d¸ß¤é´Á  ®æ¦¡¸û¬°½ÆÂø

¤£ºÞ¬O­nselect¬d
select format(¤é´ÁÄæ¦ì,'yyyy-MM-dd')

©ÎªÌ where¿z
where between format(¤é´ÁÄæ¦ì,'yyyy-MM-dd') and  format(¤é´ÁÄæ¦ì,'yyyy-MM-dd')&'23:59:59'

³£­n¥Î"¤å¦r¤é´Á" ¤è¦¡¨Ó³B²z
¦Ó¥B­nª`·N¤j¤p¼g


§A¤]¥i¥H°Ñ¦Ò
https://forum.twbts.com/viewthread.php?tid=23976&extra=pageD2&page=4
32¼Ó

TOP

¦^´_ 7# singo1232001


    ·PÁ«ü¾É¡A§Ú·|¦A¦h§V¤O¾Ç²ß»yªk¡I

TOP

        ÀR«ä¦Û¦b : ­n§åµû§O¤H®É¡A¥ý·Q·Q¦Û¤v¬O§_§¹¬üµL¯Ê¡C
ªð¦^¦Cªí ¤W¤@¥DÃD