
Dudas sobre una consulta
Publicado por victor (3 intervenciones) el 04/06/2018 21:17:24
Buenas, este es mi primer post, saludos a todos.
Tengo esta consulta a 3 tablitas
Funciona correctamente, pero necesito agrupar ciertos valores e intente esto:
Sumar dos columnas y agruparlas por el label_c
Pero me da un error en la consulta, se poco de sql y he estado leyendo, pero aun no encuentro el error. Si necesitan mas información para poder responder no duden en preguntar. Saludos
Tengo esta consulta a 3 tablitas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
SELECT a.id AS id_a,
a.label AS label_a,
a.accounting_move_id,
a.accounting_account_id,
a.accounting_period_id,
a.debt,
a.credt,
a.date_at date_at_a,
a.created_at created_a,
a.updated_at AS t0_c9,
a.reconciled AS t0_c10,
b.id,
b.journal_id ,
b.label label_b,
b.date_at,
b.created_at created_b,
b.updated_at updated_b,
b.status,
c.access_key,
c.code,
c.label label_c
FROM mip_accounting_move_line a
INNER JOIN mip_accounting_move b
ON (a.accounting_move_id=b.id)
AND ((status = 'EM98') or (status = 'EM01'))
INNER JOIN mip_accounting_account c
ON (a.accounting_account_id=c.id)
ORDER BY c.access_key
Funciona correctamente, pero necesito agrupar ciertos valores e intente esto:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
SELECT a.id AS id_a,
a.label AS label_a,
a.accounting_move_id,
a.accounting_account_id,
a.accounting_period_id,
SUM(a.debt),
SUM(a.credt),
a.date_at date_at_a,
a.created_at created_a,
a.updated_at AS t0_c9,
a.reconciled AS t0_c10,
b.id,
b.journal_id ,
b.label label_b,
b.date_at,
b.created_at created_b,
b.updated_at updated_b,
b.status,
c.access_key,
c.code,
c.label label_c
FROM mip_accounting_move_line a
INNER JOIN mip_accounting_move b
ON (a.accounting_move_id=b.id)
AND ((status = 'EM98') or (status = 'EM01'))
INNER JOIN mip_accounting_account c
ON (a.accounting_account_id=c.id)
ORDER BY c.access_key
GROUP BY label_c
Sumar dos columnas y agruparlas por el label_c
Pero me da un error en la consulta, se poco de sql y he estado leyendo, pero aun no encuentro el error. Si necesitan mas información para poder responder no duden en preguntar. Saludos
Valora esta pregunta


0