SELECT SUM(IF(code='c1', code, IF(code='c2', code, 0))) - SUM(IF(code='c4',
code, IF(code='c5', code, 0))) FROM datavalue;

-----Original Message-----
From: VenuGopal Papasani [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 14, 2006 11:26 AM
To: mysql@lists.mysql.com
Subject: query needed

Hi,
  i got a table datavalue as follows
               code             period               value

               c1                  2005                1
                c2                 2005                2
                 c3                2006                 3
                c4                   2005               2
                 c5                2005                   1
          now i need a query where some values should be added and some
values should be subtracted of certain period.for ex here 2005 now i need
(c1+c2-c4-c5)              can i do it in a single query .Can any one give
me the query plsssssssssss


regards,
venu.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to