SQL排序表达式

ORACLE 排序表达

WITH ts AS ( 
SELECT row_number ( ) over ( PARTITION BY catalog_id ORDER BY rank_order ) row_Num, inf.* 
FROM RPT_AR_FR_REPORT_INFO inf ) 

SELECT
t.row_num 
FROM
	ts t 
WHERE
	t.rpt_id = info.rpt_id

MYSQL 排序表达

SELECT
		t.row_num
		FROM
		(SELECT
		b.*,
		IF
		( @p = catalog_id, @rownum := @rownum + 1, @rownum := 1 ) row_num,
		@p := catalog_id
		FROM
		( SELECT @p := NULL, @rownum := 0 ) rownum,
		RPT_AR_FR_REPORT_INFO b
		ORDER BY
		catalog_id,
		rank_order) t
		WHERE
		t.rpt_id = info.rpt_id

ORACLE 行转列

SELECT
	* 
FROM
	RPT_AR_FR_REPORT_CATALOG t START WITH t.catalog_id = : nodeId connect BY prior t.up_catalog_id = t.catalog_id

MYSQL 行转列

SELECT
	* 
FROM
	(
SELECT
	m.*,
	group_concat( m.catalog_nm SEPARATOR <![ CDATA [ '<-' ]]> ) catalog_path 
FROM
	( SELECT * FROM RPT_AR_FR_REPORT_CATALOG t ) m 
GROUP BY
	m.order_no 
ORDER BY
	m.order_no 
	) t 
WHERE
	t.catalog_id = #{catalogId}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值