SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table test (id serial, email varchar(64), price int, type varchar(64), areaid int); insert into test (email, price, type, areaid) values ('person2@test1.com', 70, 'type1', 1), ('person3@test2.com', 60, 'type2', 2), ('person3@test3.com', 50, 'type1', 3), ('person4@test4.com', 110, 'type1', 3), ('person1@test1.com', 90, 'type2', 4), ('person2@test2.com', 65, 'type2', 1), ('person3@test3.com', 84, 'type2', 2), ('person4@test4.com', 84, 'type1', 2); DELIMITER $$ CREATE FUNCTION max_price() RETURNS int NOT DETERMINISTIC BEGIN SELECT MAX(price) INTO max_price FROM test; RETURN max_price; END $$ DELIMITER ; SELECT max_price();
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear