Обсуждение: GROUP-BY

Поиск
Список
Период
Сортировка

GROUP-BY

От
Ludwig Meyerhoff
Дата:
Hallo!

I have a small problem with Pg 7.1 ...
I have two tables, one with the items data like description and price, one
with the customers order, item-id and amount ...

Now, the order-table is in chronological order, so it can contain several
rows. The chronological order of the orders can be of interest when
dicussing with the customer, that list contains a timestamp also, disabled
for the moment.

Now, I was trying to find one query-string to get of a customer a list of
the items ordered, the respective number ordered and the total amount to
pay for them.

I tried something like:

select w.descr, k.number, (k.anzahl*w.price) as totprice from wares w,
customerware k where w.id=k.wareid group by w.descr;

I get an errormessage:
ERROR: Attribute k.number must be GROUPed or used in an aggregate function



The "Introduction and concepts" of Mr. Momjian did not help me much :(


Maybe someone here can help me?


Saluti!

Ludwig