当前位置: 代码迷 >> Sql Server >> sql 查询格式化解决方法
  详细解决方案

sql 查询格式化解决方法

热度:53   发布时间:2016-04-25 00:08:53.0
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
  相关解决方案