Solved

Case Statement SQL 2008 Issue

Posted on 2011-09-29
1
224 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 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
In this article I will describe the Detach & Attach 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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

729 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