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 2000 Forums
 Transact-SQL (2000)
 Dynamic Crosstabs T-SQL

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-08-08 : 07:36:48
Craig writes "Hi all
I found this article, http://www.sqlteam.com/item.asp?ItemID=2955, and it works like a charm, until I start to use multiple calculations (eg1) within the pivot when it fails dramatically.

I thought the syntax of the calculation was incorrect, but when I break it down to the individual parts (eg2/eg3), the execute works.

Does anyone know how to overcome this.

eg1
'100*sum(CASE WHEN DaysOD IS NOT NULL AND DaysOD <= tblDefStd.DefStd THEN 1 ELSE 0 END) / sum(CASE WHEN DateClosed IS NOT NULL THEN 1 ELSE 0 END)', ' Month(DateRaised) ', 'tblDefect'

eg2
'100*sum(CASE WHEN DaysOD IS NOT NULL AND DaysOD <= tblDefStd.DefStd THEN 1 ELSE 0 END)',
' Month(DateRaised) ', 'tblDefect'

eg3
'100*sum(CASE WHEN DateClosed IS NOT NULL THEN 1 ELSE 0 END)',
' Month(DateRaised) ', 'tblDefect'"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-08 : 12:36:17
See if this helps
http://weblogs.sqlteam.com/jeffs/archive/2005/05.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-08 : 12:37:04
This article might shed some light in your problem.
http://www.sqlservercentral.com/columnists/plarsson/pivottableformicrosoftsqlserver.asp

Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -