sql 查询格式化
select ROW_NUMBER() OVER(ORDER BY Code DESC) AS 'Number' , Codeid,Price from table1
想把检索的number列,格式为NO.00001,NO.00002
NO后边为5位,不够的补0,怎么写呢?
------解决方案--------------------select 'NO.'+LEFT('0000'+CONVERT(VARCHAR(5),ROW_NUMBER() OVER(ORDER BY Codeid DESC)),5) AS 'Number' , Codeid,Price from table1