Prueba esto:
create type xxx as (t varchar, y varchar, z int);
with a as
(
select row(table_name, column_name, (random() * 100)::int) x
from information_schema.columns
)
-- cannot cast directly to xxx, should cast to text first
select (x::text::xxx).t, (x::text::xxx).y, (x::text::xxx).z
from a
Alternativamente, usted puede hacer esto:
with a as
(
select row(table_name, column_name, (random() * 100)::int) x
from information_schema.columns
),
-- cannot cast directly to xxx, should cast to text first
b as (select x::text::xxx as w from a)
select
(w).t, (w).y, (w).z
from b
Para seleccionar todos los campos:
with a as
(
select row(table_name, column_name, (random() * 100)::int) x
from information_schema.columns
),
-- cannot cast directly to xxx, should cast to text first
b as (select x::text::xxx as w from a)
select
(w).*
from b
Puede hacer esto también, pero esto hace que el Todo el ejercicio de usar ROW es inútil cuando simplemente se puede eliminar la función ROW y volver a recogerla desde afuera de cte/derivada tabl mi. Supuse que la FILA del OP venía de una función; para lo cual debe utilizar los códigos de arriba, no el siguiente:
with a as
(
select row(table_name, column_name, (random() * 100)::int)::xxx x
from information_schema.columns
)
select
(x).t, (x).y, (x).z
from a
¿Por qué necesita para agrupar esos 4 columnas para una columna? –
No necesito agruparlos, solo quiero tener una imagen para cada producto, pero no hay forma de poner LIMIT en una combinación como en mysql, lo mejor que logré fue la consulta anterior con ROW – codeassembly