本文介绍了如果值大于其他列名,则如何显示列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select SoftwareName as Software,LicenseQty, AssignedQty,case when LicenseQty>AssignedQty then (LicenseQty-AssignedQty) else 0 end as FreeQty,case when AssignedQty>LicenseQty
then (AssignedQty-LicenseQty)else 0 end as ExcessQty from TblSoftware

推荐答案

select SoftwareName as Software,LicenseQty, AssignedQty,
case when LicenseQty>AssignedQty then (LicenseQty-AssignedQty) else 0 end as FreeQty,
case when AssignedQty>LicenseQty
then (AssignedQty-LicenseQty)else 0 end as ExcessQty,
-- to get column name who have greater value do the following
case when AssignedQty>LicenseQty then  "AssignedQty" else "LicenseQty" end as ColumnWithGreaterValue
from TblSoftware;


这篇关于如果值大于其他列名,则如何显示列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 21:38