MySQL Forums
Forum List  »  Newbie

Re: How to get this result....
Posted by: Felix Geerinckx
Date: February 28, 2007 02:12AM

Aljosa Motore Wrote:


> I have table with next data:
> Col.A | Col.B | Col.C
> -10 | A | D
> -2 | A | R
> -3 | B | D
> -1 | B | R
>
> What I want is to get next result:
> Col.B | Col.A | Desription not in result query
> A | -8 | -10-(-2)
> B | -2 | -3-(-1)

SELECT
    ColB,
    SUM(IF(ColC = 'D', ColA, -ColA))
FROM foo
GROUP BY ColB

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
February 28, 2007 12:08AM
Re: How to get this result....
February 28, 2007 02:12AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.