concatenation - Create view to allow certain fields - SQL -
my table includes fname,lname,studentid,major1,major2,minor attempting create 2 different create view tables different restrictions. first one, view table need show me names of students majoring in business classes. how able query include example - eco, fin, acc not include non-business majors example bio, chem.
create view a7t6 select fname || ' ' || lname "student", studentid "id", gpa, upper(minor) "minor" a7
what statement be?
since question includes 2 major columns "major1" , "major2", might require minor modification gurv's script. e.g.:
create view a7t6 select fname || ' ' || lname "student", studentid "id", gpa, upper(minor) "minor" a7 major1 in ('eco', 'fin', 'acc') or major2 in ('eco', 'fin', 'acc');
for non-business case, might better alter clause use not in rather enumerate possible negative cases:
where major1 not in ('eco', 'fin', 'acc') , major2 not in ('eco', 'fin', 'acc');
Comments
Post a Comment