折雨的天空
mysql中sum函数嵌套的使用
2011-4-13 我好笨

很有可能你也不小心遇到这种需求了,看下下面几种。


select d1,d2,sum(d1,d2) from (select sum(a1,a2) as d1,sum(a3,a4) as d2,id from 500wan where id='1') as t;错


select d1,d2,(d1+d2) from (select sum(a1,a2) as d1,sum(a3,a4) as d2,id from 500wan where id='1') as t;错


select d1,d2,sum(d1,d2) from (select (a1+a2) as d1,(a3+a4) as d2,id from 500wan where id='1') as t;错


select d1,d2,(d1+d2) from (select (a1+a2) as d1,(a3+a4) as d2,id from 500wan where id='1') ;错


-------------------以上都是错的-----------------------------------------------


select d1,d2,(d1+d2) from (select (a1+a2) as d1,(a3+a4) as d2,id from 500wan where id='1') as t;对

发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容