View Single Post

   
  #3 (permalink)  
Old 03-06-2008, 02:04 PM
Vic
 
Posts: n/a
Default Re: Each GROUP BY expression must contain at least one column that isnot an outer reference

On Mar 4, 11:32 am, czytacz <redak...@dupa.gazeta.pl> wrote:
> @fieldname is treated like a constant value,
> so no another group is returned


So I tired to modify the stored procedure a little bit as below
Declare @TableNullCount int
Declare @TableValidCount int

select @TableNullCount = (SELECT Count(*)
from TestData6061.dbo.accounting
WHERE (AutomationType = 'loader') AND ([Negative Testcase] = 0)
AND ([01-RecordClass] = @ObjectType) AND
([02-RecordAction]= 'New') AND ('['+@FieldName+']+ IS NULL') )
print @ObjectType
print '['+@FieldName+'] IS NULL'
print @TableNullCount

/*select @TableValidCount = (SELECT Count(*)
from TestData6061.dbo.accounting
WHERE (AutomationType = 'loader') AND ([Negative Testcase] = 0)
AND ([01-RecordClass] = @ObjectType) AND
([02-RecordAction]= 'New') AND ('['+@FieldName+'] IS NOT NULL') )

print @TableValidCount

SELECT DISTINCT @ObjectClass as ObjectClass,@ObjectType as
ObjectType,@RecordAction as RecordAction,@FieldName as FieldName,
@TableValidCount as VALIDCount, @TableNullCount as NULLCount

FROM TestData6061.dbo.accounting
WHERE (AutomationType LIKE 'loader') AND ([Negative Testcase] =
0) AND (@ObjectType = @ObjectType) AND (@RecordAction = 'New')

GROUP BY [01-RecordClass],[02-RecordAction] */

some commented code but basically I am trying to get the total number
of rows (ValidCount) and (NullCount) seperately and use that in the
3rd select statement but it gives me an error saying 'An expression of
non-boolean type specified in a context where a condition is expected,
near ')'. Which is @FieldName in the select statement. Am I doing
anything wrong here?
Reply With Quote