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
Post a Comment