Z4u3z1 回复 Basis(提问者)WITH T (FLA,FLB) AS(
SELECT \'大类A\',\'子类A\'
UNION ALL
SELECT \'大类A\',\'子类B\'
UNION ALL
SELECT \'大类A\',\'子类C\'
UNION ALL
SELECT \'大类A\',\'子类D\'
UNION ALL
SELECT \'大类B\',\'子类A\'
UNION ALL
SELECT \'大类B\',\'子类B\'
UNION ALL
SELECT \'大类B\',\'子类C\'
UNION ALL
SELECT \'大类B\',\'子类D\'
UNION ALL
SELECT \'大类C\',\'子类A\'
)
SELECT DENSE_RANK() OVER(ORDER BY FLA ASC) [IDA],ROW_NUMBER() OVER(PARTITION BY FLA ORDER BY FLB ASC) [IDB],* FROM T WHERE FLB LIKE\'%C\'
后面加个where 不就对了