日期:2014-05-16 浏览次数:20555 次
聽鍏堣鏄庝笅涓氬姟鏌ヨ涓昏瀛楁(id,org_code,org_name,org_count鍏朵腑org_count涓鸿绠楃粺璁″嚭鐨勬暟閲?鎸夋暟閲忓墠10鏉″€掑簭鎺掑垪棣栧厛鑰冭檻鍒扮敤鍒嗛〉杈撳嚭鏉ユ帶鍒舵晥鐜?/p>
鍏堣创涓婅鍙?/p>
SELECT t.ID,t.ORG_CODE,t.ORG_NAME,t.ORG_COUNT from
(SELECT ROWNUM RN ,A.ID,A.ORG_CODE,A.ORG_NAME,A.ORG_COUNT FROM
(SELECT c.ID,c.ORG_CODE,c.ORG_NAME,
(SELECT count(ID) from llt_report b where b.SEND_ORG_ID=c.ID) as ORG_COUNT from Llt_Org_Info c order by ORG_COUNT desc)
聽A WHERE ROWNUM <=10) t WHERE RN >0
聽
鍥犱负oracle 涓笉鏀寔top 鍏抽敭瀛楋紝鍒嗛〉鍙兘闈爎ownum 鏉ユ帶鍒舵潯鏁版潵鏄剧ず锛屼絾鏈€鍐呭眰鏌ヨ鏃跺凡缁忔妸鎵€鏈夌粨鏋滈兘鎵弿涓€閬?/p>
SELECT c.ID,c.ORG_CODE,c.ORG_NAME,
(SELECT count(ID) from llt_report b where b.SEND_ORG_ID=c.ID) as ORG_COUNT from Llt_Org_Info c order by ORG_COUNT desc
鍦ㄧ敤鍒嗛〉鎺у埗鏃跺氨鏄鎵€鏈夋煡璇㈢粨鏋滃垎椤?骞舵病鏈夊彧鏌?0鏉$劧鍚庡杩?0鏉℃帓搴?涔熷氨鏄鍒嗛〉骞舵病鏈夎捣鍒颁富瑕佷綔鐢?
濡傛灉鍦ㄦ煡璇腑鐢≧OWNUM 鎺у埗浣忔潯鏁颁絾缁撴灉鍙堜笉瀵?br>SELECT c.ID,c.ORG_CODE,c.ORG_NAME,
(SELECT count(ID) from llt_report b where b.SEND_ORG_ID=c.ID) as ORG_COUNT from Llt_Org_Info c
where聽rownum<=10聽order by ORG_COUNT desc
聽
缁忚繃鍙嶅娴嬭瘯鍙戠幇闂涓昏闆嗕腑鍦╫rder by 鎺掑簭鍚庢晥鐜囨槑鏄句笅闄?璇存槑鏌ヨ鏃秓racle鍏堝琛ㄧ粺涓€鏌ヨ涓€閬嶇劧鍚庡張鎺掑簭閲嶆墽琛屼竴閬?锛侊紒(浣嗘帓搴忓繀椤讳繚鐣?
棣栧厛oracle涓劅瑙夊垎椤靛お绻佺悙锛屼笉鏂灞傚眰缁撴灉闆嗚繘绋嬫搷浣滐紝棰戠箒浣跨敤select鏌ヨ 澧炲姞瀵硅〃鐨勬搷浣滄鏁伴檷浣庝簡鏌ヨ鏁堢巼
聽
10鏉℃煡璇㈣€楁椂绾?.4绉?/p>
聽
閭d箞Oracle涓浣曟搷浣滅粺璁$殑瀛楁鎺掑簭
浼樺寲鐨勫嚑鐐瑰缓璁細
1鍋ュ.鐨剆ql涓嶈渚濊禆鏁版嵁杩涜鏉′欢杩囨护锛岃鏍规嵁琛ㄧ殑鍒濊》璁捐鏉ヨ繘琛岃繃婊ゆ潯浠?/p>
2瑕侀€夊ソ鍩虹琛紝(鍩虹琛ㄦ爣鍑?淇℃伅娑电洊鍏紝鏁版嵁閲忓敖鍙兘灏?濂芥瘮闆姳鍨嬭璁′腑鐨勪腑蹇?
聽
鐜板湪鑰冭檻鐩存帴绛涢€夊嚭鎵€闇€瀛楁锛岀粍鎴愮粨鏋滈泦
--浼樺寲鍚?br>select t.send_org_id,
(select a.org_code from llt_org_info a where a.id=t.send_org_id) as org_code,
(select a.org_name from llt_org_info a where a.id=t.send_org_id) as org_name,
count(t.send_org_id) as count_send_org_id聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ----缁熻鏁伴噺鐨勫瓧娈?/p>
from llt_report t
where t.send_org_id in (select id from llt_org_info)聽聽聽聽聽聽 --杩囨护闈炴墍闇€淇℃伅
group by t.send_org_id order by count_send_org_id desc
聽
聽
聽
聽鑰楁椂澶х害0.09绉?/p>
鏁堢巼鏈変簡璐ㄧ殑鏀瑰彉
鎬荤粨:oracle涓帓搴忎笉寤鸿鐢╫racle涓彁渚涚殑ROWNUM鍒嗛〉锛屽洜涓篟OWNUM鍙兘瀵规煡璇㈢殑鎵€鏈夌粨鏋滃湪杩囨护锛屽苟娌″湪鏌ヨ涓帶鍒舵暟閲?锛屽缓璁洿鎺ョ瓫閫夊瓧娈垫帓搴忎笉浠呭噺灏戜簡SELECT鐨勯绻佷娇鐢紝涔熶娇璇彞缁撴灉鏇村姞鏄庢湕锛?/p>
聽
聽
聽