input_table
username input
A A10
B A9
C A8
D A7
E A0
F A4
就像这样
如何通过从'input'字段中删除'A'char来找到输入的总和
答案 0 :(得分:8)
尝试以下代码
select SUM(SUBSTRING(input, 2)) from input_table
答案 1 :(得分:3)
试试这个,可能有用;)
MySQL 5.6架构:
SELECT DATE_SUB('2016-05-11', INTERVAL INTPART1.n ...
查询1 :
(select max(leads_update_on) from tlb_leads)
<强> Results 强>:
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')
;
答案 2 :(得分:0)
Use RIGHT
function to get the number in the right side and CAST
it and then find the SUM
.
Query
SELECT SUM(CAST(RIGHT(input, LENGTH(input) - 1) AS UNSIGNED)) AS `SUM`
FROM input_table;
答案 3 :(得分:0)
Try this also:
SELECT SUM(CAST(TRIM(LEADING 'A' FROM input)) AS UNSIGNED) AS total FROM table;