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.
Author |
Topic |
jamie_pattison
Yak Posting Veteran
65 Posts |
Posted - 2008-10-01 : 07:06:14
|
Im trying to sum a column.As a test my SQL isSELECT TOP 10 Name, LastName,'10' AS ColumnTotalFROM EmployeesIve manually placed "10" in each row for the column "ColumnTotal". I add a text box and add this code to the expression field:=Sum (Fields!ColumnTotal.Value, "DataSource1")This returns back as an error.How could i resolve this?Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-01 : 07:38:45
|
[code]SELECT TOP 10 Name, LastName,CAST(10 AS int) AS ColumnTotalFROM Employees[/code]you could even try just dropping braces. it will take it as int in most cases. if not,cast as above. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-01 : 07:40:13
|
and if you dont want to tweak sql behind use=Sum (val(Fields!ColumnTotal.Value), "DataSource1")or=Sum (Cint(Fields!ColumnTotal.Value), "DataSource1") |
 |
|
jamie_pattison
Yak Posting Veteran
65 Posts |
Posted - 2008-10-01 : 07:41:24
|
I removed the ' from 10 and it resolved...Edit:Thanks ill try that out too |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-01 : 07:51:33
|
quote: Originally posted by jamie_pattison I removed the ' from 10 and it resolved...Edit:Thanks ill try that out too
Cheers |
 |
|
|
|
|