Re: simple query question

From: "John K(dot) Herreshoff" <jkherr(at)power-net(dot)net>
To: Akbar <tuxer(at)myrealbox(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: simple query question
Date: 2005-02-07 11:17:47
Message-ID: 200502070617.47968.jkherr@power-net.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Monday 07 February 2005 07:23 am, Akbar wrote:

Try SELECT name, sum(sum) as total_sum, buying_price, sale_price
FROM view_stok_table_total
GROUP BY name, buying_price, sale_price
ORDER BY buying_price, sale_price;

HTH.

John.

> Hi.....
>
> Imagine I have view named view_stok_table_total....
> SELECT * FROM view_stok_table_total;
> index name sum buying_price sale_price
> 1 mentos 5 100 120
> 2 mentos 8 110 140
> 3 durex 9 200 210
> 4 queen 10 400 450
>
> You see, there are two mentos ( same product but different
> price )......
> What query command that I have to issue so that I get the list
> like this:
> name sum buying_price sale_price
> mentos 13 110 140
> durex 9 200 210
> queen 10 400 450
>
> so this time, there is only one mentos. This mentos has 13 ( 8 + 5 )
> stuff, and use the highest index's ( that is 2 because 2 is higher than
> 1 ) buying_price and sale_price value.
>
> Thank you....
>
> regards,
>
> akbar
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Schuhmacher, Bret 2005-02-07 11:34:03 Stuck in "group by" aggregate hell
Previous Message Michael Fuhr 2005-02-07 06:42:06 Re: simple query question