Explorar el Código

메인 쿼리 수정

bin2107 hace 5 años
padre
commit
c18a22fdfb
Se han modificado 1 ficheros con 39 adiciones y 26 borrados
  1. 39 26
      src/main/java/com/style24/persistence/mybatis/shop/TsfGoods.xml

+ 39 - 26
src/main/java/com/style24/persistence/mybatis/shop/TsfGoods.xml

@@ -1411,7 +1411,10 @@
 		         , G.LIST_PRICE         /*정상가(최초판매가)*/
 		         , G.CURR_PRICE         /*현재판매가*/
 		         , G.REG_DT             /*등록일시*/
-		         , G.NUMB
+		         , G.DISP_ORD
+				<if test="contentsLoc == 'SCM002'">
+					, G.SELL_WEEK_QTY
+				</if>
 		    FROM   (
 		            SELECT CASE WHEN BG.DISP_NM_LANG = 'EN' THEN
 		                            BG.BRAND_GROUP_ENM
@@ -1430,28 +1433,21 @@
 		                 , G.LIST_PRICE                                             /*정상가(최초판매가)*/
 		                 , G.CURR_PRICE                                             /*현재판매가*/
 		                 , G.REG_DT                                                 /*등록일시*/
-		                 <choose>
-		                     <when test="contentsLoc == 'SCM113'"> <!-- 베스트 -->
-		                 , ROW_NUMBER() OVER(ORDER BY GS.SELL_WEEK_QTY DESC
-		                                            , G.GOODS_CD) AS NUMB
-		                     </when>
-		                     <when test="contentsLoc == 'SMM009' or contentsLoc == 'SMM007' or contentsLoc == 'SMM012'"> <!-- md추천 -->
-		                 , ROW_NUMBER() OVER(ORDER BY CTG.DISP_ORD
-		                 , G.REG_DT DESC
-		                 , G.GOODS_CD) AS NUMB
-		                     </when>
-		                     <when test="contentsLoc == 'SCM002' or (contentsLoc == 'SCM003' and pageGb == null)"> <!-- md추천 -->
-		                  , ROW_NUMBER() OVER(ORDER BY CG.DISP_ORD ,G.UPD_DT DESC, G.CURR_PRICE DESC, G.GOODS_CD ASC) AS NUMB
-		                     </when>
-		                     <when test="contentsLoc == 'SCM003' and pageGb != null and pageGb == 'BEST'">
-		                  , ROW_NUMBER() OVER(ORDER BY C4.CATE1_NO, CG.DISP_ORD ,G.UPD_DT DESC, G.CURR_PRICE DESC, G.GOODS_CD ASC) AS NUMB
-		                     </when>
-		                     <otherwise>
-		                 , ROW_NUMBER() OVER(ORDER BY CG.DISP_ORD
-		                                            , G.REG_DT DESC
-		                                            , G.GOODS_CD) AS NUMB
-		                     </otherwise>
-		                 </choose>
+		                 , G.UPD_DT
+					<choose>
+						<when test="contentsLoc == 'SMM009' or contentsLoc == 'SMM007' or contentsLoc == 'SMM012'">
+						 , CT.DISP_ORD
+		                 </when>
+		                 <otherwise>
+						 , CG.DISP_ORD
+						 </otherwise>
+					</choose>
+		            <if test="contentsLoc == 'SCM002'">
+						, GS.SELL_WEEK_QTY
+					</if>
+					<if test="contentsLoc == 'SCM003' and pageGb != null and pageGb == 'BEST'">
+		            	, C4.CATE1_NO
+		            </if>
 		            <choose>
 		                <when test="contentsLoc == 'SMM009' or contentsLoc == 'SMM007' or contentsLoc == 'SMM012'"> <!-- md추천 -->
 		                    FROM	TB_CONTENTS CT
@@ -1523,18 +1519,35 @@
 		            </if>
 		           ) G
 		    WHERE  1=1
+		<choose>
+			<when test="contentsLoc == 'SCM113'"> <!-- 베스트 -->
+				ORDER BY G.SELL_WEEK_QTY DESC , G.GOODS_CD
+			</when>
+			<when test="contentsLoc == 'SMM009' or contentsLoc == 'SMM007' or contentsLoc == 'SMM012'"> <!-- md추천 -->
+				ORDER BY G.DISP_ORD , G.REG_DT DESC , G.GOODS_CD
+			</when>
+			<when test="contentsLoc == 'SCM002' or (contentsLoc == 'SCM003' and pageGb == null)"> <!-- md추천 -->
+				ORDER BY G.DISP_ORD ,G.UPD_DT DESC, G.CURR_PRICE DESC, G.GOODS_CD ASC
+			</when>
+			<when test="contentsLoc == 'SCM003' and pageGb != null and pageGb == 'BEST'">
+				ORDER BY G.CATE1_NO, G.DISP_ORD ,G.UPD_DT DESC, G.CURR_PRICE DESC, G.GOODS_CD ASC
+			</when>
+			<otherwise>
+				ORDER BY G.DISP_ORD , G.REG_DT DESC , G.GOODS_CD
+			</otherwise>
+		</choose>
 		<if test="pageable != null and pageable.endRow != null and pageable.endRow > 0">
 		    <choose>
 		        <when test="pageGb == 'BEST' and pageable.endRow >= 100">
-		    AND  G.NUMB BETWEEN #{pageable.startRow} AND 100
+		    LIMIT 100
 		        </when>
 		        <otherwise>
-		    AND  G.NUMB BETWEEN #{pageable.startRow} AND #{pageable.endRow}
+		    LIMIT #{pageable.startRow} , #{pageable.endRow}
 		        </otherwise>
 		    </choose>
 		</if>
 		<if test="maxRow != null and maxRow !=''">
-			AND  G.NUMB <![CDATA[<=]]> #{maxRow}
+			LIMIT #{maxRow}
 		</if>
 		)
 		SELECT G.BRAND_GROUP_NM