473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

SQL Query - modifying return values

How can I modify return values?

i.e. I perform a query:

SELECT STATUS
FROM USERS

RESULTS
=======
1
2
1
1
1
2
2
3
4

I want to replace the results to display:

RESULTS
=======
Active
Inactive
Active
Active
Active
Inactive
Inactive
Trial
Demonstration

Is there a way to do this within the SQL statement???

May 23 '07 #1
2 1608
On May 23, 10:27 pm, swami <sivaswamim...@gmail.comwrote:
db2 =select case s1 when 0 then 'Active' when 1 then 'InActive' end
"STATUS" f
rom statustable

STATUS
--------
InActive
InActive
InActive
Active
Active
Active
Active
InActive

8 record(s) selected.
Thanks swami

May 24 '07 #2
Hi whitsey,

if you have a table, that relates the numbers to strings, use this table to
join. If not, you could use a common table expression "result" and join it
like this:

with result( num, str ) as
(
values (1, "Active"),
(2, "Inactive"),
(3, "Trial"),
(4, "Demo")
)
select result.str
from users, result
where users.status = result.num

Not tested, might need minor adjustments, but you get the idea?

HTH,

Joachim Banzhaf
whitsey wrote:
How can I modify return values?

i.e. I perform a query:

SELECT STATUS
FROM USERS

RESULTS
=======
1
2
1
1
1
2
2
3
4

I want to replace the results to display:

RESULTS
=======
Active
Inactive
Active
Active
Active
Inactive
Inactive
Trial
Demonstration

Is there a way to do this within the SQL statement???
May 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bob Bedford | last post by:
I've a table on mysql: code1 tinyint, code2 tinyint, notcode1 varchar(20),notcode2 varchar(20),label I do have some records: values(1,null,null,null,'text1');...
3
by: DaveHayzen | last post by:
The following SQL query :- SELECT CardHolder.RecordID, History.GenTime, History.Link1 FROM History FULL OUTER JOIN Card ON History.Param3 = LTRIM(RTRIM(Card.CardNumber)) FULL OUTER...
4
by: Orion | last post by:
Hi, This is kind of last minute, I have a day and a half left to figure this out. I'm working on a project using ms-sqlserver. We are creating a ticket sales system, as part of the system, I...
2
by: Betrock | last post by:
This is probably very simple, but I just can't see my way thru it..... Short version: keyed values(numeric)in a lookup table are stored in a main table. They are displayed as text values - the...
7
by: Dave Hopper | last post by:
Hi I posted a question recently regarding problems I am having getting a value from a list box to use in a query. I got a lot of help, for which I thank you and it's nearly working! But I need...
0
by: Jeff Boes | last post by:
I hope this helps someone else ... I had struggled some time ago with attempts to get a rank of values query to work, but then I gave up and set it aside. I had another reason to attack it, and in...
3
by: ILCSP | last post by:
Hello, I'm fairly new to the concept of running action pass through queries (insert, update, etc.) from Access 2000. I have a SQL Server 2000 database and I'm using a Access 2K database as my...
7
by: KoliPoki | last post by:
Hello every body. I have a small issue. Problem: I have a table with 4 descriptor columns (type). I need to formulate a query to retrieve a count for each type so I can group by...etc. The...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.