码迷,mamicode.com
首页 > 数据库 > 详细

mysql 中if(),left(),right(),with rollup的用法

时间:2015-01-20 17:52:47      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:

if的用法:

mysql> select if(10>9,10,9) as bigger from dual;
+--------+
| bigger |
+--------+
|     10 |
+--------+

left()和right()的用法:

mysql> select left(abcdeft,4) a,right(abcdeft,4) b;
+------+------+
| a    | b    |
+------+------+
| abcd | deft |
+------+------+

with rollup的用法:

select substr(tDeliverdate,1,10) riqi,sum(dSalesPrice) sale_amount from test.sale_order_detail group by riqi with rollup;
+------------+-------------+
| riqi       | sale_amount |
+------------+-------------+
| 2014-12-31 |    0.300000 |
| 2015-01-17 |  240.000000 |
| NULL       |  240.300000 |
+------------+-------------+

 

mysql 中if(),left(),right(),with rollup的用法

标签:

原文地址:http://www.cnblogs.com/rabbit168/p/4236346.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!