NoNameCracksInc

SQL scripts and codes for educational purpose

Jan 13th, 2013
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.49 KB | None | 0 0
  1. Hey guys.I prepared some short scripts for those who are interested in SQL :)
  2. All values in table are fictive, dont worry about using it educationally.
  3.  
  4. create table customers(
  5. Cust_id numeric(10) not null,
  6. cust_name varchar(20) not null,
  7. cust_phone int(10) not null,
  8. cust_adress varchar(255) not null,         <----table
  9. cust_birth DATE not null,
  10. cust_salary decimal(10,2) not null,
  11. PRIMARY KEY (cust_id)
  12. );
  13.  
  14. insert into customers values
  15. ('1','Vollans','0905703848','Bottova 14','1999-05-15','1415');
  16. insert into customers values
  17. ('2','George','0971884569','Washingtons 4','1980-9-07','1792');
  18. insert into customers values
  19. ('3','Sealy','0955632447','Slovenska 9','1985-3-14','1330');
  20. insert into customers values
  21. ('4','Andrej','0907823863','Bottova 2','1997-04-28','1679');   <-----values
  22. insert into customers values
  23. ('5','Matthew','0917851997','Maja 8','1997-06-13','2300');
  24. insert into customers values
  25. ('6','Fred','0975478112','Romneys 19','1991-10-01','1445');
  26.  
  27. delimiter $$
  28. drop procedure if exists max_custom_salary;
  29.  create procedure max_custom_salary()
  30.   begin
  31.    declare 2_max INTEGER;
  32.     select max(cust_salary)
  33.      into 2_max
  34.       from customers
  35. where max(cust_salary) <>
  36. (select min(cust_salary), max(cust_salary)                <---Scipt which shows you highest salary
  37. from customers                                                after writing: CALL max_custom_salary() $$
  38. having min(cust_salary) <> max(cust_salary)/2
  39. );
  40. select concat ('Salary= ',2_max);
  41. END $$
Advertisement
Add Comment
Please, Sign In to add comment