Search Postgresql Archives

Re: PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On May 4, 9:27 am, DaNieL <daniele.pigned...@xxxxxxxxx> wrote:
> Sorry, i know that this maybe is a basically problem, but i come from
> mysql.. and in mysql that query works...

if there's only one name per order, just put a min or max around the
second col.  as you know by now, all columns that are not GROUPed BY
must be in an aggregate function.

SELECT
 orders.code,
 MIN(customer.name),
 SUM(order_item.price)
FROM
 orders
 INNER JOIN customer ON (customer.id = orders.id_customer)
 INNER JOIN order_item ON (order_item.id_order = orders.id)
GROUP BY orders.id


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux