Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

displaying if statement as a column

Status
Not open for further replies.

CSOP

Technical User
Sep 26, 2003
9
GB
Hi there,

Does anyone know if it is possible to do this. eg:

IF ((ColumnA <ColumnB)OR (Column A <ColumnC)) AS CALC

Many thanks
 
I'm not entirely sure what you're trying to do - it may help if you post more of the query. It looks like you're trying to do something like a CASE expression.

--James
 
ideally i want to define a new column, which isnt held in the database which should hold my new value (the results of the if statement)

In this column i want the output of the if statment

eg Query

select id_no, account, balance, odlimit
from table a

IF ((odlimit = '00' AND balance < '00') OR (odlimit = '500' AND balance < '-500'))

//return results into NEWCOLUMN AS 'Y'

//but don't know syntax

Cheers mate :)
 
OK, you will need a CASE expression as I thought. The basic syntax would be something like:

Code:
SELECT id_no, account, balance, odlimit,
  CASE
    WHEN (odlimit = '00' AND balance < '00') OR (odlimit = '500' AND balance < '-500') THEN 'Y'
    ELSE 'N'
  END AS newcolumn
FROM tbl

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top