Thread: select query
View Single Post
  #1 (permalink)  
Old January 16th, 2005, 03:27 PM
collie collie is offline
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
Default select query

Hi,

I have a table with 2 fields:

passport varchar
idNo numeric


I have to display the fields in one column
If idNo is null then I want to show the passport number in the column but if neither passport or idNo are null then I want to show the idNo.

I tried the following select query but it only works if both fields are numeric and i can't change the data type for one of the fields as it will coz huge problems:
select idno,passport,
(case when idno is null then passport else idno end) as sid
from student

How can I make it work?

Thanks


Reply With Quote