?
Solved

Modify select query to return certain values based on particular values

Posted on 2011-02-17
3
Medium Priority
?
230 Views
Last Modified: 2012-05-11
Experts,
             I have the following query
Select EventType
FROM tablename
In the database EventType is either stored as a 0 or 1. Is it possible to modify the select query so that if EventType is 1 it returns "Open" and when it is zero it returns the string "Click"

Thanks,
Aditya
0
Comment
Question by:pmac38CDS
[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
  • 2
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 34917437
select eventType, case EventType when 1 then 'Click' when 0 then 'Open' else '/' end EventType2 from tablename
0
 
LVL 57

Expert Comment

by:HainKurt
ID: 34917527
use this in select

case EventType when 1 then 'Open' else 'Click' end EventType  
0
 
LVL 57

Expert Comment

by:HainKurt
ID: 34917551
or

case
when EventType=1 then 'Open'
when EventType=0 then 'Click'
else 'NA'
end as EventType
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

777 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