mysql灏嗗瓧绗︿覆杞垚鏁板瓧
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql灏嗗瓧绗︿覆杞垚鏁板瓧相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e5%ad%97%e7%ac%a6%e4%b8%b2' title='瀛楃涓?>瀛楃涓?/a> val mount 鎺掑垪 sele nsa color 鍒嗙粍 rgb
浠婂ぉ鍐檚ql璇彞鏃讹紝鐩稿瀛楃涓茬被鍨嬬殑鏁板瓧杩涜鎺掑簭锛屾€庝箞鍋氬憿锛?/p>
闇€瑕佸厛杞崲鎴愭暟瀛楀啀杩涜鎺掑簭
1.鐩存帴鐢ㄥ姞娉?/p>
銆€銆€瀛楃涓?0
eg:
銆€銆€select * from orders order by (mark+0) desc
eg:
浠ュ垎绫诲瓧娈佃繘琛屽垎缁勶紝鑾峰彇鍒嗙被鎬绘暟amount锛屽拰qty锛堟暟閲忥級锛屾渶鍚庝互amount杩涜鏈夊ぇ鍒板皬鐨勫€掑簭鎺掑垪
SELECT category_code,SUM(transaction_number) as qty ,FORMAT(SUM(number*price),2)+0 as amount FROM sell WHERE date=鈥?017-03-06鈥?nbsp;GROUP BY category_code ORDER BY amount DESC;
2.浣跨敤鍑芥暟
CAST(value as type);
CONVERT(value, type);
娉細
銆€銆€杩欓噷鐨則ype鍙互涓猴細
銆€銆€銆€銆€娴偣鏁?: DECIMAL
銆€銆€銆€銆€鏁存暟 : SIGNED
銆€銆€銆€銆€鏃犵鍙锋暣鏁?: UNSIGNED
eg:
銆€銆€select * from orders order by CONVERT(mark,SIGNED) desc
銆€銆€select * from orders order by CAST(mark as SIGNED) desc
以上是关于mysql灏嗗瓧绗︿覆杞垚鏁板瓧的主要内容,如果未能解决你的问题,请参考以下文章