Sqlite3 problem with duplicate values

0

. Tables involved:

data_incidence

data_ticket

I try to execute this query:

select t1.fecha_carga, t1.hurtos, t2.fallas, t3.ticket
                                from (select count(ttc) as hurtos, fecha_carga from data_incidencia
                                where campo_key_id = 2
                                group by fecha_carga) t1,
                                (select count(ttc) as fallas, fecha_carga from data_incidencia
                                where campo_key_id = 1
                                group by fecha_carga) t2,
                                (select count(ticket) as ticket, fecha_solicitud as fecha_carga from data_ticket ) t3 where t1.fecha_carga = t2.fecha_carga;

and the result is as follows:

and the expected is this:

    
asked by Anthony 20.05.2018 в 19:02
source

1 answer

0

I would say the result is correct. You have not linked the fecha_solicitud of data_ticket with no other date. Try the following way to see how:

select t1.fecha_carga, t1.hurtos, t2.fallas, t3.ticket
                                from (select count(ttc) as hurtos, fecha_carga from data_incidencia
                                where campo_key_id = 2
                                group by fecha_carga) t1,
                                (select count(ttc) as fallas, fecha_carga from data_incidencia
                                where campo_key_id = 1
                                group by fecha_carga) t2,
                                (select count(ticket) as ticket, fecha_solicitud as fecha_carga from data_ticket ) t3 where t1.fecha_carga = t2.fecha_carga and t2.fecha_carga = t3.fecha_carga;
    
answered by 23.05.2018 в 19:56