sql - How to SUM two first character in MySQL? -


is possible sum first 2 characters using substr , group by in mysql?
such :

select sum(substr(period, 1,2) table group period 

i have tried these sql. didn't effect because of using group by. result of these query sum of period value.

try (if want sum 2 first characters):

select     sum(cast(substr(period, 1, 1)) int) + cast(substr(period, 2, 1)) int))     table group     period 

or

select     sum(cast(substr(period, 1, 2) int))      table group     period 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -