分钟转换为小时,标准格式为
将60转换为1.00
70转换为1.10
119转换为1.59
120转换为2.00
1800转换为30.00
1800转换为300.00
------解决方案--------------------
- SQL code
select cast(ltrim(@i/60)+'.'+ltrim(@i%60) as decimal(18,2))
------解决方案--------------------
借4楼数据一用
- SQL code
IF NOT OBJECT_ID('[tb]') IS NULL DROP TABLE [tb]GOCREATE TABLE [tb]([col] INT)INSERT [tb]SELECT 60 UNION ALLSELECT 70 UNION ALLSELECT 119 UNION ALLSELECT 120 UNION ALLSELECT 1800 UNION ALLSELECT 18000GOselect cast(col/60+(col%60)/100.0 as dec(18,2))from tb/**---------------------------------------1.001.101.592.0030.00300.00(6 行受影响)**/
------解决方案--------------------
CAST(COL*1./60 AS DEC(18,2))
------解决方案--------------------
- SQL code
--------------------SQL Server数据格式化工具------------------------------------------------ DESIGNER :happycell188(喜喜)-- QQ :584738179-- Development Tool :Microsoft Visual C++ 6.0 C Language -- FUNCTION :CONVERT DATA TO T-SQL----------------------------- Microsoft SQL Server 2005-- Developer Edition on Microsoft Windows XP [版本 5.1.2600]------------------------------------------------------use testgoif object_id('test.dbo.tb') is not null drop table tb-- 创建数据表create table tb(cnt int)go--插入测试数据insert into tb select 60union all select 70union all select 119union all select 120union all select 1800union all select 18000go--代码实现select str(ltrim(cnt/60)+'.'+ltrim(cnt%60),10,2)cnt from tb/*测试结果cnt--------------------- 1.00 1.10 1.59 2.00 30.00 300.00(6 行受影响)*/