Skip site navigation (1) Skip section navigation (2)

Re: How this query!

From: Lars Haugseth <pgsql(at)larshaugseth(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Cc: richard(at)orbisindonesia(dot)com
Subject: Re: How this query!
Date: 2005-08-25 12:21:20
Message-ID: 87pss2qkan.fsf@skapulf.larshaugseth.com (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-sql
* richard(at)orbisindonesia(dot)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

In response to

pgsql-admin by date

Next:From: jose fuenmayorDate: 2005-08-25 12:52:35
Subject: size of indexes and tables (more than 1GB)
Previous:From: Richard SusantoDate: 2005-08-25 11:44:00
Subject: How this query!

pgsql-sql by date

Next:From: Bruno Wolff IIIDate: 2005-08-25 13:10:21
Subject: Re: Number of rows in a cursor ?
Previous:From: Hélder M. VieiraDate: 2005-08-25 12:16:47
Subject: Re: table listing queries

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group