Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

oracleÐÐÁÐת»»£¨×ª£©

1¡¢¹Ì¶¨ÁÐÊýµÄÐÐÁÐת»»
Èç
student subject grade
--------- ---------- --------
student1 ÓïÎÄ 80
student1 Êýѧ 70
student1 Ó¢Óï 60
student2 ÓïÎÄ 90
student2 Êýѧ 80
student2 Ó¢Óï 100
……
ת»»Îª
ÓïÎÄ Êýѧ Ó¢Óï
student1 80 70 60
student2 90 80 100
……
Óï¾äÈçÏ£ºselect student, 
sum(decode(subject,'ÓïÎÄ', grade,null)) "ÓïÎÄ",
sum(decode(subject,'Êýѧ', grade,null)) "Êýѧ",
sum(decode(subject,'Ó¢Óï', grade,null)) "Ó¢Óï"
from table
group by student;
¡¡
2¡¢²»¶¨ÁÐÐÐÁÐת»»
Èç
c1 c2
--- -----------
1 ÎÒ
1 ÊÇ
1 Ë­
2 Öª
2 µÀ
3 ²»
……
ת»»Îª
1 ÎÒÊÇË­
2 ÖªµÀ
3 ²»
ÕâÒ»ÀàÐ͵Äת»»¿ÉÒÔ½èÖúÓÚPL/SQLÀ´Íê³É£¬ÕâÀï¸øÒ»¸öÀý×Ó
CREATE OR REPLACE FUNCTION get_c2(tmp_c1 NUMBER)
RETURN VARCHAR2
IS
Col_c2 VARCHAR2(4000);
BEGIN
FOR cur IN (SELECT c2 from t WHERE c1=tmp_c1) LOOP
Col_c2 := Col_c2||cur.c2;
END LOOP;
Col_c2 := rtrim(Col_c2,1);
RETURN Col_c2;
END;
select distinct c1 ,get_c2(c1) cc2 from table;
»òÕß²»ÓÃpl/sql£¬ÀûÓ÷ÖÎöº¯ÊýºÍ CONNECT_BY ʵÏÖ£º
SELECT c1, SUBSTR (MAX (SYS_CONNECT_BY_PATH (c2, ';')), 2) NAME
    from (SELECT c1, c2, rn, LEAD (rn) OVER (PARTITION BY c1 ORDER BY rn) rn1
            from (SELECT c1, c2, ROW_NUMBER () OVER (ORDER BY c2) rn
                    from t))
START WITH rn1 IS NULL
CONNECT BY rn1 = PRIOR rn
GROUP BY c1;
3¡¢ÁÐÊý²»¹Ì¶¨£¨½»²æ±íÐÐÁÐתÖã©
ÕâÖÖÊDZȽÏÂé·³µÄÒ»ÖÖ£¬ÐèÒª½èÖúpl/sql£º
ԭʼÊý¾Ý£º
CLASS1     CALLDATE         CALLCOUNT
1          2005-08-08       40
1          2005-08-07       6
2          2005-08-08       77
3          2005-08-09       33
3         


Ïà¹ØÎĵµ£º

sql serverºÍoracleµÄÇø±ð

1£®OracleΪ¿Í»§¶Ë¿ªÆô»á»°ÓÐÁ½ÖÖ·½Ê½£º¹²Ïí·þÎñºÍרÓ÷þÎñ¡£ÔÚרÓ÷þÎñÇé¿öÏ£¬¼àÌýÆ÷ΪÁ¬½ÓÇëÇó´´½¨Ð½ø³Ì£¨Unix»·¾³ÏÂÊÇProcess£¬WindowsÏÂÎÒÏëÓ¦¸ÃÊÇThread°É£©£»¹²Ïí·þÎñÇé¿öÏ£¬¼àÌýÆ÷½«¿Í»§ÇëÇ󽻸øDispatcher£¬ÓÉDispatcher°²ÅŶà¿Í»§µÄ×÷Òµ¡£SQL ServerÔÚĬÈÏÇé¿öÏÂ×Ô¶¯Îª¿Í»§¶ËÁ¬½Ó´´½¨Ị̈߳¬µ±Óзdz£¶àµÄ¿Í ......

SQL ¿ª·¢ÈËÔ± Oracle Berkeley DB Ö¸ÄÏ£¨zz£©

תÔØÒ»¸öBDBµÄÏà¹Ø½éÉÜ£¬»ù±¾¿ÉÒÔµ±ËÙ³ÉÊÖ²áÓ㬸ü¶àµÄÎĵµ¿ÉÒÔÈ¥Oracle¹Ù·½ÍøÕ¾ÏÂÔØ¡£
SQL ¿ª·¢ÈËÔ± Oracle Berkeley DB Ö¸ÄÏ
×÷ÕߣºMargo Seltzer
Oracle Berkeley DB Öг£Óà SQL º¯ÊýʹÓÃÖ¸ÄÏ¡£
2007 Äê 9 Ô·¢±í
³£³£ÓÐÈËÎÊ Oracle Berkeley DB “ÎÒÈçºÎÔÚ Berkeley DB ÖнøÐÐ <SQL ²éѯ>£¿"Òò´Ë£¬ÎÒÃÇ ......

OracleÊý¾Ý¿âµÄ±¸·ÝÓë»Ö¸´

OracleÊý¾Ý¿âÓÐÈýÖÖ±ê×¼µÄ±¸·Ý·½·¨£¬ËüÃÇ·Ö±ðÊǵ¼³ö£¯µ¼È루EXP/IMP£©¡¢Èȱ¸·ÝºÍÀ䱸·Ý¡£µ¼³ö±¸¼þÊÇÒ»ÖÖÂß¼­±¸·Ý£¬À䱸·ÝºÍÈȱ¸·ÝÊÇÎïÀí±¸·Ý¡£
Ò»¡¢ µ¼³ö£¯µ¼È루Export£¯Import£©
ÀûÓÃExport¿É½«Êý¾Ý´ÓÊý¾Ý¿âÖÐÌáÈ¡³öÀ´£¬ÀûÓÃImportÔò¿É½«ÌáÈ¡³öÀ´µÄÊý¾ÝËͻص½OracleÊý¾Ý¿âÖÐÈ¥¡£
£±¡¢ ¼òµ¥µ¼³öÊý¾Ý£¨Export£©ºÍµ¼ÈëÊý¾ ......

oracleѧϰ±Ê¼Ç2 ±íµÄ»ù±¾²Ù×÷

Oracle±íµÄ¹ÜÀí
±íÃûºÍÁÐÃûµÄÃüÃû¹æÔò£º
1±ØÐëÒÔ×Öĸ¿ªÍ·
2³¤¶È²»Äܳ¬¹ý30¸ö×Ö·û
3²»ÄÜʹÓÃOracleµÄ±£Áô×Ö
4Ö»ÄÜʹÓÃÈçÏÂ×Ö·û£ºA-Z,a-z,0-9,$,#µÈ
OracleÖ§³ÖµÄÊý¾ÝÀàÐÍ£º
1char ¶¨³¤£¬×î´ó2000×Ö·û
Àý×Ó£ºchar(10) ‘Ïþ»Ô’ Ç°Ëĸö×Ö·û·Å’Ïþ»Ô’£¬ºóÌíÁù¸ö¿Õ¸ñ²¹È«
2varchar2(20) ±ä³¤£¬×î´ ......

Oracleѧϰ±Ê¼Ç3 ¼òµ¥²éѯ

±íµÄ²éÕÒ£º
select * from emp where (sal>500 or job='MANAGER') and ename like 'J%';
ÒýºÅÀï±ßµÄ×Ö·ûÊÇÇø·Ö´óСдµÄ¡£
²éÕÒÖ®ºó°Ñ½á¹ûÅÅÐò£º
select * from emp order by sal asc;
ascÊÇÉýÐò£¬descÊǽµÐò
 
¶ÔÁÐÖØÃüÃû£¬Ö»Òª´ò¸ö¿Õ¸ñ£¬ºó¸úÐÂÁÐÃû¾Í¿ÉÒÔ
select ename,sal*12+nvl(comm,0)*12 "Äêн" from ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ