It seems like you want
SELECT
CASE
WHEN t.A <= t.B
THEN t.A
ELSE t.B
END AS Smaller
FROM Table t
Question
I have a user defined function and I want to do a select and choose a column based on whether or not it is bigger or small than another.
For example:
Select
t.A, t.B
From
Table t
Where
if(t.A <= t.B) then
use t.A
else
use t.B
Is this possible? Thanks in advance!
Solution
It seems like you want
SELECT
CASE
WHEN t.A <= t.B
THEN t.A
ELSE t.B
END AS Smaller
FROM Table t
OTHER TIPS
No! But you can use a case
statement
Select
t.A, t.B
From
Table t
Where
(case when t.A <= t.B then t.A ELSE t.B END) = SomeValue
or if the smaller column is required in the select statement only then
Select
(case when t.A <= t.B then t.A ELSE t.B END) as column
From
Table t
NOTE I haven't used pervasive sql before, but a quick googlez reveals that the case statement was added in version 9.x??
Do you actually want?
SELECT MIN(t.A, t.B) AS SmallestAOrB FROM Table t