/**
 * question相关视图
 * create time: 2011-5-31 下午03:33:45
 * @version $Id: db.views.sql 30 2011-06-05 02:36:00Z liqt $
 * @author LiQintao
 */

DROP
    VIEW IF EXISTS v_question_index_sort_newest
;
CREATE
    VIEW v_question_index_sort_newest AS
        SELECT * FROM qa_question ORDER BY q_ask_time DESC
;

DROP
    VIEW IF EXISTS v_question_index_sort_newanswer
;
CREATE
    VIEW v_question_index_sort_newanswer AS
        SELECT * FROM qa_question WHERE (q_lastanswer_time IS NOT NULL) ORDER BY q_lastanswer_time DESC
;

DROP
    VIEW IF EXISTS v_question_index_sort_score
;
CREATE
    VIEW v_question_index_sort_score AS
        SELECT * FROM qa_question WHERE (q_score > 0) ORDER BY q_score DESC, q_ask_time DESC
;

DROP
    VIEW IF EXISTS v_question_index_sort_concerned
;
CREATE
    VIEW v_question_index_sort_concerned AS
        SELECT * FROM qa_question WHERE (q_concerned > 0) ORDER BY q_concerned DESC, q_ask_time DESC
;

DROP
    VIEW IF EXISTS v_question_index_sort_unanswer
;
CREATE
    VIEW v_question_index_sort_unanswer AS
        SELECT * FROM qa_question WHERE (q_answer_quantity = 0) ORDER BY q_ask_time DESC
;

DROP
    VIEW IF EXISTS v_question_index_sort_answer
;
CREATE
    VIEW v_question_index_sort_answer AS
        SELECT * FROM qa_question WHERE (q_answer_quantity > 0) ORDER BY q_answer_quantity DESC, q_ask_time DESC
;

DROP
    VIEW IF EXISTS v_question_index_sort_views
;
CREATE
    VIEW v_question_index_sort_views AS
        SELECT * FROM qa_question WHERE (q_views > 0) ORDER BY q_views DESC, q_ask_time DESC
;