Unix Technical Forum

How this query!

This is a discussion on How this query! within the pgsql Admins forums, part of the PostgreSQL category; --> Folks, would you like help me how to query this case. I have tbl_a, the fields are : item_record ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 05:10 AM
Richard Susanto
 
Posts: n/a
Default How this query!

Folks,
would you like help me how to query this case.

I have tbl_a, the fields are :
item_record
item_product_name
item_qty


if the data are :

item_record = 1,2,3,4,5,6
item_product_name = a,b,a,c,d,c,...
item_qty = 10,5,15,10,20,5,...

How the query to sum item_qty_total if i want the result :
item_product_name = a,b,c,d
item_qty_total = 25,5,15,20

Regards,
--
>>Richard Sitompul<<

Software Engineer
PT. Orbis Indonesia
http://www.orbisindonesia.com
http://richardsstp.3wsi.net


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 05:10 AM
Lars Haugseth
 
Posts: n/a
Default Re: How this query!


* richard@orbisindonesia.com ("Richard Susanto") wrote:
|
| Folks,
| would you like help me how to query this case.
|
| I have tbl_a, the fields are :
| item_record
| item_product_name
| item_qty
|
|
| if the data are :
|
| item_record = 1,2,3,4,5,6
| item_product_name = a,b,a,c,d,c,...
| item_qty = 10,5,15,10,20,5,...
|
| How the query to sum item_qty_total if i want the result :
| item_product_name = a,b,c,d
| item_qty_total = 25,5,15,20

SELECT item_product_name, sum(item_qty) FROM tbl_a GROUP BY item_product_name;

--
Lars Haugseth
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:54 AM.


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