﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / Query to sum only few values in a same column / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 19 Jun 2013 00:44:45 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Query to sum only few values in a same column</title><link>http://www.sqlservercentral.com/Forums/Topic1414963-391-1.aspx</link><description>@park1432,Two way street here.  We're actually interested in your problem and would like a bit more info if, for nothing else, a little education on a strange request. ;-)</description><pubDate>Mon, 04 Feb 2013 18:05:56 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Query to sum only few values in a same column</title><link>http://www.sqlservercentral.com/Forums/Topic1414963-391-1.aspx</link><description>What I would ask is "What characteristic/attribute of the fourth record makes you want to exclude it?"</description><pubDate>Mon, 04 Feb 2013 14:52:48 GMT</pubDate><dc:creator>jshahan</dc:creator></item><item><title>RE: Query to sum only few values in a same column</title><link>http://www.sqlservercentral.com/Forums/Topic1414963-391-1.aspx</link><description>[quote][b]park1432 (2/3/2013)[/b][hr]Thank you very much. This will work for me now.[/quote]Since you're new, I have to ask, which one is the [font="Arial Black"]"This"[/font] you speak of and why did you choose it?</description><pubDate>Sun, 03 Feb 2013 11:27:14 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Query to sum only few values in a same column</title><link>http://www.sqlservercentral.com/Forums/Topic1414963-391-1.aspx</link><description>Thank you very much. This will work for me now.</description><pubDate>Sun, 03 Feb 2013 08:11:11 GMT</pubDate><dc:creator>park1432</dc:creator></item><item><title>RE: Query to sum only few values in a same column</title><link>http://www.sqlservercentral.com/Forums/Topic1414963-391-1.aspx</link><description>Here is a quick method.  NOT recommended for speed or flexibility ... If you would outline your requirements in greater detail perhaps some one can / will give you further assistance.[code="sql"]   CREATE TABLE For_Test(ID int not null,Name varchar(255),Amount decimal(18,2))   INSERT INTO For_Test VALUES (1,'A',220),(2,'B',340),(3,'C',540)   ,(4,'D',780)--I just want to add amount of ID 1,2 and 3 excluding 4.   SELECT SUM(Amount) FROM For_Test WHERE ID in (1,2,3)--Different select statement but same result  SELECT SUM(Amount) FROM For_Test WHERE ID &amp;lt;&amp;gt; 4--Yet a 3rd way   SELECT SUM(Amount) FROM For_Test WHERE ID &amp;lt; 4--Yet a 4th way - using MOD function   SELECT SUM(Amount) FROM For_Test WHERE ID % 4 &amp;lt;&amp;gt; 0;Result:(No column name)1100.00[/code]</description><pubDate>Sun, 03 Feb 2013 07:07:09 GMT</pubDate><dc:creator>bitbucket-25253</dc:creator></item><item><title>Query to sum only few values in a same column</title><link>http://www.sqlservercentral.com/Forums/Topic1414963-391-1.aspx</link><description>Hello all,I am kind of new to sql server and I am stuck on this. It may sound stupid and simple but here is my situation:CREATE TABLE For_Test(ID int not null,Name varchar(255),Amount decimal(18,2))INSERT INTO For_Test VALUES (1,'A',220),(2,'B',340),(3,'C',540),(4,'D',780)I just want to add amount of ID 1,2 and 3 excluding 4. There will be more than four rows in a table. So, how to do this?</description><pubDate>Sat, 02 Feb 2013 13:54:33 GMT</pubDate><dc:creator>park1432</dc:creator></item></channel></rss>