[thelist] Selecting constants conditionally in SQL

Joshua OIson joshua at alphashop.net
Tue Dec 12 13:46:39 CST 2000


I want to write an SQL statement that pulls data from a table with a rank
column.

But, I also want it to return constants if the rank is not the lowest or
highest ranks in the table.

The "psuedo-sql" example query I came up with is the following.

SELECT
  name,
  rank,
  (4 if this is not the lowest rank in the table, or NULL if it is) AS
lowest,
  (5 if this is not the highest rank in the table, or NULL if it is) AS
highest
FROM foo

-joshua





More information about the thelist mailing list