?
Solved

Modify select query to return certain values based on particular values

Posted on 2011-02-17
3
Medium Priority
?
238 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
  • 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 61

Expert Comment

by:HainKurt
ID: 34917527
use this in select

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

850 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