Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
fofa4ever
Starting Member
3 Posts |
Posted - 2012-09-14 : 08:28:43
|
Hi all,I'm writing query similar to this, my question is how to add this condition(sum(r.engine)>100) to the query select a.name a.policy c.Id c.contact (select sum(r.engine) from car r where p.policy=r.policy) from policy p outer join client c on a.policy=c.policyI've tried to repeat this where (select sum(r.engine) from car r where p.policy=r.policy)>100 in the end of the query but the performance was slowly |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-09-14 : 08:44:01
|
[code]select p.name, p.policy, c.Id, c.contact, e.enginefrom policy p inner join client c on p.policy = c.policy inner join ( select policy, engine = sum(engine) from car group by policy having sum(engine) > 100 ) e on p.policy = e.policy[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|