Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 17, 2022 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/aaa2736bc47eff6f2ff87a89a2e5e0c0 to your computer and use it in GitHub Desktop.
Save parzibyte/aaa2736bc47eff6f2ff87a89a2e5e0c0 to your computer and use it in GitHub Desktop.
sistema_textil=# select e.nombre, e.apellido_paterno, e.apellido_materno, e.sueldo, ( select coalesce(json_agg(bonos), '[]') from ( select cantidad, concepto from bonos_empleado_nomina where id_nomina = 3 and id_empleado = e.id ) bonos ) bonos from empleados e;
nombre | apellido_paterno | apellido_materno | sueldo | bonos
------------------+------------------+------------------+---------+----------------------------------------------------
Luis | Cabrera | Benito | 1500.00 | [{"cantidad":50.00,"concepto":"Me cae bien"}]
Nombre muy largo | Nombre muy largo | Nombre muy largo | 5000.00 | [{"cantidad":20.00,"concepto":"Ejemplo de bono"}, +
| | | | {"cantidad":30.00,"concepto":"Otro bono"}]
Otro | Rivera | BernabΘ | 30.00 | []
Hola | Hola | Hola | 20.00 | []
Ejemplo | 20 | 30 | 30.00 | []
Ejemplo | 20 | 20 | 30.00 | []
123 | 123 | 123 | 12.00 | []
asd | 123 | 123 | 213.00 | []
13 | 12 | 31 | 31.00 | []
3 | 123 | 1 | 1.00 | []
asd | asd | da | 12.00 | []
qweq | qew | qwe | 12.00 | []
asd | assad | asd | 12.00 | []
asd | asd | asd | 123.00 | []
Pedro | 123 | 1231 | 123.00 | []
Chris | Redfield | A | 300.00 | []
Leon | Scott | Kennedy | 500.00 | []
Marφa JosΘ | a | a | 2000.00 | []
JosΘ Francisco | a | a | 5000.00 | []
Fernando | a | a | 30.00 | []
Abraham | a | a | 50.00 | []
(21 filas)
sistema_textil=#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment