473,387 Members | 1,904 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.

Using an if statement

I have a column in a table... ColumnA
ColumnA contains positive and negative numbers
What I want to do is insert an expression that basically does the
equivalent of the following excel formula..

If(ColumnA>=0,"Use","Ignore")

What should I change the following syntax to?

SELECT *, ColumnA AS Expr1
FROM Table

Regards,
Ciarán

Jul 23 '05 #1
2 1110
SELECT *,
CASE WHEN columnA>=0 THEN 'Use' ELSE 'Ignore' END AS expr1
FROM Table

--
David Portas
SQL Server MVP
--

Jul 23 '05 #2
You're probably looking for CASE (see Books Online):

select case when ColumnA >= 0 then 'Use' else 'Ignore' end as 'Expr1'
from dbo.MyTable

Simon

Jul 23 '05 #3

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

Similar topics

4
by: Japhy | last post by:
Hello, I'm am pulling data from a mysql db and want to use the data to populate a <ul. Here are relavent parts of my code : $wohdate = mysql_result($wohRS,$wohndx,woh_date); $woh_display...
4
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to...
5
by: Bill Priess | last post by:
Hey gang, Ok, I'm stumped on this one... I am using the using statement to wrap a SqlDataAdapter that I am using to fill a DataTable. Now, what I need to know is, just how much block-scope...
5
by: charliewest | last post by:
I've implemented the USING statement to ensure that my newly created sql connection closes when my method is finished using it. The USING statement is wrapped in try/catch error handling statement....
8
by: Andrew Robinson | last post by:
Are these two equivalent? Is one better than the other? I tend to go with #1 but started wondering.... Thanks, 1: using (SqlConnection cn = new SqlConnection(DataConnection)) using...
2
by: Robert Bravery | last post by:
Hi all, Being new to C# and .net I often don't know how to use things. I have created an app that imports excel data, it works well, with methods to open excel, extract the data and close excel....
6
markmcgookin
by: markmcgookin | last post by:
Hi Folks, I am running a simple query using VB (This isnt a VB Question, dont worry!) on SQL Server Compact. I have the query below being created, and then added to if a flower location doesn't...
4
by: Jure Bogataj | last post by:
Hello! I'm using .NET 2005 (C#) and I've come across using statement. It seems ok, I was just wondering one thing. What if I returned object inside using statement using RETURN directive. Is...
13
by: jkimbler | last post by:
As part of our QA of hardware and firmware for the company I work for, we need to automate some testing of devices and firmware. Since not everybody here knows C#, I'm looking to create a new...
15
by: tshad | last post by:
Do I still need to close an object in a finally statement after a catch if it is part of a using statement? For example: FileStream fs = null; try { using (FileInfo fInfo = new...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.