---
title: "oracle 子查询写法"
author: "#rethink#"
date: "2010-06-12T16:13:00Z"
tags: []
slug: "oracle"
draft: false
lastmod: "2010-06-12T16:13:00Z"
id: 803737
url: "https://rethink2.iteye.com/blog/803737"
---

1

select sub\_table.num,sub\_table.job\_id

from (

select count(\*) as num,t.job\_id 

from dir\_irai t group by t.job\_id order by num desc

) 

sub\_table where sub\_table.num&gt;1

2　　 

select distinct sub\_table.num,t2.job\_id,t2.anken\_id,t2.client\_id

from (

select count(\*) as num,t.job\_id 

from dir\_irai t group by t.job\_id order by num desc

) sub\_table,dir\_irai t2

where sub\_table.num&gt;1 and sub\_table.job\_id=t2.job\_id 

order by t2.job\_id