NoNameCracksInc icon

SQL scripts and codes for educational purpose

NoNameCracksInc | PRO | 01/13/13 03:23:11 PM UTC | 0 ⭐ | 435 👁️ | Never ⏰ | []
MySQL |

1.49 KB

|

None

|

0 👍

/

0 👎

Hey guys.I prepared some short scripts for those who are interested in SQL :)
All values in table are fictive, dont worry about using it educationally.
 
create table customers(
Cust_id numeric(10) not null,
cust_name varchar(20) not null,
cust_phone int(10) not null,
cust_adress varchar(255) not null,         <----table
cust_birth DATE not null,
cust_salary decimal(10,2) not null,
PRIMARY KEY (cust_id)
);
 
insert into customers values
('1','Vollans','0905703848','Bottova 14','1999-05-15','1415');
insert into customers values
('2','George','0971884569','Washingtons 4','1980-9-07','1792');
insert into customers values
('3','Sealy','0955632447','Slovenska 9','1985-3-14','1330');
insert into customers values
('4','Andrej','0907823863','Bottova 2','1997-04-28','1679');   <-----values
insert into customers values
('5','Matthew','0917851997','Maja 8','1997-06-13','2300');
insert into customers values
('6','Fred','0975478112','Romneys 19','1991-10-01','1445');
 
delimiter $$
drop procedure if exists max_custom_salary;
 create procedure max_custom_salary()
  begin
   declare 2_max INTEGER;
    select max(cust_salary)
     into 2_max
      from customers
where max(cust_salary) <>
(select min(cust_salary), max(cust_salary)                <---Scipt which shows you highest salary
from customers                                                after writing: CALL max_custom_salary() $$
having min(cust_salary) <> max(cust_salary)/2
);
select concat ('Salary= ',2_max);
END $$

Comments