473,387 Members | 1,693 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,387 software developers and data experts.

Replace one value with another in query result

Hi,

I am only starting to dabble in SQL and would like some help with the following.

I have a field called type which holds a number between 0 and 13.

If the value is 1 or 3 then I would like the result in the query to be 'yes' if not then it should be 'no' .

I think this sounds like I should use the case function and do some thing clever and simple, at the moment I do a search and replace in excel to get the correct output.

any help would be great.

Harry
Feb 24 '08 #1
3 13823
jagged
23
Hi,

I am only starting to dabble in SQL and would like some help with the following.

I have a field called type which holds a number between 0 and 13.

If the value is 1 or 3 then I would like the result in the query to be 'yes' if not then it should be 'no' .

I think this sounds like I should use the case function and do some thing clever and simple, at the moment I do a search and replace in excel to get the correct output.

any help would be great.

Harry
Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. CASE 
  3. WHEN [type] = 1 OR [type] = 3 THEN 'yes' 
  4. ELSE 'no' 
  5. END 
  6. FROM table_name
Feb 25 '08 #2
debasisdas
8,127 Expert 4TB
Using CASE is the best solution.

and performance wise that is very fast.
Feb 25 '08 #3
Works perfectly thanks guys.

Harry
Feb 25 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Joe Gazda | last post by:
I'm a relative newbie to PHP, but have been able to put together some PHP code to generate a CSV/XLS file from a Query result. Now, I would like to include custom column names instead of the MySQL...
3
by: Jack | last post by:
Hi, I have a form when loaded, retrieves record from an access table. Among other fields there is a check box called FinalUpdate. This is tied to a field in Access of type Yes/No. The form...
5
by: Daniel Tan | last post by:
Are there anyway to copy rows of records from one query to another query and then hide the records in source query ? Pls advise. Thanks. Regards, Daniel
8
by: skinnybloke | last post by:
Hi - I am a newbie to Access & SQL and I would appreciate some help on this if at all possible. I have a query that contains the following code. SELECT DISTINCT Product. AS , Product. AS ; ...
3
by: milam | last post by:
Greetings, I would like to use a query result as a column name in another query, I can't seem to get this to work using Subqueries. Is there a good way to do this? Example: Table...
3
by: Gil D. | last post by:
Hello, I have a query with 2 sub queries. Each query returns one value. My query should sum these values and display the sum. For example: sub query 1 returns 5 sub query 2 returns 10 my...
7
by: Triple7 | last post by:
Hi there, basically what I am trying to do (without using code as I don’t know how to do that with a code) is to retrieve the previous 5 days & the next 5 days (date wise)against a query1 that...
30
by: Noob | last post by:
ftp://ukcassassin:winston@www.ukcassassin.pwp.blueyonder.co.uk/htdocs/Diary%20Form.bmp Hi all I will appologise in advance for my lack of knowledge of access and its working as i am quite new to...
3
by: robin1983 | last post by:
HI all, how are you ? i need help from you people. This time my problem is that i m running a query inside another query. But, the result that i got is something not exactly what i want. and one...
5
by: ndeeley | last post by:
Hi, This is driving me mad - can someone guide me in the right direction please? I am outputting the results of a query to a webpage - in this case drawings in a database. The user selects the...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.