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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 group by condition

Author  Topic 

issammansour
Yak Posting Veteran

51 Posts

Posted - 2007-08-20 : 14:58:45
Hi,

I Have the following "select statement" with "group by condition", I want the outgoing result for the query to be vno with (scamt <> sdamt) the example is as following:-


select vno,vtype,tdate,sum(camt) as scamt,sum(damt) as sdamt
from transact
where year = 2007
group by vno,vtype,tdate
HAVING (scamt <> sdamt)
order by vno

but i have the following error

Invalid column name 'sdamt'.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-20 : 15:03:04
HAVING sum(camt) <> sum(damt)



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-20 : 15:03:48
Also see
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=88108



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -