我正在寻找一种方法来将那些在“n_version1”中没有任何数字的对象列表分开超过10个。你能帮助我吗?
输出应该如下:
我试图在HAVING中对n_version1列求和,但这不是正确的方法。 我正在使用Pl / SQL,oracle 9i。
答案 0 :(得分:2)
使用NOT EXISTS
SELECT *
FROM table t1
WHERE NOT EXISTS (
SELECT *
FROM table t2
WHERE t1.v_object_name = t2.v_object_name AND t2.n_version > 10
)
或NOT IN
SELECT *
FROM table t1
WHERE t1.v_object_name NOT IN (
SELECT t2.v_object_name
FROM table t2
WHERE t2.n_version > 10 AND t2.v_object_name IS NOT NULL
)
答案 1 :(得分:2)
您可以使用分析函数在单个表扫描中执行此操作:
SELECT v_object_name,
n_version1
FROM (
SELECT v_object_name,
n_version1,
COUNT( CASE WHEN n_version1 >= 10 THEN 1 END )
OVER ( PARTITION BY v_object_name ) AS num_invalid
FROM your_table
)
WHERE num_invalid = 0;
答案 2 :(得分:1)
使用:
mvn install:install-file -Dfile=<path-to-file> -DpomFile=<path-to-pomfile>
答案 3 :(得分:1)
有一个派生表,返回具有最大版本&lt; = 10的v_object_names。加入该结果:
select t1.v_object_name, t1.n_version1
from tablename t1
join (select v_object_name
from tablename
group by v_object_name
having max(n_version1) <= 10) t2
on t1.v_object_name = t2.v_object_name