I would like to create a new column in a table. If the primary key exists in the other table or meets certain criteria, then return 'yes' else return 'no'. Here's an example:
Table 1:
Student
a
b
c
d
Table 2:
Student | Subject
a | english
a | math
b | english
b | science
b | match
c | science
c | english
d | math
I'd like to see this column added to Table1:
Student | HasMath
a | Yes
b | Yes
c | No
d | Yes
So if a student's name exists in the filtered table where Subject = 'Math' then the generated column will return 'Yes', else return 'No'.
Could anyone pls show me how to do it by SQL? Thanks very much.