RE : [SQL] Sum sets of records

2007-02-12 Thread Sylvain Barrette
Hi, "Group by" is what you're looking for.. select type,sum(value) from MyTable group by type Or for the total only Select sum(case when type='C' then value when type='W' then -value else 0 end) from MyTable hth Sylvain Barrette Architecte et analyste principal, RE/MAX Québec inc. Hi list

Re: [SQL] Sum sets of records

2007-02-12 Thread Bart Degryse
select sum(case when id = 'C' then value else -value end) as total from mytable >>> "Ezequias Rodrigues da Rocha" <[EMAIL PROTECTED]> 2007-02-12 16:41 >>> Hi list, I would like a little help from you to get the sum value of various subsets of my table. My table is like this id | type | value 1

[SQL] Sum sets of records

2007-02-12 Thread Ezequias Rodrigues da Rocha
Hi list, I would like a little help from you to get the sum value of various subsets of my table. My table is like this id | type | value 1 C 10.00 2 C 15.00 3 W5.00 4 W3.00 Where C is credit and w is witdraw. How do I sum all records with C and subtract with