· 6 years ago · Jun 27, 2019, 08:54 AM
1CREATE TABLE IF NOT EXISTS `sale` (
2 `ID` int(6) unsigned NOT NULL,
3 `payment_method` int(3) unsigned NOT NULL,
4 `amount` varchar(200) NOT NULL,
5 `qty` varchar(200) NOT NULL,
6 )
7
8INSERT INTO `sale` (`id`, `payment_method`, `amount`, `qty `) VALUES
9
10 ('2', '200', '10050','1'),
11 ('3', '201', '10050','1'),
12 ('4', '200', '9045','1'),
13 ('6', '227', '10050','1'),
14 ('8', '228', '20050','2')
15
16select payment_method,sum( amount),
17sum(qty) from sale
18group by payment_method
19
20amount qty
2129145 3
2230150 3