我有一个表:
编号 时间长度
1      40
2      61
3      120
...我想实现这样的效果
编号 时间长度
1      40"
2      1'1"
3      2'
.....
大家有什么好办法?另外我想达到这样的效果:
编号 时间长度 累计长度
1    40         40
2    61         101
3    120        221

sql语句又该怎么写?

解决方案 »

  1.   

    数据库的记录内型为
    编号(int)时间长度(int)
    要求输出
    编号 时间长度
    1      40"
    2      1'1"
    3      2'
    .....
      

  2.   

    insert 表(编号,时间长度) values (编号,floattostr((时间长度数值 div 60)+''''+floattostr((时间长度数值 mod 60))+'''''')
      

  3.   

    最好把floattostr((时间长度数值 div 60)+''''+floattostr((时间长度数值 mod 60))+''''''
    放到外面去计算,然后赋值
      

  4.   

    --效果1
    select 编号,时间长度
    =case 时间长度/60 when 0 then '' else cast(时间长度/60 as varchar)+'''' end
    +case 时间长度%60 when 0 then '' else cast(时间长度%60 as varchar)+'"' end
    from 表--效果2
    select 编号,时间长度,累计长度=(
    select sum(时间长度) from 表 where 编号<=a.编号)
    from 表 a
      

  5.   

    oracle
    select a,to_char(trunc(B/60))||'''||to_char(mod(B/60))||'"' 
           from tableA where b>=60 and mod(B/60)<>0
    union
    select a,to_char(trunc(B/60))||'''
           from tableA where b>=60 and mod(B/60)=0
    union
    select a,to_char(mod(B/60))||'"' 
           from tableA where b<60 and b>0