创建视图.sql 3.4 KB

1234567891011
  1. CREATE
  2. VIEW `v_question_3year`AS
  3. select `quest`.`id` AS `id`,`quest`.`question_no` AS `question_no`,`quest`.`course_id` AS `course_id`,`quest`.`type_id` AS `type_id`,`quest`.`book_id` AS `book_id`,`quest`.`batch_id` AS `batch_id`,`quest`.`estimate_difficulty_value` AS `estimate_difficulty_value`,`quest`.`estimate_difficulty_code` AS `estimate_difficulty_code`,`quest`.`measured_difficulty_value` AS `measured_difficulty_value`,`quest`.`measured_difficulty_code` AS `measured_difficulty_code`,`quest`.`grade_code` AS `grade_code`,`quest`.`ability_code` AS `ability_code`,`quest`.`chapter` AS `chapter`,`quest`.`section` AS `section`,`quest`.`item` AS `item`,`quest`.`page` AS `page`,`quest`.`score` AS `score`,`quest`.`status_code` AS `status_code`,`quest`.`enable_time` AS `enable_time`,`quest`.`set_time` AS `set_time`,`quest`.`set_by` AS `set_by`,`quest`.`set_teacher_name` AS `set_teacher_name`,`quest`.`remark` AS `remark`,`quest`.`created_time` AS `created_time`,`quest`.`created_by` AS `created_by`,`quest`.`updated_time` AS `updated_time`,`quest`.`updated_by` AS `updated_by`,`quest`.`version` AS `version`,`quest`.`import_id` AS `import_id`,`quest`.`assessment_demand` AS `assessment_demand` from `zk_question` `quest` where `quest`.`id` in (select `detail`.`question_id` AS `question_id` from (`qr_pager_construct_detail` `detail` left join `qr_pager_construct` `pager` on(((`detail`.`pager_construct_id` = `pager`.`ID`) and (`pager`.`status` = 3) and (`pager`.`start_time` >= (curdate() + interval (-(3) * 365) day))))));
  4. CREATE
  5. VIEW `v_question_all`AS
  6. select `quest`.`id` AS `id`,`quest`.`question_no` AS `question_no`,`quest`.`course_id` AS `course_id`,`quest`.`type_id` AS `type_id`,`quest`.`book_id` AS `book_id`,`quest`.`batch_id` AS `batch_id`,`quest`.`estimate_difficulty_value` AS `estimate_difficulty_value`,`quest`.`estimate_difficulty_code` AS `estimate_difficulty_code`,`quest`.`measured_difficulty_value` AS `measured_difficulty_value`,`quest`.`measured_difficulty_code` AS `measured_difficulty_code`,`quest`.`grade_code` AS `grade_code`,`quest`.`ability_code` AS `ability_code`,`quest`.`chapter` AS `chapter`,`quest`.`section` AS `section`,`quest`.`item` AS `item`,`quest`.`page` AS `page`,`quest`.`score` AS `score`,`quest`.`status_code` AS `status_code`,`quest`.`enable_time` AS `enable_time`,`quest`.`set_time` AS `set_time`,`quest`.`set_by` AS `set_by`,`quest`.`set_teacher_name` AS `set_teacher_name`,`quest`.`remark` AS `remark`,`quest`.`created_time` AS `created_time`,`quest`.`created_by` AS `created_by`,`quest`.`updated_time` AS `updated_time`,`quest`.`updated_by` AS `updated_by`,`quest`.`version` AS `version`,`quest`.`import_id` AS `import_id`,`quest`.`assessment_demand` AS `assessment_demand` from `zk_question` `quest` where ((not((`quest`.`status_code` like '%REJECTED%'))) and (not(exists(select `detail`.`id`,`detail`.`question_id` from (`qr_pager_construct_detail` `detail` left join `qr_pager_construct` `pager` on((`detail`.`pager_construct_id` = `pager`.`ID`))) where ((`quest`.`id` = `detail`.`question_id`) and ((`pager`.`status` <> 3) or (`pager`.`start_time` <= (curdate() + interval (-(3) * 365) day))))))));
  7. CREATE
  8. VIEW `v_question_no`AS
  9. select `detail`.`id` AS `id`,`detail`.`question_id` AS `question_id` from (`qr_pager_construct_detail` `detail` left join `qr_pager_construct` `pager` on(((`detail`.`pager_construct_id` = `pager`.`ID`) and ((`pager`.`status` <> 3) or (`pager`.`start_time` >= (curdate() + interval (-(3) * 365) day))))));