CourseMaster | |
course_id | course_name |
1 | 会计入门 |
2 | 财务知识 |
3 | 簿记考试 |
4 | 税务师 |
OpenCourses | |
month | course_id |
200706 | 1 |
200706 | 3 |
200706 | 4 |
200707 | 4 |
200708 | 2 |
200708 | 4 |
检查OpenCourses中的各月里有表CourseMaster中的那些课程
结果:
COURSE_NAME | 6月 | 7月 | 8月 |
会计入门 | O | x | x |
财务知识 | x | x | O |
簿记考试 | O | x | x |
税务师 | O | O | O |
select course_name,
case when course_id in(select course_id from OpenCourses where month=200706) then 'O'
else 'x' end as "6月",
case when course_id in (select course_id from OpenCourses where month=200707) then 'O'
else 'x' end as "7月",
case when course_id in (select course_id from OpenCourses where month=200708) then 'O'
else 'x' end as "8月"
from CourseMaster;