p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   SQL Server 2000 (http://p2p.wrox.com/forumdisplay.php?f=20)
-   -   select query (http://p2p.wrox.com/showthread.php?t=23950)

collie January 16th, 2005 03:27 PM

select query

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?


jemacc January 16th, 2005 09:17 PM

you may want to create a UDF for this

but here is my try:


      isnull(IDNO,'') + isnull(Passport,'')as SID
FROM Student

Jaime E. Maccou

collie January 17th, 2005 03:13 AM

Thanks i will try it

All times are GMT -4. The time now is 09:08 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.