Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Impala 2.5.0
-
None
Description
sql : select UNIX_TIMESTAMP( CAST(REQUEST_MIN AS STRING), 'yyyyMMddHHmm' ) * 1000 - 28800000 AS REQUEST_TS, REQUEST_MIN, MEMBERID, CATE3_ID, CASE WHEN ROW_NUM > 1 THEN 1 ELSE 0 END AS IS_REPURCHASE FROM ( SELECT REQUEST_MIN, MEMBERID, CATE3_ID, max(ROW_NUM) AS ROW_NUM FROM ( SELECT REQUEST_MIN, MEMBERID, CASE WHEN C.CATE3_ID IS NULL THEN -1 ELSE C.CATE3_ID END AS CATE3_ID, ROW_NUMBER() OVER(partition by REQUEST_MIN, MEMBERID, C.CATE3_ID order by REQUEST_MIN) AS ROW_NUM FROM ( select ORDERID, PRODUCTID FROM CP_ORDERDETAIL WHERE CREATEDATE >= '2016-05-17 00:00:00' AND CREATEDATE < '2016-05-23 14:11:00' ) OD INNER JOIN ( SELECT CAST(FROM_UNIXTIME(UNIX_TIMESTAMP(CREATEDATE), 'yyyyMMddHHmm') AS BIGINT ) AS REQUEST_MIN, ID, MEMBERID FROM CP_ORDERS WHERE CREATEDATE >= '2016-05-17 00:00:00' AND CREATEDATE < '2016-05-23 14:11:00' AND YN = 1 ) O ON OD.ORDERID = O.ID LEFT JOIN [SHUFFLE] CP_SKU S ON OD.PRODUCTID = S.SKU_ID LEFT JOIN [SHUFFLE] CP_PRODUCT P ON S.PRODUCT_ID = P.PRODUCT_ID LEFT JOIN CATES C ON P.CATEGORY_ID = C.CATE3_ID ) XX WHERE REQUEST_MIN >= 201605231410 group by REQUEST_MIN, MEMBERID, CATE3_ID ) xx
just now I have no time to analysis why