-1
The query:
SELECT DISTINCT
hosts.name as "Unidade de Negócio",
CASE
WHEN services.acknowledged = 1
THEN acknowledgements.comment_data
ELSE 0
END AS "Análise",
hosts.last_state_change*1000 as "Duração",
acknowledgements.entry_time
FROM
hosts
INNER JOIN services ON services.host_id=hosts.host_id
LEFT JOIN acknowledgements ON acknowledgements.host_id = hosts.host_id
WHERE
hosts.enabled = 1
AND hosts.name LIKE 'pa-%'
AND services.description = 'Status FG.'
AND hosts.output not LIKE '%ok%'
AND services.state = 2
AND services.scheduled_downtime_depth =0
ORDER BY acknowledgements.entry_time DESC
The problem:
He’s repeating the first three columns.
You did
join
withservices
and in this table there seems to be 3 distinct records for this samehost
. What was the expected result?– Woss
@Andersoncarloswoss the expected result is to bring all the names of the hosts with the last updated comment and the duration that it is in the monitoring, but each time we update the comment it makes an Insert to stay in the log and this causes the data to repeat, the only thing that does not repeat is the entry time, but even when I use a group by in the fields and then an order by in the entry time, only the entry time and host is ordered, but the comment that is what I need not, IE, does not work with only group by. I’m using version 5.5 of mariadb.
– Bruno Souza
Has any response helped solve the problem and can address similar questions from other users? If so, make sure to mark the answer as accepted. To do this just click on the left side of it (below the indicator of up and down votes).
– Sorack