Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

/*ejercicio 1*/

select u.id,
u.firstname||' '||u.surname as nombre_completo,
(select ua.firstname||' '||ua.surname as nombre_completo
from "user" ua
where ua.id = u.advisorid) as nom_comp_advisor,
u.created as fecha_creacion
from "user" u where u.id = 1708;
/*ejercicio 2*/
SELECT gc.title balance,
sum(g.monthlycontribution)aporte_actual,
c.name moneda
FROM "goal" g,
"goalcategory" gc,
"currency" c
where g.userid = 1708
and g.goalcategoryid = gc.id
and g.currencyid = c.id
group by gc.title,c.name;
/*ejercicio 3*/
SELECT gc.title balance,
sum(g.monthlycontribution)aporte_total,
c.name moneda
FROM "goal" g,
"goalcategory" gc,
"currency" c
where g.userid = 1708
and g.goalcategoryid = gc.id
and g.currencyid = c.id
and g.created BETWEEN '2022-01-01 00:00:00'
and '2022-12-31 23:59:59'
group by gc.title,c.name;
/*ejercicio 4*/

You might also like