Reputation: 91
I’m doing a query that extract data from two tables. The thing that I want to do that for a condition that I will put in the “where” expression, if it is correct I want to add a column in my query result in which I will put per example 1 and 0 in the other case. For more details there the form of the result that I want
A | B | C | D (new column)
So anyone have an idea?
Upvotes: 0
Views: 48
Reputation: 1269763
I think you want a case
statement. Your question is remarkably sparse on details, but the structure of the query looks like:
select <whatever>,
(case when <your condition here> then 1 else 0 end) as Flag
from table1 t1 join
table2
on . . .;
Upvotes: 1