Solved

Case Statement SQL 2008 Issue

Posted on 2011-09-29
1
221 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
1 Comment
 
LVL 15

Accepted Solution

by:
Eyal earned 500 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

831 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