Sunday, March 26, 2017

List of chapters from Tahun 1 to Tingkatan 5

SELECT 
s.chapter_id, s.subject_id,

 CASE
 WHEN t.edu_year_id=1 THEN 'Tahun 1'
 WHEN t.edu_year_id=2 THEN 'Tahun 2'
 WHEN t.edu_year_id=3 THEN 'Tahun 3'
 WHEN t.edu_year_id=4 THEN 'Tahun 4'
 WHEN t.edu_year_id=5 THEN 'Tahun 5'
 WHEN t.edu_year_id=6 THEN 'Tahun 6'
 WHEN t.edu_year_id=7 THEN 'Tingkatan 1'
 WHEN t.edu_year_id=8 THEN 'Tingkatan 2'
 WHEN t.edu_year_id=9 THEN 'Tingkatan 3'
 WHEN t.edu_year_id=10 THEN 'Tingkatan 4'
 WHEN t.edu_year_id=11 THEN 'Tingkatan 5'
 ELSE 'lain-lain' END as `edu_year`, t.title as Subject, s.title as chapter_title
FROM chapters s
JOIN subjects t ON s.subject_id=t.subject_id

ORDER BY t.edu_year_id ASC, s.chapter_id asc

No comments:

Post a Comment