ÇóÒ»SQLÓï¾ä
ÔÊý¾Ý
ÉÌÆ· Ô¼Û ´òÕÛ·½Ê½1 ÕÛ¿Û1 ´òÕÛ·½Ê½2 ÕÛ¿Û2
±Ê¼Ç±¾ 10000 NULL 0 NULL 0
µçÊÓ»ú 2000 ´ÙÏú 200 NULL 0
±ùÏä 3000 ´ÙÏú 300 ÀÏ¿Í»§ 400
ÒªµÃ³ö½á¹û
ÉÌÆ· ´òÕÛ·½Ê½ ¼ÛÇ®
±Ê¼Ç±¾ NULL 10000
µçÊÓ»ú ´ÙÏú 2000
µçÊÓ¾ç ´ÙÏú -200
±ùÏä ´ÙÏú 3000
±ùÏä ´ÙÏú -300
±ùÏä ÀÏ¿Í»§ -400
ÐèÇóµÄ±È½ÏÆæ¹Ö¡£
´ó¸ÅÀ´Ëµ£¬Ã¿¸öÓÐЧµÄÕÛ¿Û£¬¶¼ÁíÍâÆðÒ»ÐУ¬²¢Ê¹ÓøºÊý±íʾ
ʵÏÖÆðÀ´±È½ÏÆæ¹Ö£¬¼Ó·Ö
union all
SQL code:
select ÉÌÆ· as ÉÌÆ· ,´òÕÛ·½Ê½1 as ´òÕÛ·½Ê½,Ô¼Û as ¼ÛÇ® from ±í
union all
select ÉÌÆ·,-´òÕÛ·½Ê½1,ÕÛ¿Û1 from ±í
union all
select ÉÌÆ·,-´òÕÛ·½Ê½2,ÕÛ¿Û2 from ±í
union all
Ïà¹ØÎÊ´ð£º
´ó¼ÒºÃ£¬ÇëÎÊÔÚ±íMÖÐÓÐ×ֶΣºa b c d e
ÎÒÏë²é³öÆäÖÐÂú×ãÏÂÃæÈÎÒâÒ»ÏîµÄÊý¾Ý£¬1.×Ö¶Îa µÄÖµ²»ÊÇ ¡®Êé»ò±Ê»ò±¾¡¯ÖÐÈÎÒ»£¬2.aΪÊéµÄʱºò×Ö¶Îb,cÊÇ¿Õ;3.µ±aֵΪ±ÊµÄʱºòdÊÇ¿Õ;4.µ±aΪ±¾µÄʱºòb,d,e¶¼ÊÇ¿Õ;5.È ......
СµÜÊǸöÐÂÊÖ ÏÖÔÚÓиöÎÊÌâÒ»Ö±²»Äܽâ¾ö
ÀýÈç
procedure produce_proc
@p001 nvarchar(8000),
@p002 nvarchar(8000),
@p003 nvarchar(8000),
& ......
Ö´ÐеÄ˳Ðò£º
1£©Îļþä¯ÀÀ¿ò£¨Ñ¡ÔñÎļþʹÓã©
Ñ¡ÔñºÃÎļþºó
µã»÷Ò»¸öµ¼Èë°´Å¥µÄʱºò £¬°ÑÉÏÃæÉÏ´«¿òÀïµÄcsvÎļþÒÔÒ»¸öIDΪÎļþÃû£¬ÉÏ´«µ½**/**Îļþ¼ÐÏÂ
2£©¶ÁÈ¡Õâ¸öÎļþ¼ÐϵÄcsvµÄÎļþ£¬×ª»»³Ésql
3 ......
ÒÑÖª´ÓB,±íÖÐÕÒ³öID, NAMEÁ½ÏîÓëC±íÏàͬµÄÊý¾Ý£¬ÔÙÒÀ¾ÝB±íÖо¹ý²éѯ³öÀ´µÄID,CODEÁ½ÏîÊý¾Ý²éѯÓëA±íID,CODEÁ½ÏîÏàͬµÄÊý¾ÝÖжÔÓ¦µÄEMAILÀ´£¬²¢ÁгöÈçÏÂD±íµÄÐÎʽ£¬²»ÖªÎÒÊÇ·ñ±íʾÇå³þ£¿Âé·³°ïÎÒÁÐһϹ«Ê½ºÃÂð£¿Íò· ......
ÒòΪƽʱÕâÖÖ²Ù×÷±È½Ï¶à£¬Ö±½ÓÔÚÊý¾Ý¿âÉÏÊÖ¶¯ÉèÖÃΣÏÕÐԽϴó£¬ËùÒÔÏëÓÃSQLÓï¾äʵÏÖ¡£
ÔÚÍøÉÏʵÔÚËѲ»µ½½á¹û£¬ÕâÀï¸ßÊֶ࣬ϣÍûÄܵõ½´ð°¸¡£
лл¡£
ÄãÏëÔõ麼設ÖÃ?
SQL code:
--´´½¨²âÊÔ±í
......