分割后的等分结果

时间:2016-07-10 18:38:20

标签: sql sql-server

我正在尝试获得没有等分的结果+ addig百分比标记。

我正在使用下面的行代码:

$ xlwings runpython install
Traceback (most recent call last):
  File "/usr/local/bin/xlwings", line 7, in <module>
    from xlwings.command_line import main
  File "/Library/Python/2.7/site-packages/xlwings/command_line.py", line 22, in <module>
    hfs_to_posix_path(app('Microsoft Excel').properties().get(k.templates_path))))
  File "/Library/Python/2.7/site-packages/aeosa/appscript/reference.py", line 577, in __getattr__
    selectortype, code = self.AS_appdata.referencebyname()[name]
  File "/Library/Python/2.7/site-packages/aeosa/appscript/reference.py", line 259, in referencebyname
    self.connect()
  File "/Library/Python/2.7/site-packages/aeosa/appscript/reference.py", line 225, in connect
    t = self._target = self._aemapplicationclass(**kargs)
  File "/Library/Python/2.7/site-packages/aeosa/aem/__init__.py", line 76, in __init__
    self._address = aemconnect.localapp(path, newinstance, hide)
  File "/Library/Python/2.7/site-packages/aeosa/aem/aemconnect.py", line 187, in localapp
    desc = _launchapplication(path, _runevent, newinstance, hide)
  File "/Library/Python/2.7/site-packages/aeosa/aem/aemconnect.py", line 55, in _launchapplication
    raise CantLaunchApplicationError(err.args[0], path)
aem.aemconnect.CantLaunchApplicationError: Can't launch application at u'/Applications/Microsoft Excel.app': The executable file is missing or has an unusable format. (-10827)

我的输出栏如下所示:

(cast(step_out_quantity as float) / step_in_quantity *100.00) as Yield

获得下一个结果的最佳选择是什么:

Yield
57.1428571428571
100
100
100
87.5
100
90.9090909090909
98.1132075471698
99.1525423728814
93.3333333333333

1 个答案:

答案 0 :(得分:1)

在标准SQL中,您可以执行以下操作:

select concat(cast(cast(step_out_quantity*100 as int
                       ) / step_in_quantity as varchar(255)
                  ), '%'
             ) as Yield

在SQL Server中,您可以执行以下操作:

select cast(floor(step_out_quantity * 100) as varchar(255)) + '%'