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
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Sum a column

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 is

SELECT TOP 10
Name,
LastName,
'10' AS ColumnTotal
FROM
Employees

Ive 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 ColumnTotal
FROM
Employees[/code]

you could even try just dropping braces. it will take it as int in most cases. if not,cast as above.
Go to Top of Page

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")
Go to Top of Page

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
Go to Top of Page

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
Go to Top of Page
   

- Advertisement -