Hi,
I have a problem with the following SQL query:
<cfquery datasource="#db#">
SELECT Field1, Avg(Val(Field2)) AS avg_field2
FROM Table1
GROUP BY Field1
</cfquery>
The above query works fine for the Access database, in which the data type of Filed2 is Text. After I exported the Access database to SQL Server, the datatype of Field2 was changed to nvarchar, and the above query doesn't work. It first says "Val" is not a valid function. I changed it to Avg(#Val(Field2)#), then ColdFusion is unable to determine the value of "Feild2". I replaced Val with Evaluate, the same thing.
I know this is a simple question, but can anyone help me out? Thanks!
cshncn
I have a problem with the following SQL query:
<cfquery datasource="#db#">
SELECT Field1, Avg(Val(Field2)) AS avg_field2
FROM Table1
GROUP BY Field1
</cfquery>
The above query works fine for the Access database, in which the data type of Filed2 is Text. After I exported the Access database to SQL Server, the datatype of Field2 was changed to nvarchar, and the above query doesn't work. It first says "Val" is not a valid function. I changed it to Avg(#Val(Field2)#), then ColdFusion is unable to determine the value of "Feild2". I replaced Val with Evaluate, the same thing.
I know this is a simple question, but can anyone help me out? Thanks!
cshncn