Home  >  Article  >  Database  >  一条比较SQL

一条比较SQL

WBOY
WBOYOriginal
2016-06-07 14:54:461171browse

如果是正偏,显示为+,如果是负偏向显示”-“,如果没有则显示”-“,该语句MSSQLserver2000下测试通过 无 --hjc为记录条数,如果没有记录则没有可比性。否则显示比较值case when hjc=0 then '-' else CAST(case when (hj-hjc)0 then '+'+cast((hj-hjc) as var

如果是正偏,显示为"+",如果是负偏向显示”-“,如果没有则显示”-“,该语句MSSQLserver2000下测试通过

--hjc为记录条数,如果没有记录则没有可比性。否则显示比较值
case when hjc=0 then '-' else CAST(case when (hj-hjc)>0 then '+'+cast((hj-hjc) as varchar) else cast((hj-hjc) as varchar) end as varchar(5000)) end as hj2,
case when hjc=0 then '-'else CAST(CAST(CASE WHEN wfhjc =wfhj  THEN 0 WHEN wfhjc = 0 AND wfhj>0 THEN 100 ELSE (wfhj-wfhjc) * 100.0 / wfhjc END AS DECIMAL(10,2)) as varchar(5000)) end as wfl2,

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:SQL导出为WordNext article:sql Raiserror with parameters