mysql实现row_number() over

SELECT
CASE
WHEN @cust_code !=cust_code THEN @rownum:=1
ELSE @rownum:=@rownum+1
END AS rownum,
@cust_code:=cust_code AS cust_code,
channel_name,
add_date,
open_date,
order_id,
pay_amount,
order_time
FROM
(SELECT @cust_code:=”) c,
(SELECT @rownum:=0) r,
(SELECT * FROM rpt_qb_mem_conv_d ORDER BY cust_code,order_time ASC) t

你可能感兴趣的:(MySQL)