Õâ¸öSQLÓï¾äÔõôд? - Oracle / »ù´¡ºÍ¹ÜÀí
Õâ¸öSQLÓï¾äÔõôд?
ÏÖÔÚÓÐÒ»¸ö±íT,ÀïÃæ¾Í3¸ö×Ö¶Î
ѧÉúID(sid)¿Î³Ì(cName)³É¼¨(score)
1 1 75
2 2 90
3 2 60
4 3 89
5 3 80
6 3 70
ÎÒÏÖÔÚÏëÖªµÀµÃµ½µÄ½á¹ûÊÇ:ÿÃſγÌÅÅÔÚǰÁ½ÃûµÄѧÉúµÄID,Ó¦¸ÃÔõÃ´Ð´ÄØ?
SQL code:
select k.*
from (select sid,
cname,
score,
rank() over(partition by cname order by score desc) rn
from t) k
where k.rn <= 2
SQL code:
select m.* from
(
select t.* , row_number() over(partition by cName order by score desc) px from tb t
) m
where px <= 2
select m.* from
(
select t.* , (select count(1) from tb where cName = t.cName and score > t.score) + 1 from tb t
) m
where px <= 2
select id,cname from
(select id,cname,rank () over (partition by cname order by score desc) rk
from t)
where rk<=2;
SQL code:
SQL>
SQL> with t as (
2 select 1 sid, 1 cname, 75 score from dual union all
3 select 2, 2, 90 from dual union all
4 select 3, 2, 60 from dual union all
5 select 4, 3, 89 from dual union all
Ïà¹ØÎÊ´ð£º
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
private static final String URL = "jdbc:oracle:thin:@localhost:1521:orcl";
private static final String USERNAME = "sys";
private static final String PASSWORD = "s ......
ÔÚϵͳÔËÐеÄʱºò×ÜÊÇÓÐÒ»¿é´ÅÅÌʼÖÕÉÁºìµÆ£¬½øÈëϵͳºó
#topas²é¿´×ÜÊÇÓÐÒ»¿é´ÅÅÌ%BUSYΪ90%ÒÔÉÏ£¬
Êý¾Ý¿â°æ±¾£ºoracle 9.2.0.7
Êý¾ÝÎļþ¹ÒÔØµÄ½Úµã£º/oradata/pcs/ Âß¼¾íºÅlv04
#lslv -l lv04
......
oracle 11g °²×° 01092 ´íÎó,
ÈÕÖ¾ÐÅÏ¢£º
[oracle@linux trace]$ vi alert_orcl.log
MMON started with pid=14, OS id=9089
RESETLOGS after incomplete recovery UNTIL CHANGE 522752
Errors in file / ......
oracleµÄ°²×°ºÍʹÓö¼ºÜÄÑÂð£¿ÔÀ´Ê²Ã´¶¼²»»áʱѧÁËMySQL£¬Ò²Ã»Ôõôѧ¹ý£¬¾Í×Ô¼º×°¼¸´Î£¬Óü¸Ï£¬¾Í´ïµ½ÁË´óÌåÄÜʹÓõij̶ÈÁË£¬¿ÉÊÇoracleµ½ÏÖÔÚ²»»á×°²»»áÓ㬲»»áÅ䣬ÎÒ¾ÍÏë×°¸öoracle£¬È»ºó½¨¸öÊý¾Ý¿â£¬ÀïÃæÓм¸Õ ......