Unix Technical Forum

To query SUM of multiple row of the same key id

This is a discussion on To query SUM of multiple row of the same key id within the MySQL forums, part of the Database Server Software category; --> Hi, Pls help What query I should use to get the SUM of this example EjenID ProductID Amount Month ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 08:37 AM
muadzir@yahoo.com
 
Posts: n/a
Default To query SUM of multiple row of the same key id

Hi,

Pls help

What query I should use to get the SUM of this example

EjenID ProductID Amount Month
1 41 2 9
2 40 2 9
1 40 3 9
2 41 2 9
1 42 2 10

how can I get the result of this: to view the EjenID total Amount of
purchase in Month=9

look like this

EjenID Amount Month
1 5 9
2 4 9

thanx

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 08:37 AM
Jeff Paffett
 
Posts: n/a
Default Re: To query SUM of multiple row of the same key id

muadzir@yahoo.com wrote:
> Hi,
>
> Pls help
>
> What query I should use to get the SUM of this example
>
> EjenID ProductID Amount Month
> 1 41 2 9
> 2 40 2 9
> 1 40 3 9
> 2 41 2 9
> 1 42 2 10
>
> how can I get the result of this: to view the EjenID total Amount of
> purchase in Month=9
>
> look like this
>
> EjenID Amount Month
> 1 5 9
> 2 4 9
>
> thanx
>

SELECT EjenID, SUM(Amount), Month FROM table_name WHERE Month = 9 GROUP
BY EjenID, Month
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 08:37 AM
adzir
 
Posts: n/a
Default Re: To query SUM of multiple row of the same key id

Thanks Jeff it works...

appreciate that

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:13 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com