我有2张桌子
TBL1
INSERT INTO `tbl1` (`id_tbl1`, `name`, `weight`) VALUES (1, 'data_1', 0.2), (2, 'data_2', 0.3), (3, 'data_3', 0.4), (4, 'data_4', 0.5), (5, 'data_5', 0.5), (6, 'data_6', 0.9), (7, 'data_7', 0.9), (14, 'data_14', 0.2), (15, 'data_15', 0.4), (16, 'data_16', 0.6), (17, 'data_17', 0.5), (18, 'data_18', 0.7), (19, 'data_19', 0.9);
TBL2
INSERT INTO `tbl2` (`id_tbl2`, `id_category`, `id_tbl1`) VALUES (1, 1, 1), (2, 1, 2), (3, 1, 3), (4, 1, 4), (5, 1, 5), (6, 1, 6), (7, 1, 7), (14, 3, 14), (15, 3, 15), (16, 3, 16), (17, 3, 17), (18, 3, 18), (19, 3, 19);
和我的查询
SELECT SUM(weight) AS 'total' FROM tbl2 JOIN tbl1 ON tbl2.id_tbl1 = tbl1.id_tbl1 GROUP BY id_category;
结果应为3.7和3.3,但显示
3.6999999999999997 3.3000000000000003
有人可以告诉我出了什么问题吗?
谢谢。