ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 검색필드값 조건 걸기
    MYSQL 2020. 7. 14. 13:44

    //검색 필드에서 연산후 별칭을 주어 having 으로 논리연산

    ex)

     

    SELECT

                        ipc.ipc_name,

                        ipc.ipc_code,

                        eps.eps_m_code,

                        COUNT(epu.epu_idx) AS exam_cnt,

                        SUM(epu.epu_right_cnt + epu.epu_wrong_cnt) AS question_cnt,

                        SUM(epu.epu_right_cnt) AS right_cnt,

                       (SUM(epu.epu_right_cnt) / SUM(epu.epu_right_cnt + epu.epu_wrong_cnt)) * 100 AS rate

                    FROM

                        tb_exam_paper_user AS epu

                    INNER JOIN

                        tb_exam_paper_summery AS eps

                    ON

                        epu.epu_eps_idx = eps.eps_idx AND eps.eps_exam_type = '".$exam_type."' AND eps.eps_ip_category = '".$cate1."' AND eps.eps_ip_category2 = '".$cate2."' ".$where."

                    INNER JOIN

                        tb_item_pool_category AS ipc

                    ON

                        eps.eps_ip_category3 = ipc.ipc_code

                    WHERE

                        epu.epu_exam_complete = 'Y'

                    AND

                        (right_cnt / question_cnt *100) as rate >".$rate."

                    GROUP BY

                        eps.eps_ip_category3

                    HAVING

                        rate >= 90";

     

    'MYSQL' 카테고리의 다른 글

    날짜 검색시  (0) 2020.07.15
    DB현재 실행중인 쿼리 확인  (0) 2020.07.14
    index란  (0) 2020.07.14
    order by case 또는 select case  (0) 2020.06.11
    mysql 글로벌 설정값 보기  (0) 2020.06.11

    댓글

Designed by Tistory.