[英]SQL to find sum of column
I have a table insurance with columns: 我有带有表的保险:
p_id smallint
2011_inv int
2012_inv int
city char(15)
I want to find out sum total of 2012_inv
for all p_id where 2011_inv
is equal but city name is different. 我想找出所有p_id的总和
2012_inv
,其中2011_inv
相等,但城市名称不同。 Please help. 请帮忙。 I have been struggling with this all evening.
我整晚都在挣扎。
Refer to the table below 请参考下表
SELECT SUM(tiv_2012) FROM insurance
WHERE tiv_2011 = tiv_2012
AND city NOT 'value';
City is different from what? 城市有什么不同? There needs to be a value for City for it to be different from something
City必须具有与众不同的价值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.