• Please read this.

    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

    Here is a query that will make THIS specific example work.

    It rely's on your Key column to be ordered correctly.

    If the order of your keys is guaranteed then fine, but I would seriously look at the design of this table and data storage strategy before worrying about creating these queries.

    DECLARE @Table TABLE ( Varchar(10),Value1 INT, Value2 INT, Value3 INT)

    INSERT INTO @Table

    SELECT 'ky010', 100, 150, 90 UNION ALL

    SELECT 'ky020', 150, 200, 10 UNION ALL

    SELECT 'ky030', 580, 400, 10 UNION ALL

    SELECT 'ky040', 160, 100, 10 UNION ALL

    SELECT 'ky050', 110, 250, 10 UNION ALL

    SELECT 'ky060', 190, 280, 10 UNION ALL

    SELECT 'ky070', 350, 270, 10

    SELECT 'ky055',

    SUM(CASE WHEN ID =1 THEN Value1 ELSE Value1 * -1 END),

    SUM(CASE WHEN ID =1 THEN Value2 ELSE Value2 * -1 END),

    SUM(CASE WHEN ID =1 THEN Value3 ELSE Value3 * -1 END)

    FROM (

    SELECT RANK() OVER(ORDER BY [Key]) AS id, [Key], Value1, Value2, Value3

    FROM @table

    WHERE [Key] in ('ky030','ky040','ky050')

    )t