oracle - How to rewrite a SQL query that contains repeated SubQuery? -



oracle - How to rewrite a SQL query that contains repeated SubQuery? -

could help me rewrite sql query below in short ? there subquery repeated.

update policy set totalvehicles = ( select count(*) riskunit riskunit.policyid = policy.id , riskunit.subtype = 7) policy.verified = '1' , policy.totalvehicles <( select count(*) riskunit riskunit.policyid = policy.id , riskunit.subtype = 7 );

thanks !!

i prefer because it's easy insert select above , see changed.

update p set totalvehicles = cnt.[count] policy p inner bring together ( select policyid,count(*) [count] riskunit ru.subtype = 7 grouping policyid ) cnt on cnt.policyid=p.policyid p.verified = '1' , p.totalvehicles < cnt.[count]

sql oracle

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -