Solved

Case Statement SQL 2008 Issue

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
In this article I will describe the Backup & Restore 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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 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

20 Experts available now in Live!

Get 1:1 Help Now