需要在select语句中按整数输出排序 [英] Need to order by integer output in a select statement

查看:70
本文介绍了需要在select语句中按整数输出排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

--	DECLARE @MRUN   VARCHAR(10) 
			
			SELECT HLOANS.*, CAST((INT_ARREARS+PRIN_ARREARS)/DEDUCT AS INT) as COMP_ARREARS 
		               FROM HLOANS where DEDUCT >0 and INT_ARREARS+PRIN_ARREARS>0   
		               AND CMONTH=@ZMONTH AND CYEAR=@ZYEAR	ORDER BY COMP_ARREARS 







需要按计算顺序整数 COMP_ARREARS





你如何实现它



谢谢



我尝试过:



检查互联网和代码列表




need to order by the calculated integer COMP_ARREARS


How do you accomplish it

Thanks

What I have tried:

Checked the internet and a list of codes

推荐答案

SELECT HLOANS.*, CAST((INT_ARREARS+PRIN_ARREARS)/DEDUCT AS INT) as COMP_ARREARS 
FROM HLOANS where DEDUCT >0 and INT_ARREARS+PRIN_ARREARS>0
AND CMONTH=@ZMONTH AND CYEAR=@ZYEAR
ORDER BY CAST((INT_ARREARS+PRIN_ARREARS)/DEDUCT AS INT)



另一个解决方案是直接在表中创建计算列,并在查询中引用它。


Another solution would be to create the computed column in the table directly, and referencing it in your query.


这篇关于需要在select语句中按整数输出排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆