pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Muhyiddin A.M Hayat <middink@indo.net.id>
To: pgsql-sql@postgresql.org
Subject: SUM() & GROUP BY
Date: Mon, 29 Sep 2003 02:01:14 +0800
Message-ID: <001401c385ea$836f5960$29179fca@middinkcomp> (raw)


hotel=# SELECT
hotel-#   "public".billing.id,
hotel-#   "public".billing.guest_id,
hotel-#   "public".billing.trx_date,
hotel-#   "public".billing.trx_time,
hotel-#   "public".billing.payment_method,
hotel-#   "public".billing.tax,
hotel-#   "public".billing.dep_id,
hotel-#   "public".department."name",
hotel-#   SUM("public".items.price) AS total,
hotel-#   "public".billing.amount_paid
hotel-# FROM
hotel-#   "public".billing_items
hotel-#   INNER JOIN "public".billing ON ("public".billing_items.billing_id = "public".billing.id)
hotel-#   INNER JOIN "public".department ON ("public".billing.dep_id = "public".department.id)
hotel-#   INNER JOIN "public".items ON ("public".billing_items.items_id = "public".items.id)
hotel-# GROUP BY  "public".billing.id;
ERROR:  Attribute billing.guest_id must be GROUPed or used in an aggregate function
hotel=#

What Worng ??

How to using SUM() & GROUP BY

view thread (9+ messages)  latest in thread

Message-ID: <001401c385ea$836f5960$29179fca@middinkcomp>
Permalink:  ../001401c385ea$836f5960$29179fca@middinkcomp/
Also on:    postgresql.org/message-id/001401c385ea$836f5960$29179fca@middinkcomp

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: middink@indo.net.id
  Subject: Re: SUM() & GROUP BY
  In-Reply-To: <001401c385ea$836f5960$29179fca@middinkcomp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox