CREATE TABLE `worldmap` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`country_code` varchar(3) NOT NULL,
`value` INT NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
and with data like this:
INSERT INTO `testdata`.`worldmap`
(`country_code`,
`value`,
`timestamp`)
VALUES
('IE',
3.0,
now());
and this query (although it is probably better to do a GROUP BY and sum here rather than using Grafana’s aggregation):
SELECT
UNIX_TIMESTAMP(`timestamp`) as time_sec,
`value` as value,
country_code as metric
FROM worldmap
WHERE $__timeFilter(`timestamp`)
ORDER BY `timestamp` ASC
1条答案
按热度按时间c9x0cxw01#
请参见: