input_table
username input
A A10
B A9
C A8
D A7
E A0
F A4
like so on
How i can find sum of input by removing 'A' char from 'input' field
Try the below code
select SUM(SUBSTRING(input, 2)) from input_table
Try this, may work;)
SQL Fiddle
MySQL 5.6 Schema:
CREATE TABLE input_table
(`username` varchar(1), `input` varchar(3))
;
INSERT INTO input_table
(`username`, `input`)
VALUES
('A', 'A10'),
('B', 'A9'),
('C', 'A8'),
('D', 'A7'),
('E', 'A0'),
('F', 'A4')
;
Query 1:
select sum(replace(input, 'A', '')) from input_table
Results:
| sum(replace(input, 'A', '')) |
|------------------------------|
| 38 |
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With