在分子和/或分母中添加强制转换为小数?

时间:2018-09-19 19:12:59

标签: sql-server tsql

演员表如何改变除法结果?还是我应该同时投这两个?

select 1/(cast(3 as decimal(6,2)))
select (cast(1 as decimal(6,2)))/3
select (cast(1 as decimal(6,2)))/(cast(3 as decimal(6,2)))

select 4/(cast(3 as decimal(6,2)))
select (cast(4 as decimal(6,2)))/3
select (cast(4 as decimal(6,2)))/(cast(3 as decimal(6,2)))
select 220020212/(cast(3 as decimal(6,2)))

返回

0.3333333
0.333333
0.333333333
1.3333333
1.333333
1.333333333
73340070.6666666

1 个答案:

答案 0 :(得分:0)

我喜欢先将列设置为数字,这样就不必将其转换为小数。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="render-menu">

    <li class="font-size">list 1</li>

    <li class="font-size">list 2</li>

    <li class="font-size">list 3</li>

    <li class="font-size">list 4</li>

    </ul>