I\'ve create a stored procedure in MySQL like the this
CREATE DEFINER=`root`@`localhost` PROCEDURE `my_proc`(IN var1 VARCHAR(25))
BEGIN
select (sum(er)*9)/(out/3
You can define a stored function instead of a stored procedure.
CREATE DEFINER=`root`@`localhost` FUNCTION `my_func`(IN var1 VARCHAR(25))
RETURNS NUMERIC(9,2)
BEGIN
RETURN (SELECT (SUM(er)*9)/(out/3) AS era FROM table1 WHERE id = var1);
END
Then you can call it simply as you would call a function:
SELECT id, column1, column2, my_func(table1.id) AS era FROM table1
The stored function must be guaranteed to return a single scalar to be usable in your select-list.
I removed the GROUP BY, since it's superfluous.
The example above is kind of suspicious, because there's no reason to call a function like this to calculate the SUM over a single row. But I guess you have something more complex in mind.