Click to See Complete Forum and Search --> : SQL question - thanks


rayxu
March 22nd, 2001, 11:13 PM
I don't know what is wrong in the following

------------

SELECT @SQL2 = "INSERT INTO #ACETmp " +
"SELECT rptSection = 'A',
Field1 = SummValue,
Field2 = sum(ItemAmount) " +
" FROM vRptbase2
where trantype in ( '33','35') group by SummValue"
execute (SQL2)
--------------------

something wrong with "sum(ItemAmount)". I don't know how to place it correctly. It is how to put "sum(ItemAmount)" within double "".

Please help me out. thanks

sotoasty
March 23rd, 2001, 07:58 AM
Not sure if this is the problem but when you use a Calculation function in SQL you have to give it a field name. For example...

SELECT SUM(FieldtoSum) as MySum FROM myTable;

Hope this helps