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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query quandry

Status
Not open for further replies.

raynkel

Programmer
Oct 24, 2002
23
US
I am using an SQL database to track parking.
I am trying to write a query to get data.
Should be simple, but of course it's not.
The problem is:

There are 3 ways to refer to a parking stall. StallNumber, PermitNumber, and CardNumber. Problem is, not all records have all three fields. Record 1 has a StallNumber. 2 has a Permit number, 3 has a card number.

I want to fill a list with the StallNumber, if no StallNumber exists, show the PermitNumber, if no PermitNumber, show the CardNumber.

The closest I got is:

SELECT
StallID,
isnull(isnull(StallNumber,PermitNumber), CardNumber)
FROM Stall

Any suggestions?
Thanks
Ray
 
Erm, probably the wrong forum, mate.

[blue]Arguably the best cat skinner around ! [/blue]

Cheers
Scott
 
No doubt. I see that now. I was having a really bad day yesterday.
Sorry about that!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top