Received: from rdms.pyr.ec.gc.ca (fwvan1.pyr.ec.gc.ca [199.212.20.2]) by hub.org (8.10.1/8.10.1) with ESMTP id e8DMw1s95750 for ; Wed, 13 Sep 2000 18:58:01 -0400 (EDT) Received: from ec.gc.ca (IDENT:huangb@rdms.pyr.ec.gc.ca [131.235.150.90]) by rdms.pyr.ec.gc.ca (8.9.3/8.9.3) with ESMTP id PAA31985 for ; Wed, 13 Sep 2000 15:54:19 -0700 Message-ID: <39C00596.C3F3EA89@ec.gc.ca> Date: Wed, 13 Sep 2000 15:54:15 -0700 From: Bernie Huang Organization: Environment Canada X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 To: PGSQL-SQL Subject: Group by within table joins Content-Type: multipart/mixed; boundary="------------2CA2D40C090F43F3E985D944" X-Archive-Number: 200009/97 This is a multi-part message in MIME format. --------------2CA2D40C090F43F3E985D944 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Hi, I have the following SQL: SELECT ltb.v_id, count(ltb.v_id) AS num_of_times_borrowed, vtb.equip_attr[1] AS year, vtb.equip_attr[3] AS model, vtb.equip_attr[4] AS type FROM log_tb ltb, vehicle_tb vtb WHERE ltb.v_id=vtb.equip_id GROUP BY ltb.v_id ORDER BY year; "ERROR: Attribute vtb.equip_attr must be GROUPed or used in an aggregate function" but, it didn't work. I want to know how many time each vehicle has been borrowed. Please help. Thanks. - Bernie --------------2CA2D40C090F43F3E985D944 Content-Type: text/x-vcard; charset=iso-8859-15; name="bernie.huang.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Bernie Huang Content-Disposition: attachment; filename="bernie.huang.vcf" begin:vcard n:Huang;Bernie tel;fax:(604)664-9195 tel;work:(604)664-9172 x-mozilla-html:TRUE org:Environment Canada;Standards and Technology Services adr:;;700-1200 West 73 Ave.;Vancouver;BC;V6P 6H9;Canada version:2.1 email;internet:bernie.huang@ec.gc.ca title:Programmer x-mozilla-cpt:;0 fn:Bernie Huang end:vcard --------------2CA2D40C090F43F3E985D944--