<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.style24.batch.biz.dao.TsbDisplayDao">

	<!-- cate4srch 삭제 -->
	<delete id="deleteCate4srch">
		/* TsbDisplay.deleteCate4srch */
		DELETE FROM TB_CATE_4SRCH
	</delete>

	<!-- cate4srch 생성 -->
	<insert id="createCate4srch">
		/* TsbDisplay.createCate4srch */
		INSERT INTO TB_CATE_4SRCH (
		       SITE_CD
		     , CATE_GB
		     , LEAF_CATE_NO
		     , CATE_TYPE
		     , CATE1_NO
		     , CATE1_NM
		     , CATE2_NO
		     , CATE2_NM
		     , CATE3_NO
		     , CATE3_NM
		     , CATE4_NO
		     , CATE4_NM
		     , CATE5_NO
		     , CATE5_NM
		     , FULL_CATE_NO
		     , FULL_CATE_NM
		     , DISP_ORD
		     , FORMAL_GB
		     , CONTENTS_LOC
		)
		SELECT SITE_CD
		     , CATE_GB
		     , LEAF_CATE_NO
		     , CATE_TYPE
		     , CATE1_NO
		     , CATE1_NM
		     , CATE2_NO
		     , CATE2_NM
		     , CATE3_NO
		     , CATE3_NM
		     , CATE4_NO
		     , CATE4_NM
		     , CATE5_NO
		     , CATE5_NM
		     , FULL_CATE_NO
		     , FULL_CATE_NM
		     , DISP_ORD
		     , FORMAL_GB
		     , CONTENTS_LOC
		FROM   VW_CATE_4SRCH
	</insert>

	<!-- 카테고리별재고임시 테이블 truncate -->
	<delete id="truncateTemporaryCategoryStock" >
		/* TsbDisplay.truncateTemporaryCategoryStock */
		TRUNCATE TABLE TB_CATE_STOCK_TMP
	</delete>

	<!-- 카테고리별재고 임시테이블에 생성 -->
	<insert id="createTemporaryCategoryStock" timeout="300">
		/* TsbDisplay.createTemporaryCategoryStock */
		INSERT INTO TB_CATE_STOCK_TMP (
		       SITE_CD
		     , CATE1_NO
		     , CATE2_NO
		     , CATE3_NO
		     , CATE4_NO
		     , CATE5_NO
		     , GOODS_CD
		     , BRAND_GROUP_NO
		     , FORMAL_GB
		     , STOCK_QTY
		)
		SELECT B.SITE_CD
		     , B.CATE1_NO
		     , B.CATE2_NO
		     , B.CATE3_NO
		     , B.CATE4_NO
		     , B.CATE5_NO
		     , A.GOODS_CD
		     , C.BRAND_GROUP_NO
		     , C.FORMAL_GB
		     , C.STOCK_QTY
		FROM   TB_CATE_GOODS A
		     , TB_CATE_4SRCH B
		     , (
		        SELECT G.GOODS_CD
		             , B.BRAND_GROUP_NO
		             , G.FORMAL_GB
		             , SUM(S.CURR_STOCK_QTY - S.BASE_STOCK_QTY) AS STOCK_QTY
		        FROM   TB_GOODS G
		             , VW_STOCK S
		             , TB_BRAND B
		        WHERE  G.GOODS_CD = S.GOODS_CD
		        AND    G.BRAND_CD = B.BRAND_CD
		        AND    G.GOODS_TYPE = 'G056_N' /*일반상품*/
		        AND    G.GOODS_STAT = 'G008_90' /*승인된상품*/
		        AND    G.SELF_MALL_YN = 'Y' /*자사몰에노출하는넘만*/
		        AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*유효한판매기간*/
		        AND    S.SOLDOUT_YN = 'N' /*품절이아닌넘*/
		        AND    S.DISP_YN = 'Y' /*사이즈노출하는넘만*/
		        AND    S.CURR_STOCK_QTY - S.BASE_STOCK_QTY > 0 /*재고있는넘*/
		        GROUP  BY G.GOODS_CD, B.BRAND_GROUP_NO, G.FORMAL_GB
		        UNION ALL
		        SELECT G.GOODS_CD
		             , B.BRAND_GROUP_NO
		             , G.FORMAL_GB
		             , SUM(S.CURR_STOCK_QTY - S.BASE_STOCK_QTY) AS STOCK_QTY
		        FROM   TB_GOODS G
		             , TB_GOODS_COMPOSE GC
		             , VW_STOCK S
		             , TB_BRAND B
		        WHERE  G.GOODS_CD = GC.GOODS_CD
		        AND    GC.COMPS_GOODS_CD = S.GOODS_CD
		        AND    G.BRAND_CD = B.BRAND_CD
		        AND    G.GOODS_TYPE != 'G056_N' /*일반상품이 아닌넘*/
		        AND    G.GOODS_STAT = 'G008_90' /*승인된상품*/
		     --   AND    G.SELF_GOODS_YN = 'Y' /*자사상품만(세트상품과 딜상품은 자사상품만)*/
		        AND    G.SELF_MALL_YN = 'Y' /*자사몰에노출하는넘만*/
		        AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*유효한판매기간*/
		        AND    GC.USE_YN = 'Y' /*사용하는구성상품*/
		        AND    S.SOLDOUT_YN = 'N' /*품절이아닌넘*/
		        AND    S.DISP_YN = 'Y' /*사이즈노출하는넘만*/
		        AND    S.CURR_STOCK_QTY - S.BASE_STOCK_QTY > 0 /*재고있는넘*/
		        GROUP  BY G.GOODS_CD, B.BRAND_GROUP_NO, G.FORMAL_GB
		       ) C
		WHERE  A.GOODS_CD = C.GOODS_CD
		AND    A.CATE_NO = B.LEAF_CATE_NO
		AND    B.CATE_TYPE = 'G031_10' /*상품분류카테고리*/
	</insert>

	<!-- 카테고리별재고 삭제 -->
	<delete id="deleteCategoryStock"  timeout="300">
		/* TsbDisplay.deleteCategoryStock */
		DELETE FROM TB_CATE_STOCK
	</delete>

	<!-- 카테고리별재고 생성 -->
	<insert id="createCategoryStock"  timeout="300">
		/* TsbDisplay.createCategoryStock */
		INSERT INTO TB_CATE_STOCK (
		       SITE_CD
		     , CATE_NO
		     , BRAND_GROUP_NO
		     , FORMAL_GB
		     , STOCK_QTY
		     , GOODS_QTY
		     , REG_NO
		     , REG_DT
		)
		SELECT SITE_CD
		     , CATE_NO
		     , BRAND_GROUP_NO
		     , FORMAL_GB
		     , STOCK_QTY
		     , GOODS_QTY
		     , 0               AS REG_NO
		     , NOW()           AS REG_DT
		FROM   (
		        SELECT SITE_CD
		             , CATE5_NO                 AS CATE_NO
		             , BRAND_GROUP_NO
		             , FORMAL_GB
		             , SUM(STOCK_QTY)           AS STOCK_QTY
		             , COUNT(DISTINCT GOODS_CD) AS GOODS_QTY
		        FROM   TB_CATE_STOCK_TMP
		        WHERE  CATE5_NO IS NOT NULL
		        GROUP  BY SITE_CD, CATE5_NO, BRAND_GROUP_NO, FORMAL_GB
		        HAVING SUM(STOCK_QTY) > 0
		        UNION ALL
		        SELECT SITE_CD
		             , CATE4_NO                 AS CATE_NO
		             , BRAND_GROUP_NO
		             , FORMAL_GB
		             , SUM(STOCK_QTY)           AS STOCK_QTY
		             , COUNT(DISTINCT GOODS_CD) AS GOODS_QTY
		        FROM   TB_CATE_STOCK_TMP
		        WHERE  CATE4_NO IS NOT NULL
		        GROUP  BY SITE_CD, CATE4_NO, BRAND_GROUP_NO, FORMAL_GB
		        HAVING SUM(STOCK_QTY) > 0
		        UNION ALL
		        SELECT SITE_CD
		             , CATE3_NO                 AS CATE_NO
		             , BRAND_GROUP_NO
		             , FORMAL_GB
		             , SUM(STOCK_QTY)           AS STOCK_QTY
		             , COUNT(DISTINCT GOODS_CD) AS GOODS_QTY
		        FROM   TB_CATE_STOCK_TMP
		        WHERE  CATE3_NO IS NOT NULL
		        GROUP  BY SITE_CD, CATE3_NO, BRAND_GROUP_NO, FORMAL_GB
		        HAVING SUM(STOCK_QTY) > 0
		        UNION ALL
		        SELECT SITE_CD
		             , CATE2_NO                 AS CATE_NO
		             , BRAND_GROUP_NO
		             , FORMAL_GB
		             , SUM(STOCK_QTY)           AS STOCK_QTY
		             , COUNT(DISTINCT GOODS_CD) AS GOODS_QTY
		        FROM   TB_CATE_STOCK_TMP
		        WHERE  CATE2_NO IS NOT NULL
		        GROUP  BY SITE_CD, CATE2_NO, BRAND_GROUP_NO, FORMAL_GB
		        HAVING SUM(STOCK_QTY) > 0
		        UNION ALL
		        SELECT SITE_CD
		             , CATE1_NO                 AS CATE_NO
		             , BRAND_GROUP_NO
		             , FORMAL_GB
		             , SUM(STOCK_QTY)           AS STOCK_QTY
		             , COUNT(DISTINCT GOODS_CD) AS GOODS_QTY
		        FROM   TB_CATE_STOCK_TMP
		        WHERE  CATE1_NO IS NOT NULL
		        GROUP  BY SITE_CD, CATE1_NO, BRAND_GROUP_NO, FORMAL_GB
		        HAVING SUM(STOCK_QTY) > 0
		       ) Z
		WHERE  CATE_NO IS NOT NULL
	</insert>

	<!-- 임시카테고리별검색필터 테이블 truncate -->
	<delete id="truncateTemporaryCategoryFilter">
		/* TsbDisplay.truncateTemporaryCategoryFilter */
		TRUNCATE TABLE TB_CATE_FILTER_TMP
	</delete>

	<!-- 임시카테고리별검색필터 - 브랜드 생성 -->
	<insert id="createTemporaryCategoryFilterBrand" timeout="600">
		/* TsbDisplay.createTemporaryCategoryFilterBrand */
		INSERT INTO TB_CATE_FILTER_TMP (
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , CG.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , B.BRAND_GROUP_NO  AS FILTER_CD
		         , CASE WHEN BG.DISP_NM_LANG = 'EN' THEN
		                BG.BRAND_GROUP_ENM
		           ELSE
		                BG.BRAND_GROUP_KNM
		           END               AS FILTER_NM
		    FROM   TB_CATE_4SRCH C4
		         , TB_CATE_GOODS CG
		         , TB_GOODS G
		         , TB_GOODS_STOCK GS
		         , TB_BRAND B
		         , TB_SITE_BRAND SB
		         , TB_BRAND_GROUP BG
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		    AND    CG.BRAND_GROUP_NO = 0
		    AND    CG.GOODS_CD = G.GOODS_CD
		    AND    G.GOODS_CD = GS.GOODS_CD
		    AND    G.BRAND_CD = B.BRAND_CD
		    AND    B.BRAND_CD = SB.BRAND_CD
		    AND    B.BRAND_GROUP_NO = BG.BRAND_GROUP_NO
		    AND    C4.SITE_CD = 'G000_10'
		    AND    C4.CATE_GB = 'G032_101'
		    AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		    AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		    AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		    AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*유효한판매기간*/
		    AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		    AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		    AND    SB.SITE_CD = 'G000_10'
		    AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		    AND    BG.USE_YN = 'Y' /*사용하는 브랜드그룹*/
		)
		SELECT SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , 'BRAND'        AS FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , RANK() OVER(PARTITION BY SITE_CD, CATE_GB, FORMAL_GB, BRAND_GROUP_NO, CATE_NO
		                   ORDER BY FILTER_NM
		                  )   AS DISP_ORD
		FROM   (
		        SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , FILTER_CD
		             , FILTER_NM
		        FROM   (
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE5_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE5_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE4_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE4_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE3_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE3_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE2_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE2_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE1_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE1_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE5_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE5_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE4_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE4_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE3_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE3_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE2_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE2_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE1_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE1_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		               ) Z
		        WHERE  CATE_NO IS NOT NULL
		       ) Z
	</insert>

	<!-- 임시카테고리별검색필터 - 사이즈 생성 -->
	<insert id="createTemporaryCategoryFilterSize" timeout="600">
		/* TsbDisplay.createTemporaryCategoryFilterSize */
		INSERT INTO TB_CATE_FILTER_TMP (
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , CG.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , CONCAT(I.SIZE_GB,'|',S.OPT_CD2) AS FILTER_CD
		         , S.OPT_CD2                       AS FILTER_NM
		    FROM   TB_CATE_4SRCH C4
		         , TB_CATE_GOODS CG
		         , TB_GOODS G
		         , TB_ITEMKIND I
		         , VW_STOCK S
		         , TB_BRAND B
		         , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		    AND    CG.BRAND_GROUP_NO = 0
		    AND    CG.GOODS_CD = G.GOODS_CD
		    AND    G.ITEMKIND_CD = I.ITEMKIND_CD
		    AND    G.GOODS_CD = S.GOODS_CD
		    AND    G.BRAND_CD = B.BRAND_CD
		    AND    B.BRAND_CD = SB.BRAND_CD
		    AND    C4.SITE_CD = 'G000_10'
		    AND    C4.CATE_GB = 'G032_101'
		    AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		    AND    G.GOODS_TYPE = 'G056_N' /*일반상품*/
		    AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		    AND    G.SELF_MALL_YN = 'Y' /*자사몰에노출하는상품*/
		    AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*유효한판매기간*/
		    AND    I.SIZE_GB IS NOT NULL
		    AND    S.CURR_STOCK_QTY - S.BASE_STOCK_QTY > 0 /*재고있는옵션*/
		    AND    S.SOLDOUT_YN = 'N' /*품절이 아닌 옵션*/
		    AND    S.DISP_YN = 'Y' /*노출하는 옵션*/
		    AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		    AND    SB.SITE_CD = 'G000_10'
		    AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		    UNION ALL
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , C4.FORMAL_GB
		         , CG.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , CONCAT(I.SIZE_GB,'|',S.OPT_CD2) AS FILTER_CD
		         , S.OPT_CD2                       AS FILTER_NM
		    FROM   TB_CATE_4SRCH C4
		         , TB_CATE_GOODS CG
		         , TB_GOODS G
		         , TB_GOODS_COMPOSE GC
		         , TB_ITEMKIND I
		         , VW_STOCK S
		         , TB_BRAND B
		         , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		    AND    CG.BRAND_GROUP_NO = 0
		    AND    CG.GOODS_CD = G.GOODS_CD
		    AND    G.GOODS_CD = GC.GOODS_CD
		    AND    G.ITEMKIND_CD = I.ITEMKIND_CD
		    AND    GC.COMPS_GOODS_CD = S.GOODS_CD
		    AND    G.BRAND_CD = B.BRAND_CD
		    AND    B.BRAND_CD = SB.BRAND_CD
		    AND    C4.SITE_CD = 'G000_10'
		    AND    C4.CATE_GB = 'G032_101'
		    AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		    AND    G.GOODS_TYPE != 'G056_N' /*일반상품이 아닌넘*/
		    AND    G.GOODS_STAT = 'G008_90' /*승인된상품*/
		  --  AND    G.SELF_GOODS_YN = 'Y' /*자사상품만(세트상품과 딜상품은 자사상품만)*/
		    AND    G.SELF_MALL_YN = 'Y' /*자사몰에노출하는넘만*/
		    AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*유효한판매기간*/
		    AND    I.SIZE_GB IS NOT NULL
		    AND    S.CURR_STOCK_QTY - S.BASE_STOCK_QTY > 0 /*재고있는옵션*/
		    AND    S.SOLDOUT_YN = 'N' /*품절이 아닌 옵션*/
		    AND    S.DISP_YN = 'Y' /*노출하는 옵션*/
		    AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		    AND    SB.SITE_CD = 'G000_10'
		    AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , 'SIZE'        AS FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , RANK() OVER(PARTITION BY SITE_CD, CATE_GB, FORMAL_GB, BRAND_GROUP_NO, CATE_NO
		                   ORDER BY CASE WHEN FILTER_CD LIKE 'T%' THEN 1
		                                 WHEN FILTER_CD LIKE 'B%' THEN 2
		                                 WHEN FILTER_CD LIKE 'S%' THEN 3
		                                 ELSE 4
		                            END, FILTER_NM
		                  )   AS DISP_ORD
		FROM   (
		        SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , FILTER_CD
		             , FILTER_NM
		        FROM   (
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE5_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE5_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE4_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE4_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE3_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE3_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE2_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE2_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE1_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE1_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE5_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE5_NO IS NOT NULL
		                  AND  FORMAL_GB  = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE4_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE4_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE3_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE3_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE2_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE2_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE1_NO       AS CATE_NO
		                     , FILTER_CD
		                     , FILTER_NM
		                FROM   TAB_FILTER
		                WHERE  CATE1_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		               ) Z
		        WHERE  CATE_NO IS NOT NULL
		       ) Z
	</insert>

	<!-- 임시카테고리별검색필터 - 가격 생성 -->
	<insert id="createTemporaryCategoryFilterPrice" timeout="600">
		/* TsbDisplay.createTemporaryCategoryFilterPrice */
		INSERT INTO TB_CATE_FILTER_TMP (
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , CG.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , FN_GET_BENEFIT_PRICE('P',G.GOODS_CD,G.CURR_PRICE,'G100_10') AS CURR_PRICE
		    FROM   TB_CATE_4SRCH C4
		         , TB_CATE_GOODS CG
		         , TB_GOODS G
		         , TB_GOODS_STOCK GS
		         , TB_BRAND B
		         , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		    AND    CG.BRAND_GROUP_NO = 0
		    AND    CG.GOODS_CD = G.GOODS_CD
		    AND    CG.GOODS_CD = GS.GOODS_CD
		    AND    G.BRAND_CD = B.BRAND_CD
		    AND    B.BRAND_CD = SB.BRAND_CD
		    AND    C4.SITE_CD = 'G000_10'
		    AND    C4.CATE_GB = 'G032_101'
		    AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		    AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		    AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		    AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*유효한판매기간*/
		    AND    GS.STOCK_QTY > 0 /*재고있는옵션*/
		    AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		    AND    SB.SITE_CD = 'G000_10'
		    AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		, TAB_PRICE AS (
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_10' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		            SELECT SITE_CD
		                 , CATE_GB
		                 , BRAND_GROUP_NO
		                 , CATE1_NO        AS CATE_NO
		                 , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                 , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                 , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		            FROM   TAB_FILTER
		            WHERE  CATE1_NO IS NOT NULL
		              AND  FORMAL_GB IN ('G009_10','G009_20')
		            GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE1_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_10' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		            SELECT SITE_CD
		                 , CATE_GB
		                 , BRAND_GROUP_NO
		                 , CATE2_NO        AS CATE_NO
		                 , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                 , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                 , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		            FROM   TAB_FILTER
		            WHERE  CATE2_NO IS NOT NULL
		              AND  FORMAL_GB IN ('G009_10','G009_20')
		            GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE1_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_10' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		            SELECT SITE_CD
		                 , CATE_GB
		                 , BRAND_GROUP_NO
		                 , CATE3_NO        AS CATE_NO
		                 , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                 , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                 , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		            FROM   TAB_FILTER
		            WHERE  CATE3_NO IS NOT NULL
		              AND  FORMAL_GB IN ('G009_10','G009_20')
		            GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE1_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_10' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		            SELECT SITE_CD
		                 , CATE_GB
		                 , BRAND_GROUP_NO
		                 , CATE4_NO        AS CATE_NO
		                 , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                 , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                 , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		            FROM   TAB_FILTER
		            WHERE  CATE4_NO IS NOT NULL
		              AND  FORMAL_GB IN ('G009_10','G009_20')
		            GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE1_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_10' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		            SELECT SITE_CD
		                 , CATE_GB
		                 , BRAND_GROUP_NO
		                 , CATE5_NO        AS CATE_NO
		                 , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                 , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                 , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		            FROM   TAB_FILTER
		            WHERE  CATE5_NO IS NOT NULL
		              AND  FORMAL_GB IN ('G009_10','G009_20')
		            GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE1_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_20' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , BRAND_GROUP_NO
		                    , CATE1_NO        AS CATE_NO
		                    , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                    , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                    , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  CATE1_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE1_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_20' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , BRAND_GROUP_NO
		                    , CATE2_NO        AS CATE_NO
		                    , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                    , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                    , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  CATE2_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE2_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_20' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , BRAND_GROUP_NO
		                    , CATE3_NO        AS CATE_NO
		                    , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                    , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                    , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  CATE3_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE3_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_20' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , BRAND_GROUP_NO
		                    , CATE4_NO        AS CATE_NO
		                    , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                    , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                    , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  CATE4_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE4_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_20' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , BRAND_GROUP_NO
		                    , CATE5_NO        AS CATE_NO
		                    , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                    , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                    , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  CATE5_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE5_NO
		           ) Z
		)
		SELECT DISTINCT
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , 'PRICE'        AS FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , RANK() OVER(PARTITION BY SITE_CD, CATE_GB, FORMAL_GB, BRAND_GROUP_NO, CATE_NO
		                   ORDER BY FILTER_CD
		                   )  AS DISP_ORD
		FROM   (
		        SELECT SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , PRICE1         AS FILTER_CD
		             , PRICE1         AS FILTER_NM
		        FROM   TAB_PRICE
		        UNION ALL
		        SELECT SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , PRICE2         AS FILTER_CD
		             , PRICE2         AS FILTER_NM
		        FROM   TAB_PRICE
		        UNION ALL
		        SELECT SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , PRICE3         AS FILTER_CD
		             , PRICE3         AS FILTER_NM
		        FROM   TAB_PRICE
		        UNION ALL
		        SELECT SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , PRICE4         AS FILTER_CD
		             , PRICE4         AS FILTER_NM
		        FROM   TAB_PRICE
		        UNION ALL
		        SELECT SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , PRICE5         AS FILTER_CD
		             , PRICE5         AS FILTER_NM
		        FROM   TAB_PRICE
		        UNION ALL
		        SELECT SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , PRICE6         AS FILTER_CD
		             , PRICE6         AS FILTER_NM
		        FROM   TAB_PRICE
		       ) Z
	</insert>

	<!-- 임시카테고리별검색필터 - 연령대 생성 -->
	<insert id="createTemporaryCategoryFilterAge" timeout="600">
		/* TsbDisplay.createTemporaryCategoryFilterAge */
		INSERT INTO TB_CATE_FILTER_TMP (
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , C4.FORMAL_GB
		         , CG.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , G.AGE_GRP_CD      AS FILTER_CD
		    FROM   TB_CATE_4SRCH C4
		         , TB_CATE_GOODS CG
		         , TB_GOODS G
		         , TB_GOODS_STOCK GS
		         , TB_BRAND B
		         , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		    AND    CG.BRAND_GROUP_NO = 0
		    AND    CG.GOODS_CD = G.GOODS_CD
		    AND    CG.GOODS_CD = GS.GOODS_CD
		    AND    G.BRAND_CD = B.BRAND_CD
		    AND    B.BRAND_CD = SB.BRAND_CD
		    AND    C4.SITE_CD = 'G000_10'
		    AND    C4.CATE_GB = 'G032_101'
		    AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		    AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		    AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		    AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*유효한판매기간*/
		    AND    G.AGE_GRP_CD IS NOT NULL
		    AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		    AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		    AND    SB.SITE_CD = 'G000_10'
		    AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT A.SITE_CD
		     , A.CATE_GB
		     , A.FORMAL_GB
		     , A.BRAND_GROUP_NO
		     , A.CATE_NO
		     , 'AGE'          AS FILTER_GB
		     , A.FILTER_CD
		     , CC.CD_NM       AS FILTER_NM
		     , RANK() OVER(PARTITION BY A.SITE_CD, A.CATE_GB, A.FORMAL_GB, A.BRAND_GROUP_NO, A.CATE_NO
		                   ORDER BY CC.DISP_ORD
		                  )   AS DISP_ORD
		FROM   (
		        SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , FILTER_CD
		        FROM   (
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE5_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE5_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE4_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE4_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE3_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE3_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE2_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE2_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE1_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE1_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE5_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE5_NO IS NOT NULL
		                  AND  FORMAL_GB  = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE4_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE4_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE3_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE3_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE2_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE2_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE1_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE1_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		               ) Z
		        WHERE  CATE_NO IS NOT NULL
		       ) A
		     , TB_COMMON_CODE CC
		WHERE  A.FILTER_CD = CC.CD
		AND    CC.CD_GB = 'G023'
		AND    CC.USE_YN = 'Y'
	</insert>

	<!-- 임시카테고리별검색필터 - 시즌 생성 -->
	<insert id="createTemporaryCategoryFilterSeason" timeout="600">
		/* TsbDisplay.createTemporaryCategoryFilterSeason */
		INSERT INTO TB_CATE_FILTER_TMP (
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , C4.FORMAL_GB
		         , CG.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , G.SEASON_CD       AS FILTER_CD
		    FROM   TB_CATE_4SRCH C4
		         , TB_CATE_GOODS CG
		         , TB_GOODS G
		         , TB_GOODS_STOCK GS
		         , TB_BRAND B
		         , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		    AND    CG.BRAND_GROUP_NO = 0
		    AND    CG.GOODS_CD = G.GOODS_CD
		    AND    CG.GOODS_CD = GS.GOODS_CD
		    AND    G.BRAND_CD = B.BRAND_CD
		    AND    B.BRAND_CD = SB.BRAND_CD
		    AND    C4.SITE_CD = 'G000_10'
		    AND    C4.CATE_GB = 'G032_101'
		    AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		    AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		    AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		    AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*유효한판매기간*/
		    AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		    AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		    AND    SB.SITE_CD = 'G000_10'
		    AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT A.SITE_CD
		     , A.CATE_GB
		     , A.FORMAL_GB
		     , A.BRAND_GROUP_NO
		     , A.CATE_NO
		     , 'SEASON'         AS FILTER_GB
		     , A.FILTER_CD
		     , CC.CD_NM         AS FILTER_NM
		     , RANK() OVER(PARTITION BY A.SITE_CD, A.CATE_GB, A.FORMAL_GB, A.BRAND_GROUP_NO, A.CATE_NO
		                   ORDER BY CC.DISP_ORD
		                  )   AS DISP_ORD
		FROM   (
		        SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , FILTER_CD
		        FROM   (
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE5_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE5_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE4_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE4_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE3_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE3_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE2_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE2_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , 'G009_10' AS FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE1_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE1_NO IS NOT NULL
		                  AND  FORMAL_GB IN ('G009_10','G009_20')
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE5_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE5_NO IS NOT NULL
		                  AND  FORMAL_GB  = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE4_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE4_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE3_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE3_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE2_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE2_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		                UNION ALL
		                SELECT SITE_CD
		                     , CATE_GB
		                     , FORMAL_GB
		                     , BRAND_GROUP_NO
		                     , CATE1_NO       AS CATE_NO
		                     , FILTER_CD
		                FROM   TAB_FILTER
		                WHERE  CATE1_NO IS NOT NULL
		                  AND  FORMAL_GB = 'G009_20'
		               ) Z
		        WHERE  CATE_NO IS NOT NULL
		       ) A
		     , TB_COMMON_CODE CC
		WHERE  A.FILTER_CD = CC.CD
		AND    CC.CD_GB = 'G006'
		AND    CC.USE_YN = 'Y'
	</insert>

	<!-- 임시카테고리별검색필터 - 색상 생성 -->
	<insert id="createTemporaryCategoryFilterColor" timeout="600">
		/* TsbDisplay.createTemporaryCategoryFilterColor */
		INSERT INTO TB_CATE_FILTER_TMP (
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , C4.FORMAL_GB
		         , CG.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , C.COLOR_GRP_CD    AS FILTER_CD
		    FROM   TB_CATE_4SRCH C4
		         , TB_CATE_GOODS CG
		         , TB_GOODS G
		         , TB_GOODS_STOCK GS
		         , TB_OPTION O
		         , TB_COLOR C
		         , TB_BRAND B
		         , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		    AND    CG.BRAND_GROUP_NO = 0
		    AND    CG.GOODS_CD = G.GOODS_CD
		    AND    CG.GOODS_CD = GS.GOODS_CD
		    AND    CG.GOODS_CD = O.GOODS_CD
		    AND    O.OPT_CD1 = C.COLOR_CD
		    AND    G.BRAND_CD = B.BRAND_CD
		    AND    B.BRAND_CD = SB.BRAND_CD
		    AND    C4.SITE_CD = 'G000_10'
		    AND    C4.CATE_GB = 'G032_101'
		    AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		    AND    G.GOODS_TYPE = 'G056_N' /*일반상품인넘*/
		    AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		    AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		    AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*유효한판매기간*/
		    AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		    AND    O.SOLDOUT_YN = 'N' /*품절이 아닌 옵션*/
		    AND    O.DISP_YN = 'Y' /*노출하는 옵션*/
		    AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		    AND    SB.SITE_CD = 'G000_10'
		    AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		    UNION ALL
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , C4.FORMAL_GB
		         , CG.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , C.COLOR_GRP_CD    AS FILTER_CD
		    FROM   TB_CATE_4SRCH C4
		         , TB_CATE_GOODS CG
		         , TB_GOODS G
		         , TB_GOODS_COMPOSE GC
		         , VW_STOCK GS
		         , TB_OPTION O
		         , TB_COLOR C
		         , TB_BRAND B
		         , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		    AND    CG.BRAND_GROUP_NO = 0
		    AND    CG.GOODS_CD = G.GOODS_CD
		    AND    CG.GOODS_CD = GC.GOODS_CD
		    AND    GC.COMPS_GOODS_CD = GS.GOODS_CD
		    AND    GS.GOODS_CD = O.GOODS_CD
		    AND    GS.OPT_CD1 = O.OPT_CD1
		    AND    O.OPT_CD1 = C.COLOR_CD
		    AND    G.BRAND_CD = B.BRAND_CD
		    AND    B.BRAND_CD = SB.BRAND_CD
		    AND    C4.SITE_CD = 'G000_10'
		    AND    C4.CATE_GB = 'G032_101'
		    AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		    AND    G.GOODS_TYPE != 'G056_N' /*일반상품이아닌넘*/
		    AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		  --  AND    G.SELF_GOODS_YN = 'Y' /*자사상품만(세트상품과 딜상품은 자사상품만)*/
		    AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		    AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*유효한판매기간*/
		    AND    GS.SOLDOUT_YN = 'N' /*품절이아닌넘*/
		    AND    GS.DISP_YN = 'Y' /*사이즈노출하는넘만*/
		    AND    GS.CURR_STOCK_QTY - GS.BASE_STOCK_QTY > 0 /*재고있는넘만*/
		    AND    O.SOLDOUT_YN = 'N' /*품절이 아닌 옵션*/
		    AND    O.DISP_YN = 'Y' /*노출하는 옵션*/
		    AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		    AND    SB.SITE_CD = 'G000_10'
		    AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT A.SITE_CD
		     , A.CATE_GB
		     , A.FORMAL_GB
		     , A.BRAND_GROUP_NO
		     , A.CATE_NO
		     , 'COLOR'          AS FILTER_GB
		     , A.FILTER_CD
		     , CC.CD_DESC       AS FILTER_NM
		     , RANK() OVER(PARTITION BY A.SITE_CD, A.CATE_GB, A.FORMAL_GB, A.BRAND_GROUP_NO, A.CATE_NO
		                   ORDER BY CC.DISP_ORD
		                  )   AS DISP_ORD
		FROM   (
		        SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , FILTER_CD
		        FROM   (
		                   SELECT SITE_CD
		                        , CATE_GB
		                        , 'G009_10' AS FORMAL_GB
		                        , BRAND_GROUP_NO
		                        , CATE5_NO       AS CATE_NO
		                        , FILTER_CD
		                   FROM   TAB_FILTER
		                   WHERE  CATE5_NO IS NOT NULL
		                     AND  FORMAL_GB IN ('G009_10','G009_20')
		                   UNION ALL
		                   SELECT SITE_CD
		                        , CATE_GB
		                        , 'G009_10' AS FORMAL_GB
		                        , BRAND_GROUP_NO
		                        , CATE4_NO       AS CATE_NO
		                        , FILTER_CD
		                   FROM   TAB_FILTER
		                   WHERE  CATE4_NO IS NOT NULL
		                     AND  FORMAL_GB IN ('G009_10','G009_20')
		                   UNION ALL
		                   SELECT SITE_CD
		                        , CATE_GB
		                        , 'G009_10' AS FORMAL_GB
		                        , BRAND_GROUP_NO
		                        , CATE3_NO       AS CATE_NO
		                        , FILTER_CD
		                   FROM   TAB_FILTER
		                   WHERE  CATE3_NO IS NOT NULL
		                     AND  FORMAL_GB IN ('G009_10','G009_20')
		                   UNION ALL
		                   SELECT SITE_CD
		                        , CATE_GB
		                        , 'G009_10' AS FORMAL_GB
		                        , BRAND_GROUP_NO
		                        , CATE2_NO       AS CATE_NO
		                        , FILTER_CD
		                   FROM   TAB_FILTER
		                   WHERE  CATE2_NO IS NOT NULL
		                     AND  FORMAL_GB IN ('G009_10','G009_20')
		                   UNION ALL
		                   SELECT SITE_CD
		                        , CATE_GB
		                        , 'G009_10' AS FORMAL_GB
		                        , BRAND_GROUP_NO
		                        , CATE1_NO       AS CATE_NO
		                        , FILTER_CD
		                   FROM   TAB_FILTER
		                   WHERE  CATE1_NO IS NOT NULL
		                     AND  FORMAL_GB IN ('G009_10','G009_20')
		                   UNION ALL
		                   SELECT SITE_CD
		                        , CATE_GB
		                        , FORMAL_GB
		                        , BRAND_GROUP_NO
		                        , CATE5_NO       AS CATE_NO
		                        , FILTER_CD
		                   FROM   TAB_FILTER
		                   WHERE  CATE5_NO IS NOT NULL
		                     AND  FORMAL_GB  = 'G009_20'
		                   UNION ALL
		                   SELECT SITE_CD
		                        , CATE_GB
		                        , FORMAL_GB
		                        , BRAND_GROUP_NO
		                        , CATE4_NO       AS CATE_NO
		                        , FILTER_CD
		                   FROM   TAB_FILTER
		                   WHERE  CATE4_NO IS NOT NULL
		                     AND  FORMAL_GB = 'G009_20'
		                   UNION ALL
		                   SELECT SITE_CD
		                        , CATE_GB
		                        , FORMAL_GB
		                        , BRAND_GROUP_NO
		                        , CATE3_NO       AS CATE_NO
		                        , FILTER_CD
		                   FROM   TAB_FILTER
		                   WHERE  CATE3_NO IS NOT NULL
		                     AND  FORMAL_GB = 'G009_20'
		                   UNION ALL
		                   SELECT SITE_CD
		                        , CATE_GB
		                        , FORMAL_GB
		                        , BRAND_GROUP_NO
		                        , CATE2_NO       AS CATE_NO
		                        , FILTER_CD
		                   FROM   TAB_FILTER
		                   WHERE  CATE2_NO IS NOT NULL
		                     AND  FORMAL_GB = 'G009_20'
		                   UNION ALL
		                   SELECT SITE_CD
		                        , CATE_GB
		                        , FORMAL_GB
		                        , BRAND_GROUP_NO
		                        , CATE1_NO       AS CATE_NO
		                        , FILTER_CD
		                   FROM   TAB_FILTER
		                   WHERE  CATE1_NO IS NOT NULL
		                     AND  FORMAL_GB = 'G009_20'
		               ) Z
		        WHERE  CATE_NO IS NOT NULL
		       ) A
		     , TB_COMMON_CODE CC
		WHERE  A.FILTER_CD = CC.CD
		AND    CC.CD_GB = 'G072'
		AND    CC.USE_YN = 'Y'
	</insert>

	<!-- 임시카테고리별검색필터 - 혜택 생성 -->
	<insert id="createTemporaryCategoryFilterBenefit" timeout="600">
		/* TsbDisplay.createTemporaryCategoryFilterBenefit */
		INSERT INTO TB_CATE_FILTER_TMP (
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , C4.FORMAL_GB
		         , CG.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , G.GOODS_CD
		         , GB.BENEFIT_GB
		    FROM   TB_CATE_4SRCH C4
		         , TB_CATE_GOODS CG
		         , TB_GOODS G
		         , TB_GOODS_STOCK GS
		         , TB_GOODS_BENEFIT GB
		         , TB_BRAND B
		         , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		    AND    CG.BRAND_GROUP_NO = 0
		    AND    CG.GOODS_CD = G.GOODS_CD
		    AND    CG.GOODS_CD = GS.GOODS_CD
		    AND    CG.GOODS_CD = GB.GOODS_CD
		    AND    G.BRAND_CD = B.BRAND_CD
		    AND    B.BRAND_CD = SB.BRAND_CD
		    AND    C4.SITE_CD = 'G000_10'
		    AND    C4.CATE_GB = 'G032_101'
		    AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		    AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		    AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		    AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*유효한판매기간*/
		    AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		    AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		    AND    SB.SITE_CD = 'G000_10'
		    AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , 'BENEFIT'        AS FILTER_GB
		     , FILTER_CD
		     , CASE WHEN FILTER_CD = '10' THEN '쿠폰할인'
		            WHEN FILTER_CD = '20' THEN '무료배송'
		            WHEN FILTER_CD = '30' THEN '사은품'
		            WHEN FILTER_CD = '40' THEN '신상'
		            WHEN FILTER_CD = '50' THEN '총알배송'
		       END              AS FILTER_NM
		     , RANK() OVER(PARTITION BY SITE_CD, CATE_GB, FORMAL_GB, BRAND_GROUP_NO, CATE_NO
		                   ORDER BY FILTER_CD
		                  )   AS DISP_ORD
		FROM   (
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_10' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE5_NO       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE5_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_10' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE4_NO       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE4_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_10' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE3_NO       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE3_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_10' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE2_NO       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE2_NO IS NOT NULL
		         AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_10' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE1_NO       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE1_NO IS NOT NULL
		         AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_20' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE5_NO       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE5_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_20' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE4_NO       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE4_NO IS NOT NULL
		         AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_20' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE3_NO       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE3_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_20' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE2_NO       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE2_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_20' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE1_NO       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE1_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		       ) Z
	</insert>

	<!-- 임시브랜드별검색필터 - 사이즈 생성 -->
	<insert id="createTemporaryBrandFilterSize" timeout="600">
		/* TsbDisplay.createTemporaryBrandFilterSize */
		INSERT INTO TB_CATE_FILTER_TMP (
		     SITE_CD
		   , CATE_GB
		   , FORMAL_GB
		   , BRAND_GROUP_NO
		   , CATE_NO
		   , FILTER_GB
		   , FILTER_CD
		   , FILTER_NM
		   , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , B.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , CONCAT(I.SIZE_GB,'|',S.OPT_CD2) AS FILTER_CD
		         , S.OPT_CD2                       AS FILTER_NM
		    FROM   TB_CATE_4SRCH C4
		       , TB_CATE_GOODS CG
		       , TB_GOODS G
		       , TB_ITEMKIND I
		       , VW_STOCK S
		       , TB_BRAND B
		       , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		      AND  CG.GOODS_CD = G.GOODS_CD
		      AND  G.ITEMKIND_CD = I.ITEMKIND_CD
		      AND  G.GOODS_CD = S.GOODS_CD
		      AND  G.BRAND_CD = B.BRAND_CD
		      AND  B.BRAND_CD = SB.BRAND_CD
		      AND  C4.SITE_CD = 'G000_10'
		      AND  C4.CATE_GB = 'G032_101'
		      AND  C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		      AND  G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		      AND  G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		      AND  NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		      AND  I.SIZE_GB IS NOT NULL
		      AND  S.CURR_STOCK_QTY - S.BASE_STOCK_QTY > 0 /*재고있는옵션*/
		      AND  S.SOLDOUT_YN = 'N' /*품절이 아닌 옵션*/
		      AND  S.DISP_YN = 'Y' /*노출하는 옵션*/
		      AND  LENGTH(S.OPT_CD2) > 0
		      AND  B.USE_YN = 'Y' /*사용하는 브랜드*/
		      AND  SB.SITE_CD = 'G000_10'
		      AND  SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT distinct SITE_CD
		              , CATE_GB
		              , FORMAL_GB
		              , BRAND_GROUP_NO
		              , CATE_NO
		              , 'SIZE'        AS FILTER_GB
		              , FILTER_CD
		              , FILTER_NM
		              , RANK() OVER(PARTITION BY SITE_CD, CATE_GB, FORMAL_GB, BRAND_GROUP_NO, CATE_NO
		    ORDER BY CASE WHEN FILTER_CD LIKE 'T%' THEN 1
		                  WHEN FILTER_CD LIKE 'B%' THEN 2
		                  WHEN FILTER_CD LIKE 'S%' THEN 3
		                  ELSE 4
		            END, FILTER_NM
		    )   AS DISP_ORD
		FROM   (
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , FILTER_CD
		             , FILTER_NM
		           FROM   (
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , 'G009_10' AS FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , 0       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE5_NO IS NOT NULL
		                    AND FORMAL_GB IN ('G009_10','G009_20')
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , 'G009_10' AS FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , 0       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE4_NO IS NOT NULL
		                    AND FORMAL_GB IN ('G009_10','G009_20')
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , 'G009_10' AS FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , 0       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE3_NO IS NOT NULL
		                    AND FORMAL_GB IN ('G009_10','G009_20')
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , 'G009_10' AS FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , 0       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE2_NO IS NOT NULL
		                    AND FORMAL_GB IN ('G009_10','G009_20')
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , 'G009_10' AS FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , 0       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE1_NO IS NOT NULL
		                    AND FORMAL_GB IN ('G009_10','G009_20')
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , 0       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE5_NO IS NOT NULL
		                    AND FORMAL_GB = 'G009_20'
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , 0       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE4_NO IS NOT NULL
		                    AND FORMAL_GB = 'G009_20'
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , 0       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE3_NO IS NOT NULL
		                    AND FORMAL_GB = 'G009_20'
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , 0       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE2_NO IS NOT NULL
		                    AND FORMAL_GB = 'G009_20'
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , 0       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE1_NO IS NOT NULL
		                    AND FORMAL_GB = 'G009_20'
		                  ) Z
		           WHERE  CATE_NO IS NOT NULL
		    ) Z
	</insert>

	<!-- 임시브랜드별검색필터 - 가격 생성 -->
	<insert id="createTemporaryBrandFilterPrice" timeout="600">
		/* TsbDisplay.createTemporaryBrandFilterPrice */
		INSERT INTO TB_CATE_FILTER_TMP (
		         SITE_CD
		       , CATE_GB
		       , FORMAL_GB
		       , BRAND_GROUP_NO
		       , CATE_NO
		       , FILTER_GB
		       , FILTER_CD
		       , FILTER_NM
		       , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , B.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , FN_GET_BENEFIT_PRICE('P',G.GOODS_CD,G.CURR_PRICE,'G100_10') AS CURR_PRICE
		    FROM   TB_CATE_4SRCH C4
		       , TB_CATE_GOODS CG
		       , TB_GOODS G
		       , TB_GOODS_STOCK GS
		       , TB_BRAND B
		       , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		      AND    CG.GOODS_CD = G.GOODS_CD
		      AND    CG.GOODS_CD = GS.GOODS_CD
		      AND    G.BRAND_CD = B.BRAND_CD
		      AND    B.BRAND_CD = SB.BRAND_CD
		      AND    C4.SITE_CD = 'G000_10'
		      AND    C4.CATE_GB = 'G032_101'
		      AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		      AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		      AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		      AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		      AND    GS.STOCK_QTY > 0 /*재고있는옵션*/
		      AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		      AND    SB.SITE_CD = 'G000_10'
		      AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		   , TAB_PRICE AS (
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_10' AS  FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , BRAND_GROUP_NO
		                    , 0        AS CATE_NO
		                    , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                    , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                    , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  FORMAL_GB IN ('G009_10','G009_20')
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_20' AS  FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , BRAND_GROUP_NO
		                    , 0        AS CATE_NO
		                    , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                    , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                    , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  FORMAL_GB IN ('G009_20')
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO
		           ) Z
		)
		SELECT DISTINCT
		        SITE_CD
		      , CATE_GB
		      , FORMAL_GB
		      , BRAND_GROUP_NO
		      , CATE_NO
		      , 'PRICE'        AS FILTER_GB
		      , FILTER_CD
		      , FILTER_NM
		      , RANK() OVER(PARTITION BY SITE_CD, CATE_GB, FORMAL_GB, BRAND_GROUP_NO, CATE_NO
		    ORDER BY FILTER_CD
		    )  AS DISP_ORD
		FROM   (
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE_NO
		                , PRICE1         AS FILTER_CD
		                , PRICE1         AS FILTER_NM
		           FROM   TAB_PRICE
		           WHERE PRICE1 > 0
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE_NO
		                , PRICE2         AS FILTER_CD
		                , PRICE2         AS FILTER_NM
		           FROM   TAB_PRICE
		           WHERE PRICE2 > 0
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE_NO
		                , PRICE3         AS FILTER_CD
		                , PRICE3         AS FILTER_NM
		           FROM   TAB_PRICE
		           WHERE PRICE3 > 0
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE_NO
		                , PRICE4         AS FILTER_CD
		                , PRICE4         AS FILTER_NM
		           FROM   TAB_PRICE
		           WHERE PRICE4 > 0
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE_NO
		                , PRICE5         AS FILTER_CD
		                , PRICE5         AS FILTER_NM
		           FROM   TAB_PRICE
		           WHERE PRICE5 > 0
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE_NO
		                , PRICE6         AS FILTER_CD
		                , PRICE6         AS FILTER_NM
		           FROM   TAB_PRICE
		           WHERE PRICE6 > 0
		       ) Z
	</insert>

	<!-- 임시브랜드별검색필터 - 연령대 생성 -->
	<insert id="createTemporaryBrandFilterAge" timeout="600">
		/* TsbDisplay.createTemporaryBrandFilterAge */
		INSERT INTO TB_CATE_FILTER_TMP (
		         SITE_CD
		       , CATE_GB
		       , FORMAL_GB
		       , BRAND_GROUP_NO
		       , CATE_NO
		       , FILTER_GB
		       , FILTER_CD
		       , FILTER_NM
		       , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , B.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , G.AGE_GRP_CD      AS FILTER_CD
		    FROM   TB_CATE_4SRCH C4
		       , TB_CATE_GOODS CG
		       , TB_GOODS G
		       , TB_GOODS_STOCK GS
		       , TB_BRAND B
		       , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		      AND    CG.GOODS_CD = G.GOODS_CD
		      AND    CG.GOODS_CD = GS.GOODS_CD
		      AND    G.BRAND_CD = B.BRAND_CD
		      AND    B.BRAND_CD = SB.BRAND_CD
		      AND    C4.SITE_CD = 'G000_10'
		      AND    C4.CATE_GB = 'G032_101'
		      AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		      AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		      AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		      AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		      AND    G.AGE_GRP_CD IS NOT NULL
		      AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		      AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		      AND    SB.SITE_CD = 'G000_10'
		      AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT A.SITE_CD
		     , A.CATE_GB
		     , A.FORMAL_GB
		     , A.BRAND_GROUP_NO
		     , A.CATE_NO
		     , 'AGE'          AS FILTER_GB
		     , A.FILTER_CD
		     , CC.CD_NM       AS FILTER_NM
		     , RANK() OVER(PARTITION BY A.SITE_CD, A.CATE_GB, A.FORMAL_GB, A.BRAND_GROUP_NO, A.CATE_NO
		    ORDER BY CC.DISP_ORD
		    )   AS DISP_ORD
		FROM   (
		    SELECT DISTINCT
		        SITE_CD
		        , CATE_GB
		        , FORMAL_GB
		        , BRAND_GROUP_NO
		        , 0 AS CATE_NO
		        , FILTER_CD
		    FROM   (
		           SELECT SITE_CD
		                , CATE_GB
		                , 'G009_10' AS FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE5_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE5_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , 'G009_10' AS FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE4_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE4_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , 'G009_10' AS FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE3_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE3_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , 'G009_10' AS FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE2_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE2_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , 'G009_10' AS FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE1_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE1_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE5_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE5_NO IS NOT NULL
		             AND  FORMAL_GB  = 'G009_20'
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE4_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE4_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE3_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE3_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE2_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE2_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE1_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE1_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           ) Z
		    WHERE  CATE_NO IS NOT NULL
		) A
		   , TB_COMMON_CODE CC
		WHERE  A.FILTER_CD = CC.CD
		  AND    CC.CD_GB = 'G023'
		  AND    CC.USE_YN = 'Y'
	</insert>

	<!-- 임시브랜드별검색필터 - 시즌 생성 -->
	<insert id="createTemporaryBrandFilterSeason" timeout="600">
		/* TsbDisplay.createTemporaryBrandFilterSeason */
		INSERT INTO TB_CATE_FILTER_TMP (
		         SITE_CD
		       , CATE_GB
		       , FORMAL_GB
		       , BRAND_GROUP_NO
		       , CATE_NO
		       , FILTER_GB
		       , FILTER_CD
		       , FILTER_NM
		       , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , B.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , G.SEASON_CD       AS FILTER_CD
		    FROM   TB_CATE_4SRCH C4
		       , TB_CATE_GOODS CG
		       , TB_GOODS G
		       , TB_GOODS_STOCK GS
		       , TB_BRAND B
		       , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		      AND    CG.GOODS_CD = G.GOODS_CD
		      AND    CG.GOODS_CD = GS.GOODS_CD
		      AND    G.BRAND_CD = B.BRAND_CD
		      AND    B.BRAND_CD = SB.BRAND_CD
		      AND    C4.SITE_CD = 'G000_10'
		      AND    C4.CATE_GB = 'G032_101'
		      AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		      AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		      AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		      AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		      AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		      AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		      AND    SB.SITE_CD = 'G000_10'
		      AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT A.SITE_CD
		     , A.CATE_GB
		     , A.FORMAL_GB
		     , A.BRAND_GROUP_NO
		     , A.CATE_NO
		     , 'SEASON'         AS FILTER_GB
		     , A.FILTER_CD
		     , CC.CD_NM         AS FILTER_NM
		     , RANK() OVER(PARTITION BY A.SITE_CD, A.CATE_GB, A.FORMAL_GB, A.BRAND_GROUP_NO, A.CATE_NO
		    ORDER BY CC.DISP_ORD
		    )   AS DISP_ORD
		FROM   (
		    SELECT DISTINCT
		        SITE_CD
		      , CATE_GB
		      , FORMAL_GB
		      , BRAND_GROUP_NO
		      , 0 AS CATE_NO
		      , FILTER_CD
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE5_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE5_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE4_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE4_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE3_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE3_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE2_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE2_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE1_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE1_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE5_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE5_NO IS NOT NULL
		                 AND  FORMAL_GB  = 'G009_20'
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE4_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE4_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE3_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE3_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE2_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE2_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE1_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE1_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		           ) Z
		    WHERE  CATE_NO IS NOT NULL
		) A
		   , TB_COMMON_CODE CC
		WHERE  A.FILTER_CD = CC.CD
		  AND    CC.CD_GB = 'G006'
		  AND    CC.USE_YN = 'Y'
	</insert>

	<!-- 임시브랜드별검색필터 - 컬러 생성 -->
	<insert id="createTemporaryBrandFilterColor" timeout="600">
		/* TsbDisplay.createTemporaryBrandFilterColor */
		INSERT INTO TB_CATE_FILTER_TMP (
		         SITE_CD
		       , CATE_GB
		       , FORMAL_GB
		       , BRAND_GROUP_NO
		       , CATE_NO
		       , FILTER_GB
		       , FILTER_CD
		       , FILTER_NM
		       , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , B.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , C.COLOR_GRP_CD    AS FILTER_CD
		    FROM   TB_CATE_4SRCH C4
		       , TB_CATE_GOODS CG
		       , TB_GOODS G
		       , TB_GOODS_STOCK GS
		       , TB_OPTION O
		       , TB_COLOR C
		       , TB_BRAND B
		       , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		      AND    CG.GOODS_CD = G.GOODS_CD
		      AND    CG.GOODS_CD = GS.GOODS_CD
		      AND    CG.GOODS_CD = O.GOODS_CD
		      AND    O.OPT_CD1 = C.COLOR_CD
		      AND    G.BRAND_CD = B.BRAND_CD
		      AND    B.BRAND_CD = SB.BRAND_CD
		      AND    C4.SITE_CD = 'G000_10'
		      AND    C4.CATE_GB = 'G032_101'
		      AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		      AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		      AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		      AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		      AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		      AND    O.SOLDOUT_YN = 'N' /*품절이 아닌 옵션*/
		      AND    O.DISP_YN = 'Y' /*노출하는 옵션*/
		      AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		      AND    SB.SITE_CD = 'G000_10'
		      AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT A.SITE_CD
		     , A.CATE_GB
		     , A.FORMAL_GB
		     , A.BRAND_GROUP_NO
		     , A.CATE_NO
		     , 'COLOR'          AS FILTER_GB
		     , A.FILTER_CD
		     , CC.CD_DESC       AS FILTER_NM
		     , RANK() OVER(PARTITION BY A.SITE_CD, A.CATE_GB, A.FORMAL_GB, A.BRAND_GROUP_NO, A.CATE_NO
		    ORDER BY CC.DISP_ORD
		    )   AS DISP_ORD
		FROM   (
		    SELECT DISTINCT
		            SITE_CD
		          , CATE_GB
		          , FORMAL_GB
		          , BRAND_GROUP_NO
		          , 0 as CATE_NO
		          , FILTER_CD
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE5_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE5_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE4_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE4_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE3_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE3_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE2_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE2_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE1_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE1_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE5_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE5_NO IS NOT NULL
		                 AND  FORMAL_GB  = 'G009_20'
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE4_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE4_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE3_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE3_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE2_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE2_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE1_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE1_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		           ) Z
		    WHERE  CATE_NO IS NOT NULL
		) A
		   , TB_COMMON_CODE CC
		WHERE  A.FILTER_CD = CC.CD
		  AND    CC.CD_GB = 'G072'
		  AND    CC.USE_YN = 'Y'
	</insert>

	<!-- 임시브랜드별검색필터 - 혜택 생성 -->
	<insert id="createTemporaryBrandFilterBenefit" timeout="600">
		/* TsbDisplay.createTemporaryBrandFilterBenefit */
		INSERT INTO TB_CATE_FILTER_TMP (
		         SITE_CD
		       , CATE_GB
		       , FORMAL_GB
		       , BRAND_GROUP_NO
		       , CATE_NO
		       , FILTER_GB
		       , FILTER_CD
		       , FILTER_NM
		       , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , B.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , G.GOODS_CD
		         , GB.BENEFIT_GB
		    FROM   TB_CATE_4SRCH C4
		       , TB_CATE_GOODS CG
		       , TB_GOODS G
		       , TB_GOODS_STOCK GS
		       , TB_GOODS_BENEFIT GB
		       , TB_BRAND B
		       , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		      AND    CG.GOODS_CD = G.GOODS_CD
		      AND    CG.GOODS_CD = GS.GOODS_CD
		      AND    CG.GOODS_CD = GB.GOODS_CD
		      AND    G.BRAND_CD = B.BRAND_CD
		      AND    B.BRAND_CD = SB.BRAND_CD
		      AND    C4.SITE_CD = 'G000_10'
		      AND    C4.CATE_GB = 'G032_101'
		      AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		      AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		      AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		      AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		      AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		      AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		      AND    SB.SITE_CD = 'G000_10'
		      AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT distinct SITE_CD
		          , CATE_GB
		          , FORMAL_GB
		          , BRAND_GROUP_NO
		          , 0 as CATE_NO
		          , 'BENEFIT'        AS FILTER_GB
		          , FILTER_CD
		          , CASE WHEN FILTER_CD = '10' THEN '쿠폰할인'
		                 WHEN FILTER_CD = '20' THEN '무료배송'
		                 WHEN FILTER_CD = '30' THEN '사은품'
		                 WHEN FILTER_CD = '40' THEN '신상'
		                 WHEN FILTER_CD = '50' THEN '총알배송'
		            END              AS FILTER_NM
		          , RANK() OVER(PARTITION BY SITE_CD, CATE_GB, FORMAL_GB, BRAND_GROUP_NO, CATE_NO
		    ORDER BY FILTER_CD
		    )   AS DISP_ORD
		FROM   (
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_10' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , 0       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE5_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_10' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , 0       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE4_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_10' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , 0       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE3_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_10' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , 0       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE2_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , 'G009_10' AS FORMAL_GB
		             , BRAND_GROUP_NO
		             , 0       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE1_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , 0       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE5_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , 0       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE4_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , 0       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE3_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , 0       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE2_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , 0       AS CATE_NO
		             , BENEFIT_GB     AS FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE1_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		       ) Z
	</insert>

	<!-- 임시브랜드별 카테고리검색필터-사이즈 생성 -->
	<insert id="createTemporaryBrandForCategoryFilterSize" timeout="600">
		/* TsbDisplay.createTemporaryBrandForCategoryFilterSize */
		INSERT INTO TB_CATE_FILTER_TMP (
		         SITE_CD
		       , CATE_GB
		       , FORMAL_GB
		       , BRAND_GROUP_NO
		       , CATE_NO
		       , FILTER_GB
		       , FILTER_CD
		       , FILTER_NM
		       , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , B.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , CONCAT(I.SIZE_GB,'|',S.OPT_CD2) AS FILTER_CD
		         , S.OPT_CD2                       AS FILTER_NM
		    FROM   TB_CATE_4SRCH C4
		       , TB_CATE_GOODS CG
		       , TB_GOODS G
		       , TB_ITEMKIND I
		       , VW_STOCK S
		       , TB_BRAND B
		       , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		      AND    CG.GOODS_CD = G.GOODS_CD
		      AND    G.ITEMKIND_CD = I.ITEMKIND_CD
		      AND    G.GOODS_CD = S.GOODS_CD
		      AND    G.BRAND_CD = B.BRAND_CD
		      AND    B.BRAND_CD = SB.BRAND_CD
		      AND    C4.SITE_CD = 'G000_10'
		      AND    C4.CATE_GB = 'G032_101'
		      AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		      AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		      AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		      AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		      AND    I.SIZE_GB IS NOT NULL
		      AND    S.CURR_STOCK_QTY - S.BASE_STOCK_QTY > 0 /*재고있는옵션*/
		      AND    S.SOLDOUT_YN = 'N' /*품절이 아닌 옵션*/
		      AND    S.DISP_YN = 'Y' /*노출하는 옵션*/
		      AND    LENGTH(S.OPT_CD2) > 0
		      AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		      AND    SB.SITE_CD = 'G000_10'
		      AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , 'SIZE'        AS FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , RANK() OVER(PARTITION BY SITE_CD, CATE_GB, FORMAL_GB, BRAND_GROUP_NO, CATE_NO
		    ORDER BY CASE WHEN FILTER_CD LIKE 'T%' THEN 1
		                  WHEN FILTER_CD LIKE 'B%' THEN 2
		                  WHEN FILTER_CD LIKE 'S%' THEN 3
		                  ELSE 4
		        END, FILTER_NM
		    )   AS DISP_ORD
		FROM   (
		           SELECT DISTINCT
		               SITE_CD
		             , CATE_GB
		             , FORMAL_GB
		             , BRAND_GROUP_NO
		             , CATE_NO
		             , FILTER_CD
		             , FILTER_NM
		           FROM   (
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , 'G009_10' AS FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , CATE5_NO       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE5_NO IS NOT NULL
		                    AND  FORMAL_GB IN ('G009_10','G009_20')
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , 'G009_10' AS FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , CATE4_NO       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE4_NO IS NOT NULL
		                    AND  FORMAL_GB IN ('G009_10','G009_20')
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , 'G009_10' AS FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , CATE3_NO       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE3_NO IS NOT NULL
		                    AND  FORMAL_GB IN ('G009_10','G009_20')
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , 'G009_10' AS FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , CATE2_NO       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE2_NO IS NOT NULL
		                    AND  FORMAL_GB IN ('G009_10','G009_20')
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , 'G009_10' AS FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , CATE1_NO       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE1_NO IS NOT NULL
		                    AND  FORMAL_GB IN ('G009_10','G009_20')
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , CATE5_NO       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE5_NO IS NOT NULL
		                    AND  FORMAL_GB = 'G009_20'
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , CATE4_NO       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE4_NO IS NOT NULL
		                    AND  FORMAL_GB = 'G009_20'
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , CATE3_NO       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE3_NO IS NOT NULL
		                    AND  FORMAL_GB = 'G009_20'
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , CATE2_NO       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE2_NO IS NOT NULL
		                    AND  FORMAL_GB = 'G009_20'
		                  UNION ALL
		                  SELECT SITE_CD
		                       , CATE_GB
		                       , FORMAL_GB
		                       , BRAND_GROUP_NO
		                       , CATE1_NO       AS CATE_NO
		                       , FILTER_CD
		                       , FILTER_NM
		                  FROM   TAB_FILTER
		                  WHERE  CATE1_NO IS NOT NULL
		                    AND  FORMAL_GB = 'G009_20'
		           ) Z
		           WHERE  CATE_NO IS NOT NULL
		       ) Z
	</insert>

	<!-- 임시브랜드별 카테고리검색필터-가격 생성 -->
	<insert id="createTemporaryBrandForCategoryFilterPrice" timeout="600">
		/* TsbDisplay.createTemporaryBrandForCategoryFilterPrice */
		INSERT INTO TB_CATE_FILTER_TMP (
		             SITE_CD
		           , CATE_GB
		           , FORMAL_GB
		           , BRAND_GROUP_NO
		           , CATE_NO
		           , FILTER_GB
		           , FILTER_CD
		           , FILTER_NM
		           , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , B.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , FN_GET_BENEFIT_PRICE('P',G.GOODS_CD,G.CURR_PRICE,'G100_10') AS CURR_PRICE
		    FROM   TB_CATE_4SRCH C4
		       , TB_CATE_GOODS CG
		       , TB_GOODS G
		       , TB_GOODS_STOCK GS
		       , TB_BRAND B
		       , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		      AND    CG.GOODS_CD = G.GOODS_CD
		      AND    CG.GOODS_CD = GS.GOODS_CD
		      AND    G.BRAND_CD = B.BRAND_CD
		      AND    B.BRAND_CD = SB.BRAND_CD
		      AND    C4.SITE_CD = 'G000_10'
		      AND    C4.CATE_GB = 'G032_101'
		      AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		      AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		      AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		      AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		      AND    GS.STOCK_QTY > 0 /*재고있는옵션*/
		      AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		      AND    SB.SITE_CD = 'G000_10'
		      AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		   , TAB_PRICE AS (
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_10' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		           SELECT SITE_CD
		                , CATE_GB
		                , BRAND_GROUP_NO
		                , CATE1_NO        AS CATE_NO
		                , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		           FROM   TAB_FILTER
		           WHERE  CATE1_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE1_NO
		    ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_10' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		           SELECT SITE_CD
		                , CATE_GB
		                , BRAND_GROUP_NO
		                , CATE2_NO        AS CATE_NO
		                , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		           FROM   TAB_FILTER
		           WHERE  CATE2_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE2_NO
		   ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_10' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		              SELECT SITE_CD
		                   , CATE_GB
		                   , BRAND_GROUP_NO
		                   , CATE3_NO        AS CATE_NO
		                   , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                   , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                   , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		              FROM   TAB_FILTER
		              WHERE  CATE3_NO IS NOT NULL
		                AND  FORMAL_GB IN ('G009_10','G009_20')
		              GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE3_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_10' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , BRAND_GROUP_NO
		                    , CATE4_NO        AS CATE_NO
		                    , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                    , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                    , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  CATE4_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE4_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_10' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                   , CATE_GB
		                   , BRAND_GROUP_NO
		                   , CATE5_NO        AS CATE_NO
		                   , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                   , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                   , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  CATE5_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE5_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_20' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		           SELECT SITE_CD
		                , CATE_GB
		                , BRAND_GROUP_NO
		                , CATE1_NO        AS CATE_NO
		                , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		           FROM   TAB_FILTER
		           WHERE  CATE1_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE1_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_20' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , BRAND_GROUP_NO
		                    , CATE2_NO        AS CATE_NO
		                    , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                    , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                    , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  CATE2_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE2_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_20' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , BRAND_GROUP_NO
		                    , CATE3_NO        AS CATE_NO
		                    , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                    , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                    , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  CATE3_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE3_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_20' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , BRAND_GROUP_NO
		                    , CATE4_NO        AS CATE_NO
		                    , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                    , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                    , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  CATE4_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE4_NO
		           ) Z
		    UNION ALL
		    SELECT SITE_CD
		         , CATE_GB
		         , 'G009_20' AS FORMAL_GB
		         , BRAND_GROUP_NO
		         , CATE_NO
		         , FLOOR(MIN_CURR_PRICE / 1000) * 1000                   AS PRICE1
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 1) / 1000) * 1000 AS PRICE2
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 2) / 1000) * 1000 AS PRICE3
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 3) / 1000) * 1000 AS PRICE4
		         , FLOOR((MIN_CURR_PRICE + SLICE_VAL * 4) / 1000) * 1000 AS PRICE5
		         , FLOOR(MAX_CURR_PRICE / 1000) * 1000                   AS PRICE6
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , BRAND_GROUP_NO
		                    , CATE5_NO        AS CATE_NO
		                    , MIN(CURR_PRICE) AS MIN_CURR_PRICE                    /*최소현재판매가*/
		                    , MAX(CURR_PRICE) AS MAX_CURR_PRICE                    /*최대현재판매가*/
		                    , (MAX(CURR_PRICE) - MIN(CURR_PRICE)) / 5 AS SLICE_VAL /*분할값*/
		               FROM   TAB_FILTER
		               WHERE  CATE5_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               GROUP  BY SITE_CD, CATE_GB, BRAND_GROUP_NO, CATE5_NO
		           ) Z
		)
		SELECT DISTINCT
		      SITE_CD
		      , CATE_GB
		      , FORMAL_GB
		      , BRAND_GROUP_NO
		      , CATE_NO
		      , 'PRICE'        AS FILTER_GB
		      , FILTER_CD
		      , FILTER_NM
		      , RANK() OVER(PARTITION BY SITE_CD, CATE_GB, FORMAL_GB, BRAND_GROUP_NO, CATE_NO
		    ORDER BY FILTER_CD
		    )  AS DISP_ORD
		FROM   (
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE_NO
		                , PRICE1         AS FILTER_CD
		                , PRICE1         AS FILTER_NM
		           FROM   TAB_PRICE
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE_NO
		                , PRICE2         AS FILTER_CD
		                , PRICE2         AS FILTER_NM
		           FROM   TAB_PRICE
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE_NO
		                , PRICE3         AS FILTER_CD
		                , PRICE3         AS FILTER_NM
		           FROM   TAB_PRICE
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE_NO
		                , PRICE4         AS FILTER_CD
		                , PRICE4         AS FILTER_NM
		           FROM   TAB_PRICE
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE_NO
		                , PRICE5         AS FILTER_CD
		                , PRICE5         AS FILTER_NM
		           FROM   TAB_PRICE
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE_NO
		                , PRICE6         AS FILTER_CD
		                , PRICE6         AS FILTER_NM
		           FROM   TAB_PRICE
			   ) Z
	</insert>

	<!-- 임시브랜드별 카테고리검색필터-연령대 생성 -->
	<insert id="createTemporaryBrandForCategoryFilterAge" timeout="600">
		/* TsbDisplay.createTemporaryBrandForCategoryFilterAge */
		INSERT INTO TB_CATE_FILTER_TMP (
		             SITE_CD
		           , CATE_GB
		           , FORMAL_GB
		           , BRAND_GROUP_NO
		           , CATE_NO
		           , FILTER_GB
		           , FILTER_CD
		           , FILTER_NM
		           , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , B.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , G.AGE_GRP_CD      AS FILTER_CD
		    FROM   TB_CATE_4SRCH C4
		       , TB_CATE_GOODS CG
		       , TB_GOODS G
		       , TB_GOODS_STOCK GS
		       , TB_BRAND B
		       , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		      AND    CG.GOODS_CD = G.GOODS_CD
		      AND    CG.GOODS_CD = GS.GOODS_CD
		      AND    G.BRAND_CD = B.BRAND_CD
		      AND    B.BRAND_CD = SB.BRAND_CD
		      AND    C4.SITE_CD = 'G000_10'
		      AND    C4.CATE_GB = 'G032_101'
		      AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		      AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		      AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		      AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		      AND    G.AGE_GRP_CD IS NOT NULL
		      AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		      AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		      AND    SB.SITE_CD = 'G000_10'
		      AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT A.SITE_CD
		     , A.CATE_GB
		     , A.FORMAL_GB
		     , A.BRAND_GROUP_NO
		     , A.CATE_NO
		     , 'AGE'          AS FILTER_GB
		     , A.FILTER_CD
		     , CC.CD_NM       AS FILTER_NM
		     , RANK() OVER(PARTITION BY A.SITE_CD, A.CATE_GB, A.FORMAL_GB, A.BRAND_GROUP_NO, A.CATE_NO
		    ORDER BY CC.DISP_ORD
		    )   AS DISP_ORD
		FROM   (
		    SELECT DISTINCT
		            SITE_CD
		          , CATE_GB
		          , FORMAL_GB
		          , BRAND_GROUP_NO
		          , CATE_NO
		          , FILTER_CD
		    FROM   (
		           SELECT SITE_CD
		                , CATE_GB
		                , 'G009_10' AS FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE5_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE5_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , 'G009_10' AS FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE4_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE4_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , 'G009_10' AS FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE3_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE3_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , 'G009_10' AS FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE2_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE2_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , 'G009_10' AS FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE1_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE1_NO IS NOT NULL
		             AND  FORMAL_GB IN ('G009_10','G009_20')
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE5_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE5_NO IS NOT NULL
		             AND  FORMAL_GB  = 'G009_20'
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE4_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE4_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE3_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE3_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE2_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE2_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		           UNION ALL
		           SELECT SITE_CD
		                , CATE_GB
		                , FORMAL_GB
		                , BRAND_GROUP_NO
		                , CATE1_NO       AS CATE_NO
		                , FILTER_CD
		           FROM   TAB_FILTER
		           WHERE  CATE1_NO IS NOT NULL
		             AND  FORMAL_GB = 'G009_20'
		       ) Z
		    WHERE  CATE_NO IS NOT NULL
		) A
		   , TB_COMMON_CODE CC
		WHERE  A.FILTER_CD = CC.CD
		  AND    CC.CD_GB = 'G023'
		  AND    CC.USE_YN = 'Y'
	</insert>

	<!-- 임시브랜드별 카테고리검색필터-시즌 생성 -->
	<insert id="createTemporaryBrandForCategoryFilterSeason" timeout="600">
		/* TsbDisplay.createTemporaryBrandForCategoryFilterSeason */
		INSERT INTO TB_CATE_FILTER_TMP (
		         SITE_CD
		       , CATE_GB
		       , FORMAL_GB
		       , BRAND_GROUP_NO
		       , CATE_NO
		       , FILTER_GB
		       , FILTER_CD
		       , FILTER_NM
		       , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , B.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , G.SEASON_CD       AS FILTER_CD
		    FROM   TB_CATE_4SRCH C4
		       , TB_CATE_GOODS CG
		       , TB_GOODS G
		       , TB_GOODS_STOCK GS
		       , TB_BRAND B
		       , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		      AND    CG.GOODS_CD = G.GOODS_CD
		      AND    CG.GOODS_CD = GS.GOODS_CD
		      AND    G.BRAND_CD = B.BRAND_CD
		      AND    B.BRAND_CD = SB.BRAND_CD
		      AND    C4.SITE_CD = 'G000_10'
		      AND    C4.CATE_GB = 'G032_101'
		      AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		      AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		      AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		      AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		      AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		      AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		      AND    SB.SITE_CD = 'G000_10'
		      AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT A.SITE_CD
		     , A.CATE_GB
		     , A.FORMAL_GB
		     , A.BRAND_GROUP_NO
		     , A.CATE_NO
		     , 'SEASON'         AS FILTER_GB
		     , A.FILTER_CD
		     , CC.CD_NM         AS FILTER_NM
		     , RANK() OVER(PARTITION BY A.SITE_CD, A.CATE_GB, A.FORMAL_GB, A.BRAND_GROUP_NO, A.CATE_NO
		    ORDER BY CC.DISP_ORD
		    )   AS DISP_ORD
		FROM   (
		    SELECT DISTINCT
		           SITE_CD
		          , CATE_GB
		          , FORMAL_GB
		          , BRAND_GROUP_NO
		          , CATE_NO
		          , FILTER_CD
		    FROM   (
		       SELECT SITE_CD
		            , CATE_GB
		            , 'G009_10' AS FORMAL_GB
		            , BRAND_GROUP_NO
		            , CATE5_NO       AS CATE_NO
		            , FILTER_CD
		       FROM   TAB_FILTER
		       WHERE  CATE5_NO IS NOT NULL
		         AND  FORMAL_GB IN ('G009_10','G009_20')
		       UNION ALL
		       SELECT SITE_CD
		            , CATE_GB
		            , 'G009_10' AS FORMAL_GB
		            , BRAND_GROUP_NO
		            , CATE4_NO       AS CATE_NO
		            , FILTER_CD
		       FROM   TAB_FILTER
		       WHERE  CATE4_NO IS NOT NULL
		         AND  FORMAL_GB IN ('G009_10','G009_20')
		       UNION ALL
		       SELECT SITE_CD
		            , CATE_GB
		            , 'G009_10' AS FORMAL_GB
		            , BRAND_GROUP_NO
		            , CATE3_NO       AS CATE_NO
		            , FILTER_CD
		       FROM   TAB_FILTER
		       WHERE  CATE3_NO IS NOT NULL
		         AND  FORMAL_GB IN ('G009_10','G009_20')
		       UNION ALL
		       SELECT SITE_CD
		            , CATE_GB
		            , 'G009_10' AS FORMAL_GB
		            , BRAND_GROUP_NO
		            , CATE2_NO       AS CATE_NO
		            , FILTER_CD
		       FROM   TAB_FILTER
		       WHERE  CATE2_NO IS NOT NULL
		         AND  FORMAL_GB IN ('G009_10','G009_20')
		       UNION ALL
		       SELECT SITE_CD
		            , CATE_GB
		            , 'G009_10' AS FORMAL_GB
		            , BRAND_GROUP_NO
		            , CATE1_NO       AS CATE_NO
		            , FILTER_CD
		       FROM   TAB_FILTER
		       WHERE  CATE1_NO IS NOT NULL
		         AND  FORMAL_GB IN ('G009_10','G009_20')
		       UNION ALL
		       SELECT SITE_CD
		            , CATE_GB
		            , FORMAL_GB
		            , BRAND_GROUP_NO
		            , CATE5_NO       AS CATE_NO
		            , FILTER_CD
		       FROM   TAB_FILTER
		       WHERE  CATE5_NO IS NOT NULL
		         AND  FORMAL_GB  = 'G009_20'
		       UNION ALL
		       SELECT SITE_CD
		            , CATE_GB
		            , FORMAL_GB
		            , BRAND_GROUP_NO
		            , CATE4_NO       AS CATE_NO
		            , FILTER_CD
		       FROM   TAB_FILTER
		       WHERE  CATE4_NO IS NOT NULL
		         AND  FORMAL_GB = 'G009_20'
		       UNION ALL
		       SELECT SITE_CD
		            , CATE_GB
		            , FORMAL_GB
		            , BRAND_GROUP_NO
		            , CATE3_NO       AS CATE_NO
		            , FILTER_CD
		       FROM   TAB_FILTER
		       WHERE  CATE3_NO IS NOT NULL
		         AND  FORMAL_GB = 'G009_20'
		       UNION ALL
		       SELECT SITE_CD
		            , CATE_GB
		            , FORMAL_GB
		            , BRAND_GROUP_NO
		            , CATE2_NO       AS CATE_NO
		            , FILTER_CD
		       FROM   TAB_FILTER
		       WHERE  CATE2_NO IS NOT NULL
		         AND  FORMAL_GB = 'G009_20'
		       UNION ALL
		       SELECT SITE_CD
		            , CATE_GB
		            , FORMAL_GB
		            , BRAND_GROUP_NO
		            , CATE1_NO       AS CATE_NO
		            , FILTER_CD
		       FROM   TAB_FILTER
		       WHERE  CATE1_NO IS NOT NULL
		         AND  FORMAL_GB = 'G009_20'
		    ) Z
		    WHERE  CATE_NO IS NOT NULL
		) A
		   , TB_COMMON_CODE CC
		WHERE  A.FILTER_CD = CC.CD
		  AND    CC.CD_GB = 'G006'
		  AND    CC.USE_YN = 'Y'
	</insert>

	<!-- 임시브랜드별 카테고리검색필터-컬러 생성 -->
	<insert id="createTemporaryBrandForCategoryFilterColor" timeout="600">
		/* TsbDisplay.createTemporaryBrandForCategoryFilterColor */
		INSERT INTO TB_CATE_FILTER_TMP (
		         SITE_CD
		       , CATE_GB
		       , FORMAL_GB
		       , BRAND_GROUP_NO
		       , CATE_NO
		       , FILTER_GB
		       , FILTER_CD
		       , FILTER_NM
		       , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , B.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , C.COLOR_GRP_CD    AS FILTER_CD
		    FROM   TB_CATE_4SRCH C4
		       , TB_CATE_GOODS CG
		       , TB_GOODS G
		       , TB_GOODS_STOCK GS
		       , TB_OPTION O
		       , TB_COLOR C
		       , TB_BRAND B
		       , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		      AND    CG.GOODS_CD = G.GOODS_CD
		      AND    CG.GOODS_CD = GS.GOODS_CD
		      AND    CG.GOODS_CD = O.GOODS_CD
		      AND    O.OPT_CD1 = C.COLOR_CD
		      AND    G.BRAND_CD = B.BRAND_CD
		      AND    B.BRAND_CD = SB.BRAND_CD
		      AND    C4.SITE_CD = 'G000_10'
		      AND    C4.CATE_GB = 'G032_101'
		      AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		      AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		      AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		      AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		      AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		      AND    O.SOLDOUT_YN = 'N' /*품절이 아닌 옵션*/
		      AND    O.DISP_YN = 'Y' /*노출하는 옵션*/
		      AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		      AND    SB.SITE_CD = 'G000_10'
		      AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT A.SITE_CD
		     , A.CATE_GB
		     , A.FORMAL_GB
		     , A.BRAND_GROUP_NO
		     , A.CATE_NO
		     , 'COLOR'          AS FILTER_GB
		     , A.FILTER_CD
		     , CC.CD_DESC       AS FILTER_NM
		     , RANK() OVER(PARTITION BY A.SITE_CD, A.CATE_GB, A.FORMAL_GB, A.BRAND_GROUP_NO, A.CATE_NO
		    ORDER BY CC.DISP_ORD
		    )   AS DISP_ORD
		FROM   (
		    SELECT DISTINCT
		        SITE_CD
		      , CATE_GB
		      , FORMAL_GB
		      , BRAND_GROUP_NO
		      , CATE_NO
		      , FILTER_CD
		    FROM   (
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE5_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE5_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE4_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE4_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE3_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE3_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE2_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE2_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , 'G009_10' AS FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE1_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE1_NO IS NOT NULL
		                 AND  FORMAL_GB IN ('G009_10','G009_20')
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE5_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE5_NO IS NOT NULL
		                 AND  FORMAL_GB  = 'G009_20'
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE4_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE4_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE3_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE3_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE2_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE2_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		               UNION ALL
		               SELECT SITE_CD
		                    , CATE_GB
		                    , FORMAL_GB
		                    , BRAND_GROUP_NO
		                    , CATE1_NO       AS CATE_NO
		                    , FILTER_CD
		               FROM   TAB_FILTER
		               WHERE  CATE1_NO IS NOT NULL
		                 AND  FORMAL_GB = 'G009_20'
		       ) Z
		    WHERE  CATE_NO IS NOT NULL
		) A
		   , TB_COMMON_CODE CC
		WHERE  A.FILTER_CD = CC.CD
		  AND    CC.CD_GB = 'G072'
		  AND    CC.USE_YN = 'Y'
	</insert>

	<!-- 임시브랜드별 카테고리검색필터-혜택 생성 -->
	<insert id="createTemporaryBrandForCategoryFilterBenefit" timeout="600">
		/* TsbDisplay.createTemporaryBrandForCategoryFilterBenefit */
		INSERT INTO TB_CATE_FILTER_TMP (
		         SITE_CD
		       , CATE_GB
		       , FORMAL_GB
		       , BRAND_GROUP_NO
		       , CATE_NO
		       , FILTER_GB
		       , FILTER_CD
		       , FILTER_NM
		       , DISP_ORD
		)
		WITH TAB_FILTER AS (
		    SELECT C4.SITE_CD
		         , C4.CATE_GB
		         , G.FORMAL_GB
		         , B.BRAND_GROUP_NO
		         , C4.CATE1_NO
		         , C4.CATE2_NO
		         , C4.CATE3_NO
		         , C4.CATE4_NO
		         , C4.CATE5_NO
		         , G.GOODS_CD
		         , GB.BENEFIT_GB
		    FROM   TB_CATE_4SRCH C4
		       , TB_CATE_GOODS CG
		       , TB_GOODS G
		       , TB_GOODS_STOCK GS
		       , TB_GOODS_BENEFIT GB
		       , TB_BRAND B
		       , TB_SITE_BRAND SB
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		      AND    CG.GOODS_CD = G.GOODS_CD
		      AND    CG.GOODS_CD = GS.GOODS_CD
		      AND    CG.GOODS_CD = GB.GOODS_CD
		      AND    G.BRAND_CD = B.BRAND_CD
		      AND    B.BRAND_CD = SB.BRAND_CD
		      AND    C4.SITE_CD = 'G000_10'
		      AND    C4.CATE_GB = 'G032_101'
		      AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		      AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		      AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		      AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		      AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		      AND    B.USE_YN = 'Y' /*사용하는 브랜드*/
		      AND    SB.SITE_CD = 'G000_10'
		      AND    SB.USE_YN = 'Y' /*사이트에서 사용하는 브랜드*/
		)
		SELECT SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , 'BENEFIT'        AS FILTER_GB
		     , FILTER_CD
		     , CASE WHEN FILTER_CD = '10' THEN '쿠폰할인'
		            WHEN FILTER_CD = '20' THEN '무료배송'
		            WHEN FILTER_CD = '30' THEN '사은품'
		            WHEN FILTER_CD = '40' THEN '신상'
		            WHEN FILTER_CD = '50' THEN '총알배송'
		    END              AS FILTER_NM
		     , RANK() OVER(PARTITION BY SITE_CD, CATE_GB, FORMAL_GB, BRAND_GROUP_NO, CATE_NO
		    ORDER BY FILTER_CD
		    )   AS DISP_ORD
		FROM   (
		   SELECT DISTINCT
		       SITE_CD
		     , CATE_GB
		     , 'G009_10' AS FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE5_NO       AS CATE_NO
		     , BENEFIT_GB     AS FILTER_CD
		   FROM   TAB_FILTER
		   WHERE  CATE5_NO IS NOT NULL
		     AND  FORMAL_GB IN ('G009_10','G009_20')
		   UNION ALL
		   SELECT DISTINCT
		       SITE_CD
		     , CATE_GB
		     , 'G009_10' AS FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE4_NO       AS CATE_NO
		     , BENEFIT_GB     AS FILTER_CD
		   FROM   TAB_FILTER
		   WHERE  CATE4_NO IS NOT NULL
		     AND  FORMAL_GB IN ('G009_10','G009_20')
		   UNION ALL
		   SELECT DISTINCT
		       SITE_CD
		     , CATE_GB
		     , 'G009_10' AS FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE3_NO       AS CATE_NO
		     , BENEFIT_GB     AS FILTER_CD
		   FROM   TAB_FILTER
		   WHERE  CATE3_NO IS NOT NULL
		     AND  FORMAL_GB IN ('G009_10','G009_20')
		   UNION ALL
		   SELECT DISTINCT
		       SITE_CD
		     , CATE_GB
		     , 'G009_10' AS FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE2_NO       AS CATE_NO
		     , BENEFIT_GB     AS FILTER_CD
		   FROM   TAB_FILTER
		   WHERE  CATE2_NO IS NOT NULL
		     AND  FORMAL_GB IN ('G009_10','G009_20')
		   UNION ALL
		   SELECT DISTINCT
		       SITE_CD
		     , CATE_GB
		     , 'G009_10' AS FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE1_NO       AS CATE_NO
		     , BENEFIT_GB     AS FILTER_CD
		   FROM   TAB_FILTER
		   WHERE  CATE1_NO IS NOT NULL
		     AND  FORMAL_GB IN ('G009_10','G009_20')
		   UNION ALL
		   SELECT DISTINCT
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE5_NO       AS CATE_NO
		     , BENEFIT_GB     AS FILTER_CD
		   FROM   TAB_FILTER
		   WHERE  CATE5_NO IS NOT NULL
		     AND  FORMAL_GB = 'G009_20'
		   UNION ALL
		   SELECT DISTINCT
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE4_NO       AS CATE_NO
		     , BENEFIT_GB     AS FILTER_CD
		   FROM   TAB_FILTER
		   WHERE  CATE4_NO IS NOT NULL
		     AND  FORMAL_GB = 'G009_20'
		   UNION ALL
		   SELECT DISTINCT
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE3_NO       AS CATE_NO
		     , BENEFIT_GB     AS FILTER_CD
		   FROM   TAB_FILTER
		   WHERE  CATE3_NO IS NOT NULL
		     AND  FORMAL_GB = 'G009_20'
		   UNION ALL
		   SELECT DISTINCT
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE2_NO       AS CATE_NO
		     , BENEFIT_GB     AS FILTER_CD
		   FROM   TAB_FILTER
		   WHERE  CATE2_NO IS NOT NULL
		     AND  FORMAL_GB = 'G009_20'
		   UNION ALL
		   SELECT DISTINCT
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE1_NO       AS CATE_NO
		     , BENEFIT_GB     AS FILTER_CD
		   FROM   TAB_FILTER
		   WHERE  CATE1_NO IS NOT NULL
		     AND  FORMAL_GB = 'G009_20'
		) Z
	</insert>

	<!-- 카테고리별 검색필터 삭제 -->
	<delete id="deleteCategoryFilter">
		/* TsbDisplay.deleteCategoryFilter */
		DELETE FROM TB_CATE_FILTER
	</delete>

	<!-- 카테고리별 검색필터 생성 -->
	<insert id="createCategoryFilter">
		/* TsbDisplay.createCategoryFilter */
		INSERT INTO TB_CATE_FILTER (
		       SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , DISP_ORD
		     , REG_NO
		     , REG_DT
		)
		SELECT SITE_CD
		     , CATE_GB
		     , FORMAL_GB
		     , BRAND_GROUP_NO
		     , CATE_NO
		     , FILTER_GB
		     , FILTER_CD
		     , FILTER_NM
		     , DISP_ORD
		     , 0              AS REG_NO
		     , NOW()          AS REG_DT
		FROM   TB_CATE_FILTER_TMP
	</insert>

	<!-- 최근등록된 상품 100개 삭제 -->
	<delete id="deleteRecentlyRegisterGoods">
		/* TsbDisplay.deleteRecentlyRegisterGoods */
		DELETE FROM TB_RECENT_REG_GOODS
	</delete>

	<!-- 최근등록된 상품 100개 생성 -->
	<insert id="createRecentlyRegisterGoods" timeout="600">
		/* TsbDisplay.createRecentlyRegisterGoods */
		INSERT INTO TB_RECENT_REG_GOODS (
		       MAIN_GB
		     , CATE_BGRP_NO
		     , GOODS_CD
		     , DISP_ORD
		     , REG_DT
		)
		WITH TAB_BASE AS (
		    SELECT DISTINCT
		           C4.CATE1_NO
		         , BG.BRAND_GROUP_NO
		         , CG.GOODS_CD
		         , G.REG_DT
		    FROM   TB_CATE_4SRCH C4
		         , TB_CATE_GOODS CG
		         , TB_GOODS G
		         , TB_GOODS_STOCK GS
		         , TB_BRAND B
		         , TB_BRAND_GROUP BG
		    WHERE  C4.LEAF_CATE_NO = CG.CATE_NO
		    AND    CG.GOODS_CD = G.GOODS_CD
		    AND    CG.GOODS_CD = GS.GOODS_CD
		    AND    G.BRAND_CD = B.BRAND_CD
		    AND    B.BRAND_GROUP_NO = BG.BRAND_GROUP_NO
		    AND    C4.SITE_CD = 'G000_10' /*스타일24몰*/
		    AND    C4.CATE_GB = 'G032_101' /*BYITEM카테고리*/
		    AND    C4.CATE_TYPE = 'G031_10' /*상품카테고리*/
		    AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
		    AND    G.FORMAL_GB = 'G009_10' /*정상상품*/
		    AND    G.SELF_MALL_YN = 'Y' /*몰노출상품*/
		    AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT /*판매기간*/
		    AND    GS.STOCK_QTY > 0 /*재고있는상품*/
		    AND    B.USE_YN = 'Y'
		    AND    BG.USE_YN = 'Y'
		)
		SELECT MAIN_GB
		     , CATE_BGRP_NO
		     , GOODS_CD
		     , RK             AS DISP_ORD
		     , NOW()          AS REG_DT
		FROM   (
		        /*몰메인에 노출할 최근등록된 상품 100개*/
		        SELECT 'M'                                               AS MAIN_GB
		             , 0                                                 AS CATE_BGRP_NO
		             , GOODS_CD
		             , REG_DT
		             , ROW_NUMBER() OVER(ORDER BY REG_DT DESC, GOODS_CD) AS RK
		        FROM   (
		                SELECT DISTINCT
		                       GOODS_CD
		                     , REG_DT
		                FROM   TAB_BASE
		               ) Z
		        UNION ALL
		        /*카테고리메인에 노출할 카테고리1별 최근등록된 상품 100개*/
		        SELECT 'C'                                               AS MAIN_GB
		             , CATE1_NO                                          AS CATE_BGRP_NO
		             , GOODS_CD
		             , REG_DT
		             , ROW_NUMBER() OVER(PARTITION BY CATE1_NO
		                                 ORDER BY REG_DT DESC, GOODS_CD) AS RK
		        FROM   TAB_BASE
		        UNION ALL
		        /*브랜드메인에 노출할 브랜드그룹별 최근등록된 상품 100개*/
		        SELECT 'B'                                               AS MAIN_GB
		             , BRAND_GROUP_NO                                    AS CATE_BGRP_NO
		             , GOODS_CD
		             , REG_DT
		             , ROW_NUMBER() OVER(PARTITION BY BRAND_GROUP_NO
		                                 ORDER BY REG_DT DESC, GOODS_CD) AS RK
		        FROM   (
		                SELECT DISTINCT
		                       BRAND_GROUP_NO
		                     , GOODS_CD
		                     , REG_DT
		                FROM   TAB_BASE
		               ) Z
		       ) Z
		WHERE  RK <![CDATA[<=]]> 100 /*최대100개*/
	</insert>

	<!-- 몰 메인 컨텐츠 상품 삭제 -->
	<delete id="deleteMainContentsGoods">
		/* TsbDisplay.deleteMainContentsGoods */
		DELETE FROM TB_CONTENTS_GOODS_MAIN
	</delete>

	<!-- 몰 메인 컨텐츠 상품 생성 -->
	<insert id="createMainContentsGoods">
		/* TsbDisplay.createMainContentsGoods */
		INSERT INTO TB_CONTENTS_GOODS_MAIN
		  SELECT G.GOODS_CD,
			  G.GOODS_NM,
			  G.GOODS_GB,
			  G.SELF_GOODS_YN,
			  G.FOREIGN_BUY_YN,
			  G.PARALLEL_IMPORT_YN,
			  G.ORDER_MADE_YN,
			  G.GOODS_TNM,
			  G.MAIN_COLOR_CD,
			  G.LIST_PRICE,
			  G.CURR_PRICE,
			  G.REG_DT,
			  now(),
			  CASE WHEN BG.DISP_NM_LANG = 'EN' THEN BG.BRAND_GROUP_ENM ELSE BG.BRAND_GROUP_KNM END AS BRAND_GROUP_NM,
			  (SELECT SYS_IMG_NM FROM TB_GOODS_IMG X WHERE X.GOODS_CD = G.GOODS_CD AND IF(G.SELF_GOODS_YN= 'N', 'XX', G.MAIN_COLOR_CD) = X.COLOR_CD AND DEFAULT_IMG_YN = 'Y' LIMIT 1) AS SYS_IMG_NM,
		      V.VIDEO,
			  FN_GET_GOODS_NM(G.GOODS_NM,G.GOODS_GB,G.FOREIGN_BUY_YN,G.PARALLEL_IMPORT_YN,G.ORDER_MADE_YN) AS GOODS_FULL_NM,
			  (SELECT SYS_IMG_NM FROM TB_GOODS_IMG X WHERE X.GOODS_CD = G.GOODS_CD AND IF(G.SELF_GOODS_YN= 'N', 'XX', G.MAIN_COLOR_CD) = X.COLOR_CD AND MOUSEOVER_IMG_YN = 'Y' LIMIT 1) AS SYS_IMG_NM2

		  FROM TB_GOODS G
		       INNER JOIN TB_GOODS_STOCK S  ON G.GOODS_CD = S.GOODS_CD
		  	   INNER JOIN TB_BRAND B ON G.BRAND_CD = B.BRAND_CD
			   INNER JOIN  TB_BRAND_GROUP BG ON B.BRAND_GROUP_NO = BG.BRAND_GROUP_NO
		       LEFT OUTER JOIN (
		      	      SELECT GROUP_CONCAT(CONCAT(VIDEO_GB,':',KMC_KEY) ORDER BY NUMB SEPARATOR ',') AS  VIDEO, GOODS_CD
				      FROM   (
				         SELECT GV.VIDEO_GB
				              , GV.KMC_KEY
				              , GV.REG_DT
				              , RANK() OVER(ORDER BY GV.REG_DT, GV.KMC_KEY) AS NUMB
		                      ,GOODS_CD
				         FROM   TB_GOODS_VIDEO GV
				         WHERE    GV.DISP_YN = 'Y'
				         AND    GV.KMC_KEY IS NOT NULL
				      ) Z
				      WHERE  NUMB  <![CDATA[<]]>  2
		              GROUP BY GOODS_CD
		      ) V ON G.GOODS_CD = V.GOODS_CD
		  WHERE 1=1
		     AND B.USE_YN = 'Y'
		     AND BG.USE_YN = 'Y'
			 AND    G.GOODS_STAT = 'G008_90' /*승인완료상품*/
			 AND    G.SELF_MALL_YN = 'Y'   /*몰노출상품*/
			 AND    NOW() BETWEEN G.SELL_STDT AND G.SELL_EDDT   /*판매기간*/
			 AND    S.STOCK_QTY  >  1 /*재고있는상품*/
		     AND    G.GOODS_CD IN (
						SELECT DISTINCT GOODS_CD  FROM TB_CONTENTS_GOODS
						WHERE CONTENTS_LOC IN (
						'SGNB001', 'SGNB002', 'SMM001', 'SMM002', 'SMM003'
						,'SMM004', 'SMM005', 'SMM006', 'SMM007', 'SMM008'
						,'SMM009', 'SMM011', 'STAB001', 'STAB002', 'SCM003')
					)
	</insert>
</mapper>
