I want to group the different codes with the same price for each one in different currencies.
select clp.*, clp.c_precio as precio_clp,usd.c_precio as precio_usd, uf.c_precio as precio_uf FROM
(SELECT * FROM itsa.c_listado_piso AS p where p.c_moneda ='CLP VA' group by p.c_codigo ) as clp,
(SELECT * FROM itsa.c_listado_piso AS p where p.c_moneda ='USD FOB' group by p.c_codigo) as usd,
(SELECT * FROM itsa.c_listado_piso AS p where p.c_moneda ='UF' group by p.c_codigo) as uf
And I want to do a GROUP BY
and I get this error
SQL Error [42803]: ERROR: column "p.c_listado_piso_id" must appear in the GROUP BY clause or
be used in an aggregate function
Position: 118
I would like something like get something like this.
c_codigo |c_esp|c_largo|precio_clp |precio_usd|precio_uf|
------------|-----|-------|-----------|----------|---------
PISOCK2080-N |20 |MIX | 27833 | 25.61 | 0.9883 |
PISOCK20105-N|20 |MIX | 27833 | 25.61 | 0.9883 |
One way that I think can solve your question, at least as the data appears to be, is an aggregation query that you condition on each coin: