Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. 1.
  2.  
  3. create table k820_employee
  4. (
  5. ssn varchar(11) not null primary key,
  6. lastname varchar(40) not null,
  7. firstname varchar(30) null,
  8. department_code integer(3) not null,
  9. annual_salary varchar(20) null,
  10. hire_date varchar(10) null
  11. );
  12.  
  13. 2.
  14.  
  15. create table k820_Department
  16. (
  17. department_code integer(3) not null primary key,
  18. department_name varchar(30) not null
  19. );
  20.  
  21. 3.
  22.  
  23. INSERT INTO k820_employee
  24. (ssn, lastname, firstname, department_code, annual_salary, hire_date)
  25. values
  26. (
  27. "111-22-3333",
  28. "Smith",
  29. "John",
  30. 234,
  31. "$50,000",
  32. "1999-10-15"
  33. );
  34.  
  35. update k820_employee set annual_salary=replace(annual_salary,'$','')
  36. update k820_employee set annual_salary=replace(annual_salary,',','')
  37.  
  38. INSERT INTO k820_employee
  39. (ssn, lastname, firstname, department_code, annual_salary, hire_date)
  40. values
  41. (
  42. "222-33-4444",
  43. "Jones",
  44. "Mary",
  45. 234,
  46. "$56,000",
  47. "1998-01-02"
  48. );
  49.  
  50. update k820_employee set annual_salary=replace(annual_salary,'$','')
  51. update k820_employee set annual_salary=replace(annual_salary,',','')
  52.  
  53. 4.
  54.  
  55. INSERT INTO k820_Department
  56. (department_code, department_name)
  57. values
  58. (
  59. 234,
  60. "Information Services"
  61. );
  62.  
  63. INSERT INTO k820_Department
  64. (department_code, department_name)
  65. values
  66. (
  67. 456,
  68. "Systems Group"
  69. );
  70.  
  71. 5.
  72.  
  73. SELECT lastname, firstname, hire_date from k820_employee ORDER BY lastname;
  74.  
  75. 6.
  76.  
  77. SELECT AVG( annual_salary ) FROM k820_employee;
  78.  
  79. 7.
  80.  
  81. 9.
  82.  
  83.  
  84.  
  85. 10.
  86.  
  87. DROP TABLE k820_Department;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement