I have this two queries:
SELECT 
    b.ref,
    ts.id_baits,
    SUM(strftime('%s',ts.endtime) -strftime('%s',ts.initime)) AS t,COUNT(*) AS n 
FROM TimeSegments AS ts
INNER JOIN Baits AS b ON b.id = ts.Id_Baits
GROUP BY  ts.id_baits
ORDER BY b.ref
SELECT  b.ref,
    COUNT(CASE WHEN e.Status=1 THEN 1 END) AS Undefined,
    COUNT(CASE WHEN e.Status=1 THEN 1 END) AS GetClose,
    COUNT(CASE WHEN e.Status=2 THEN 1 END) AS Threat,
    COUNT(CASE WHEN e.Status=3 THEN 1 END) AS Attack,
    COUNT(CASE WHEN e.Status=4 THEN 1 END) AS Hooked,
    COUNT(CASE WHEN e.Status=5 THEN 1 END) AS Captured,
    COUNT(CASE WHEN e.Status=6 THEN 1 END) AS Tagged,
    COUNT (*) AS TOTAL
FROM CastingsEvents AS e
LEFT JOIN Trajectories AS tr ON tr.id = e.id_trajectories 
LEFT JOIN TimeSegments AS ts ON ts.id = tr.id_timesegments
LEFT JOIN Baits AS b  ON b.id = ts.Id_Baits
GROUP BY  ts.id_baits
ORDER BY b.ref
As seen, both tables are grouped by id_baits.
I want to merge the results into one table, does someone know how to do it?