Solved

Case Statement SQL 2008 Issue

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

929 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now