Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft SQL Server > Use of having w...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 10994 of 11205
Post > Topic >>

Use of having with additional select

by Seguros Catatumbo <seguroscatatumbo@[EMAIL PROTECTED] > Apr 23, 2008 at 12:10 PM

Hello guys, i have this query:

select c8.cerveh, sum(c8.monto1) monto1,
       (select prima from arysauto a where a.cerveh=c8.cerveh)
priari,
       (sum(c8.monto1)-(select prima from arysauto a
                      where a.cerveh=c8.cerveh)) dif
from clpf08 c8
where c8.ramo=31 and c8.poliza=6100265 and
      c8.stcdcb=' ' and c8.cerveh in (select cerveh from arysauto)
and
      exists (select * from clpf07 where ramo=31 and poliza=6100265
and
      cerveh=c8.cerveh and actret<>'R')
group by c8.cerveh


That query prints the sum of a value and compares it with a
standalone
value in another table, and then outputs the difference between those
2 values.


Now i want the same query, but to only show the values that have a
difference in absolute value over 1 units. So i tried putting at the
end of the group by the following:


having (sum(c8.monto1) - (select prima from arysauto a where
                         a.cerveh = c8.cerveh) ) > 0


But the query doesn't run with some error that i have another
function
inside a funtion. If i remove the select inside the having and just
put a number it runs, so i am guessing it is the additional select.


There must be a way to do this, but i am stuck. Can someone help?
 




 5 Posts in Topic:
Use of having with additional select
Seguros Catatumbo <seg  2008-04-23 12:10:34 
Re: Use of having with additional select
Hugo Kornelis <hugo@[E  2008-04-23 21:52:54 
Re: Use of having with additional select
Seguros Catatumbo <seg  2008-04-23 13:49:49 
Re: Use of having with additional select
Hugo Kornelis <hugo@[E  2008-04-24 00:13:58 
Re: Use of having with additional select
"Plamen Ratchev"  2008-04-23 22:14:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Sun Jul 6 4:47:47 CDT 2008.