OracleµÄ ¼òµ¥ÐÐתÁÐ
Ó¦¸ö±¨±íÒªÇó×ö¸ö
ʱ¼ä ˫ɫÇò£¬ ʤ¸º²Ê¡£¡£¡£¡£¡£
200905 ÏúÁ¿ ÏúÁ¿
200906 ÏúÁ¿ ÏúÁ¿
200907 ÏúÁ¿ ÏúÁ¿
200908 ÏúÁ¿ ÏúÁ¿
Ò»¸öSQL Óï¾äµÃµ½½á¹ûÊÇ£º
f_yearmonth, lot_name,money
200905 ˫ɫÇò 50
200905 ʤ¸º²Ê 100
200906 ˫ɫÇò 60
200906 ʤ¸º²Ê 70
Select f_yearmonth,
Max(decode(f_lotname,'˫ɫÇò',f_money,0)) As "˫ɫÇò",
Max(decode(f_lotname,'¸£²Ê3D',f_money,0)) as "¸£²Ê3D",
Max(decode(f_lotname,'ʤ¸º²Ê',f_money,0)) as "ʤ¸º²Ê",
Max(decode(f_lotname,'ʱʱ²Ê',f_money,0)) as "ʱʱ²Ê",
Max(decode(f_lotname,'ʱʱÀÖ',f_money,0)) as "ʱʱÀÖ",
from
t_tmp_test_A
Group By f_yearmonth
Order By f_yearmonth
¹Ø¼üÓï¾ä£º
Max(decode(f_lotname,'˫ɫÇò',f_money,0)) As "˫ɫÇò",
Group By f_yearmonth
ӦΪ °´Ê±¼äÖØ×éÖ»ÓÐÒ»Ìõ£¬²¢ÇÒÖ»ÓÐÒ»ÌõÊý¾Ý£º 200905 ˫ɫÇò 50
ÄÇô ÓÃMAXȡһÌõÊý¾Ý ¾ÍÊÇ50
decode Òâ˼˵ Èç¹ûÊǑ˫ɫÇò’ È¡¶ÔÓ¦µÄf_money ²¢ÇÒ·ÅÔÚ ÃüÃûΪ "˫ɫÇò"µÄ ÁÐÉÏ¡£
ºÜÏÔÈ» ÕâÁÐÊǹ̶¨£¡
Ïà¹ØÎĵµ£º
°üÓɰü¹æ·¶ºÍ°üÌåÁ½²¿·Ö×é³É¡£
1¡¢°ü¹æ·¶£¨Package Specification£©
°ü¹æ·¶£¬Ò²½Ð×ö°üÍ·£¬°üº¬ÁËÓйذüµÄÄÚÈݵÄÐÅÏ¢¡£µ«ÊÇ£¬Ëü²»°üº¬Èκιý³ÌµÄ´úÂë¡£
´´½¨°üÍ·µÄÓï·¨Ò»°ãÈçÏÂ
CREATE [OR REPLACE] PACKAGE package_name {IS | AS}
Procedure_name | function_name | variable_declaration | type_def ......
1¡¢´¥·¢Æ÷µÄ¸ÅÄî
´¥·¢Æ÷Ò²ÊÇÒ»ÖÖ´øÃûµÄPL/SQL¿é¡£´¥·¢Æ÷ÀàËÆÓÚ¹ý³ÌºÍº¯Êý£¬ÒòΪËüÃǶ¼ÊÇÓµÓÐÉùÃ÷¡¢Ö´ÐкÍÒì³£´¦Àí¹ý³ÌµÄ´øÃûPL/SQL¿é¡£Óë°üÀàËÆ£¬´¥·¢Æ÷±ØÐë´æ´¢ÔÚÊý¾Ý¿âÖв¢ÇÒ²»Äܱ»¿é½øÐб¾µØ»¯ÉùÃ÷¡£
¶ÔÓÚ´¥·¢Æ÷¶øÑÔ£¬µ±´¥·¢Ê¼þ·¢ÉúµÄʱºò¾Í»áÏÔʽµØÖ´Ðиô¥·¢Æ÷£¬²¢ÇÒ´¥·¢Æ÷²»½ÓÊܲÎÊý¡£
´´½¨´¥·¢Æ÷µÄÓï·¨È ......
1. create table people (age int, id int);
2. ´´½¨Êý¾ÝÎļþPeopleDate.txt.
Êý¾ÝΪ£º
20,1
30,2
3. ´´½¨ ......
ORACLEÏà¹ØÓï·¨ ÊÕ²Ø
Ò»¡¢OracleÈëÃÅ
ÀíÂÛ֪ʶ£º
OracleµÄÎïÀí×é¼þÓÐÈý¸ö£º
(1)Êý¾ÝÎļþ Êý¾ÝÎļþÊÇÓÃÓÚ´æ´¢Êý¾Ý¿âÊý¾ÝµÄÎļþ£¬Èç±í¡¢Ë÷ÒýÊý¾Ý¡£Ã¿¸öOracleÊý¾Ý¿âÓÐÒ»¸ö»ò¶à¸öÎïÀíÊý¾ÝÎļþ£¬
&nbs ......
°¸Àý˵Ã÷£º
ÓÐA,BÁ½Ì¨oracleÊý¾Ý¿â£¬¶¼Îª10g,ÏÖÔÚÓÐÒ»¸öAÊý¾Ý¿âÖÐone±íµÄ¼¸ÌõÊý¾ÝÒª²åÈëµ½BÊý¾Ý¿âÖеÄone±í£¿
ÔÚÍøÉϲéÔÄÁËһϣ¬¿ÉÒÔͨ¹ýÔÚAÉϽ¨Á¢dblink£¬µ±È»ÔÚB»úÉϽ¨Á¢Ò²ÊÇÒ»ÑùµÄ¡£
´ò¿ªsqlplusÖÕ¶Ë£¬»òÕßÈÎÒâµÄoracle¿Í»§¶Ë»·¾³£¬Ö´ÐÐÒÔÏÂSQL
create database link Á´½ÓÃû
¡¡connect t ......