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 |
|
Irfan.abdullah
Starting Member
9 Posts |
Posted - 2012-08-09 : 20:42:28
|
| HiI'm trying to create a case statement which looks at the value of a measure and based on whether it is greater than or less than 50,000 it should give me a character or dimension object back as my result. Definition: Case WHEN (dbo.fact_Opportunity.TCV_Amt_USD <= 50000) THEN 'Under 50k'WHEN (dbo.fact_Opportunity.TCV_Amt_USD >= 50000) THEN dbo_dim_OpportunityOwner.Level_1_Presentation_NameElse 'Null'EndThe issue I am having is when I put Else 0, I get a data type error. When I put Else 'Null' the query just runs forever When I define the statement as :Case WHEN (dbo.fact_Opportunity.TCV_Amt_USD <= 50000) THEN 'Under 50k'Else dbo_dim_OpportunityOwner.Level_1_Presentation_NameEndThat runs forever too. Thanks in Advance |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2012-08-10 : 01:40:02
|
| Few questions:1- What is the datatype of column fact_Opportunity.TCV_Amt_USD ???2- How many records you have in your targt table ???3- Is there any index applied on column fact_Opportunity.TCV_Amt_USD ???--------------------------http://connectsql.blogspot.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-10 : 10:03:52
|
| the issue is not with case...when but with way overall query is written. Analyse the query's execution plan and see costly steps.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|