3 replaced http://stackoverflow.com/ with https://stackoverflow.com/ edited May 23 '17 at 12:40 The resulting answer with the original table looks like this: ``````with qtys as ( select 3 as qty from dual union all select 10 as qty from dual union all select 9 as qty from dual union all select 7 as qty from dual union all select 9 as qty from dual union all select 3 as qty from dual ) , results as ( select n qty from qtys x join ( select rownum n from dual connect by level <= ( select max(qty) from qtys ) ) y on y.n <= x.qty ) select max(qty) qty from ( select count(1) , qty from results group by qty having count(1) = ( select count(1) from qtys ) ); `````` I'm certain I can condense it a little, but it produces the desired result. EDIT I suppose looking closer at this taking the minimum would have produced the same, desired result: ``````with qtys as ( select 3 as qty from dual union all select 10 as qty from dual union all select 9 as qty from dual union all select 7 as qty from dual union all select 9 as qty from dual union all select 3 as qty from dual ) select min(qty) qty from qtys; `````` The resulting answer with the original table looks like this: ``````with qtys as ( select 3 as qty from dual union all select 10 as qty from dual union all select 9 as qty from dual union all select 7 as qty from dual union all select 9 as qty from dual union all select 3 as qty from dual ) , results as ( select n qty from qtys x join ( select rownum n from dual connect by level <= ( select max(qty) from qtys ) ) y on y.n <= x.qty ) select max(qty) qty from ( select count(1) , qty from results group by qty having count(1) = ( select count(1) from qtys ) ); `````` I'm certain I can condense it a little, but it produces the desired result. EDIT I suppose looking closer at this taking the minimum would have produced the same, desired result: ``````with qtys as ( select 3 as qty from dual union all select 10 as qty from dual union all select 9 as qty from dual union all select 7 as qty from dual union all select 9 as qty from dual union all select 3 as qty from dual ) select min(qty) qty from qtys; `````` The resulting answer with the original table looks like this: ``````with qtys as ( select 3 as qty from dual union all select 10 as qty from dual union all select 9 as qty from dual union all select 7 as qty from dual union all select 9 as qty from dual union all select 3 as qty from dual ) , results as ( select n qty from qtys x join ( select rownum n from dual connect by level <= ( select max(qty) from qtys ) ) y on y.n <= x.qty ) select max(qty) qty from ( select count(1) , qty from results group by qty having count(1) = ( select count(1) from qtys ) ); `````` I'm certain I can condense it a little, but it produces the desired result. EDIT I suppose looking closer at this taking the minimum would have produced the same, desired result: ``````with qtys as ( select 3 as qty from dual union all select 10 as qty from dual union all select 9 as qty from dual union all select 7 as qty from dual union all select 9 as qty from dual union all select 3 as qty from dual ) select min(qty) qty from qtys; `````` 2 added 432 characters in body edited Jul 28 '15 at 23:20 nathandelane 3155 bronze badges The resulting answer with the original table looks like this: ``````with qtys as ( select 3 as qty from dual union all select 10 as qty from dual union all select 9 as qty from dual union all select 7 as qty from dual union all select 9 as qty from dual union all select 3 as qty from dual ) , results as ( select n qty from qtys x join ( select rownum n from dual connect by level <= ( select max(qty) from qtys ) ) y on y.n <= x.qty ) select max(qty) qty from ( select count(1) , qty from results group by qty having count(1) = ( select count(1) from qtys ) ); `````` I'm certain I can condense it a little, but it produces the desired result. EDIT I suppose looking closer at this taking the minimum would have produced the same, desired result: ``````with qtys as ( select 3 as qty from dual union all select 10 as qty from dual union all select 9 as qty from dual union all select 7 as qty from dual union all select 9 as qty from dual union all select 3 as qty from dual ) select min(qty) qty from qtys; `````` The resulting answer with the original table looks like this: ``````with qtys as ( select 3 as qty from dual union all select 10 as qty from dual union all select 9 as qty from dual union all select 7 as qty from dual union all select 9 as qty from dual union all select 3 as qty from dual ) , results as ( select n qty from qtys x join ( select rownum n from dual connect by level <= ( select max(qty) from qtys ) ) y on y.n <= x.qty ) select max(qty) qty from ( select count(1) , qty from results group by qty having count(1) = ( select count(1) from qtys ) ); `````` I'm certain I can condense it a little, but it produces the desired result. The resulting answer with the original table looks like this: ``````with qtys as ( select 3 as qty from dual union all select 10 as qty from dual union all select 9 as qty from dual union all select 7 as qty from dual union all select 9 as qty from dual union all select 3 as qty from dual ) , results as ( select n qty from qtys x join ( select rownum n from dual connect by level <= ( select max(qty) from qtys ) ) y on y.n <= x.qty ) select max(qty) qty from ( select count(1) , qty from results group by qty having count(1) = ( select count(1) from qtys ) ); `````` I'm certain I can condense it a little, but it produces the desired result. EDIT I suppose looking closer at this taking the minimum would have produced the same, desired result: ``````with qtys as ( select 3 as qty from dual union all select 10 as qty from dual union all select 9 as qty from dual union all select 7 as qty from dual union all select 9 as qty from dual union all select 3 as qty from dual ) select min(qty) qty from qtys; `````` 1 answered Jul 28 '15 at 22:42 nathandelane 3155 bronze badges The resulting answer with the original table looks like this: ``````with qtys as ( select 3 as qty from dual union all select 10 as qty from dual union all select 9 as qty from dual union all select 7 as qty from dual union all select 9 as qty from dual union all select 3 as qty from dual ) , results as ( select n qty from qtys x join ( select rownum n from dual connect by level <= ( select max(qty) from qtys ) ) y on y.n <= x.qty ) select max(qty) qty from ( select count(1) , qty from results group by qty having count(1) = ( select count(1) from qtys ) ); `````` I'm certain I can condense it a little, but it produces the desired result.