?
Solved

Case Statement SQL 2008 Issue

Posted on 2011-09-29
1
Medium Priority
?
225 Views
Last Modified: 2012-05-12
I have the following Case Statement:

Case When PCYTD_1.PC_YTD - PCB_1.PC_Base >=  dbo.tblPIF_Size.Goal_PC Then  Dense_Rank() Over (partition by PCB_1.Terr Order By PCYTD_1.PC_YTD - PCB_1.PC_Base desc)     Else 0 End as Rank      

It states that When a total ( PCYTD_1.PC_YTD - PCB_1.PC_Base) is >= to a Goal then Rank that result. Otherwise (Else) show 0.

HOWEVER I do NOT want the 0 I want the 0 to be 'NOT MET'

My problem is that I have a data type issue as the first parts are int and my else would be char. I tried to Cast, but no luck.

Can someone asssit. Thank you.  

0
Comment
Question by:SeTech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
Eyal earned 2000 total points
ID: 36813997
try this

Case When PCYTD_1.PC_YTD - PCB_1.PC_Base >=  dbo.tblPIF_Size.Goal_PC Then  cast(Dense_Rank() Over (partition by PCB_1.Terr Order By PCYTD_1.PC_YTD - PCB_1.PC_Base desc) as nvarchar)     Else 'NOT MET' End as Rank     

Open in new window

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question