SELECT
ReqColumns, hostid, name, (TotalUsed/TotalMemory)* 100 AS Value
FROM
(
SELECT
sc.ReqColumns, i.hostid, i.name,
SUM(IF(i.name='Total Memory [used]',TRUNCATE((tu.value_max) / (1024 * 1024 * 1024), 2) ,0)) AS TotalUsed,
SUM(IF(i.name='Total Memory',TRUNCATE((tu.value_max) / (1024 * 1024 * 1024), 2) ,0)) AS TotalMemory
FROM
trends_uint tu
INNER JOIN items i
ON i.itemid = tu.itemid
INNER JOIN graphs_items gi
ON gi.itemid = i.itemid
INNER JOIN graphs g
ON g.graphid = gi.graphid
INNER JOIN HOSTS h
ON h.hostid = i.hostid
LEFT JOIN flip_linkutilisation.servercolumns sc
ON sc.ColumnDetails = g.name
WHERE
i.name IN ('Total Memory', 'Total Memory [Free]',
'Total Memory [used]')
GROUP BY sc.ReqColumns, i.hostid, i.name
) AS x
well i think this will solve your problem?
watch out i remove the unnecessary joins and columns and reduce the number of reads