日期:2014-05-16  浏览次数:20768 次

求一个sql语句,麻烦大家了,谢谢

现在数据格式如下,需要将数据累加,结果如下
3
6
5
3

mysql>   SELECT   o.xs,   o.s,   o.m,   o.l,   o.xl,   o.xxl,   o.xxxl   FROM   xxxxxx   o;

+------+-------+------+------+------+------+------+
|   xs       |   s           |   m         |   l         |   xl       |   xxl     |   xxxl   |
+------+-------+------+------+------+------+------+
|             |   1           |   2         |             |             |             |             |
|   1,2,   |   ,3,       |   ,,       |   ,,       |   ,,       |   ,,       |   ,,       |
|             |   2           |   3         |             |             |             |             |
|             |               |   1         |   2         |             |             |             |
|             |   1           |   2         |             |             |             |             |
|             |               |   2         |   3         |             |             |             |
|   1         |   2           |   3         |             |             |             |             |
|   1,,     |   1,2,2   |   ,3,2   |   ,,       |   ,,       |   ,,       |   ,,       |
+------+-------+------+------+------+------+------+




------解决方案--------------------
create table ss(xs int,s int);
insert into ss select 2,0 union all
select 1,20 union all select 3,5;
select sum(xs+s) from ss group by xs;

====

query result(3 records)
sum(xs+s)
21
2
8

------解决方案--------------------
再想想
------解决方案--------------------
用存储过程,