How to force MySQL/MariaDB to show numbers in scientific notation?
drop function if exists sci;
DELIMITER $$
create function sci (num DOUBLE) returns text deterministic language sql
begin
set @exp = IF(num=0, 0, FLOOR(LOG10(ABS(num))));
return CONCAT(FORMAT(num*POWER(10,-@exp),2),'e',@exp);
end$$
DELIMITER ;
SELECT sci(POWER(10,12));