Solved

Modify select query to return certain values based on particular values

Posted on 2011-02-17
3
190 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 142

Accepted Solution

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

Expert Comment

by:HainKurt
ID: 34917527
use this in select

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

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

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

Suggested Solutions

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

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

21 Experts available now in Live!

Get 1:1 Help Now