Hola lista,
Tengo la siguiente sentencia: SELECT a.id_usuario, a.fe_ingreso, sum(a.mo_orden) as valor from compras.ordcab a where EXTRACT(year from a.fe_ingreso) = '2011' and a.id_usuario = 'MSOTO' GROUP BY a.id_usuario, a.fe_ingreso ORDER BY a.fe_ingreso y me entrega el siguiente resultado: id_usuario fe_ingreso valor MSOTO 2011-01-16 492936 MSOTO 2011-01-17 581556 MSOTO 2011-01-20 583680 MSOTO 2011-01-22 25000 MSOTO 2011-01-23 1237415 MSOTO 2011-01-24 1031500 MSOTO 2011-01-25 100000 MSOTO 2011-01-26 618849 MSOTO 2011-02-17 177840 MSOTO 2011-02-18 214320 MSOTO 2011-02-19 1285920 MSOTO 2011-02-23 4436424 12 row(s) Ahora bien cuando le aplico la crosstab: select * from crosstab('SELECT a.id_usuario, a.fe_ingreso, sum(a.mo_orden) as valor from compras.ordcab a where EXTRACT(year from a.fe_ingreso) = ''2011'' and a.id_usuario = ''MSOTO'' GROUP BY a.id_usuario, a.fe_ingreso ORDER BY a.fe_ingreso') as foo(usuario varchar, enero DOUBLE PRECISION, febrero DOUBLE PRECISION, marzo DOUBLE PRECISION, abril DOUBLE PRECISION, mayo DOUBLE PRECISION, junio DOUBLE PRECISION, julio DOUBLE PRECISION, agosto DOUBLE PRECISION, septiembre DOUBLE PRECISION, octubre DOUBLE PRECISION, noviembre DOUBLE PRECISION, diciembre DOUBLE PRECISION ); Me da éste resultado, el cual a simple vista es incorrecto: usuario enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre MSOTO 492936 581556 583680 25000 1237415 1031500 100000 618849 177840 214320 1285920 4436424 1 row(s) Pero no entiendo porque alguien me puede dar alguna pista Saludos y gracias