比如说 一张表TABLE 有 A B C D E F 5列 其中DEF 都要求和,判断条件是 A B C 。
select sum(d),sum(e),sum(f) where 1=1 and a=1and b=2 and c=3 我现在要得到的结果 a b c sum(d), sum(e) ,sum(f)
a b c 的值 就是我在WHERE 条件里写的值
select sum(d),sum(e),sum(f) where 1=1 and a=1and b=2 and c=3 我现在要得到的结果 a b c sum(d), sum(e) ,sum(f)
a b c 的值 就是我在WHERE 条件里写的值
group by a,b,c
如果有多表,表之间如何关联?
发帖注意事项
http://topic.csdn.net/u/20091130/21/fb718680-98ff-4afb-98d8-cff2f8293ed5.html?24281
字段 a b c(date) d e f
1 2 20110311 10 2 4
1 3 20110314 15 3 3
2 1 20110301 12 3 5
2 2 20110303 15 4 6
我要查询的是 结果:
a c d e f
1 (20110311-20110314) 25 5 7
2 (20110301-20110303) 27 7 11
sum(column_name)over(partition by column1 order by column1)