0

(I don't know how to title this question) I have a table say t1 with 3 fields.

 f1----f2----f3
 1     v1     0
 2     v2     0
 3     v3     0
 4     v2    10
 5     v3    10

I want to pick up values from the tables if f3 = 0 or f3 = 10. However, if there is record with f3 = 10, then it would override 0. To make it easier to understand,

Q1: select * from t1 where f3 = 0  => returns (1,v1,0), (2,v2,0), (3,v3, 0)
Q2: select * from t1 where f3 = 10 => returns           (2,v2,10),(3,v3,10)

What I want is (1,v1,0), (2,v2,10), (3,v3,10). I want to do this with some simple if statement in the where condition. Is this possible?

Marcus Adams
  • 53,009
  • 9
  • 91
  • 143
Ram
  • 1
  • 3

1 Answers1

0

You should try something like:

 Select f1, f2, MAX(f3) from t1
 where f3 IN (0, 10)
 group by f2;
Marshall Tigerus
  • 3,675
  • 10
  • 37
  • 67