ID (auto increment)
TIMESTAMP (the same for all 6 elementids)
ELEMENTID (one of 6 values)
COUNT (0-400)
To pull my data, I am running multiple queries but trying to clean it up. I want to combine values in my parent query and getting stuck.
SELECT timestamp,count FROM stats WHERE elementid=10 ORDER BY timestamp DESC LIMIT 12
SELECT timestamp,count FROM stats WHERE elementid=11 ORDER BY timestamp DESC LIMIT 12
In this query, I would like to turn count which selects the value for the row into one query so essential my SELECT returns the timestamp and then the sum of two SELECTS as total_count for element=10 and element=11
SELECT timestamp t, (
SELECT sum(count) FROM stats WHERE elementid IN (10, 11) AND timestamp = t
) as total_count FROM stats ORDER BY timestamp DESC LIMIT 12
Ah you put me right on the correct track. Thank you!
SELECT timestamp t, (
SELECT sum(count) FROM stats WHERE elementid IN (10, 11) AND timestamp = t
) as total_count FROM stats WHERE trunk=10 OR trunk=11 GROUP BY timestamp ORDER BY timestamp DESC LIMIT 12