realsdx

DBMS_LAB2_AS3

Feb 14th, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.22 KB | None | 0 0
  1. Q1. Malay has joined in “SOFTWARE SUPPORT” Department. Insert appropriate data into the related Tables.
  2. A1.
  3. mysql> insert into employee values(13,8,"Malay","96969696969","malay69@yahoo.com","1987-12-13","M",36900);
  4. Query OK, 1 row affected (0.30 sec)
  5.  
  6. Q2. Assign “Malay” to “INFORMATION SECURITY” Project.
  7. A2.
  8. mysql> insert into work_project(13,14);
  9. Query OK, 1 row affected (0.30 sec)
  10.  
  11. Q3. List all Employees who have not assigned to any Project.
  12. A3.
  13. mysql> select e_name
  14. -> from employee
  15. -> where emp_id not in
  16. -> (select eid from work_project);
  17. +--------+
  18. | e_name |
  19. +--------+
  20. | Aalam |
  21. +--------+
  22. 1 row in set (0.04 sec)
  23.  
  24. Q4. Display Employee details who are working in the Department of “INFORMATION CENTER”.
  25. A4.
  26. mysql> select e_name
  27. -> from employee
  28. -> where emp_id in
  29. -> ( select eid
  30. -> from work_project
  31. -> where pro_id in
  32. -> (select p_id
  33. -> from project
  34. -> where p_name="INFORMATION SECURITY"));
  35. +----------+
  36. | e_name |
  37. +----------+
  38. | Anjali |
  39. | Bikash |
  40. | Nilesh |
  41. | Abhishek |
  42. | Malay |
  43. +----------+
  44. 5 rows in set (0.00 sec)
  45.  
  46.  
  47. Q5. In which Department “Aadarsh” is working?
  48. A5.
  49. mysql> select dept_name
  50. -> from department
  51. -> where dept_id in
  52. -> ( select d_id
  53. -> from employee
  54. -> where e_name = "Aadarsh");
  55. +-----------+
  56. | dept_name |
  57. +-----------+
  58. | PLANNING |
  59. +-----------+
  60. 1 row in set (0.00 sec)
  61.  
  62. Q6. Who are the senior most Employees?
  63. A6.
  64. mysql> select e_name
  65. -> from employee
  66. -> order by birthday
  67. -> limit 5;
  68. +----------+
  69. | e_name |
  70. +----------+
  71. | Abhishek |
  72. | Rakesh |
  73. | Gajendra |
  74. | Bikash |
  75. | Nilesh |
  76. +----------+
  77. 5 rows in set (0.00 sec)
  78.  
  79. 7. mysql> select phone, e_name from employee where phone LIKE "03%";
  80. +-------------+-----------+
  81. | phone | e_name |
  82. +-------------+-----------+
  83. | 0343-234565 | Gajendra |
  84. | 033-2345434 | Chiranjit |
  85. | 0343-234345 | Tapas |
  86. +-------------+-----------+
  87. 3 rows in set (0.00 sec)
  88.  
  89. 8. mysql> select e_name from employee where month(birthday)=2;
  90. +----------+
  91. | e_name |
  92. +----------+
  93. | Aadarsh |
  94. | Aalam |
  95. | Gajendra |
  96. | Malay |
  97. +----------+
  98. 4 rows in set (0.00 sec)
  99.  
  100. 9. mysql> select e_name from employee where d_id=8 order by birthday limit 1;
  101. +----------+
  102. | e_name |
  103. +----------+
  104. | Abhishek |
  105. +----------+
  106. 1 row in set (0.00 sec)
  107.  
  108. 10. mysql> select e_name from employee , work_project where emp_id=eid and pro_id=13;
  109. +--------+
  110. | e_name |
  111. +--------+
  112. | Nilesh |
  113. | Anjali |
  114. +--------+
  115. 2 rows in set (0.00 sec)
  116.  
  117. 11. mysql> select DATEDIFF(e_date,s_date) from project where p_id=12;
  118. +-------------------------+
  119. | DATEDIFF(e_date,s_date) |
  120. +-------------------------+
  121. | 561 |
  122. +-------------------------+
  123. 1 row in set (0.00 sec)
  124.  
  125. 12. mysql> select count(eid), pro_id from project, work_project group by pro_id;
  126. +------------+--------+
  127. | count(eid) | pro_id |
  128. +------------+--------+
  129. | 12 | 11 |
  130. | 8 | 12 |
  131. | 8 | 13 |
  132. | 20 | 14 |
  133. +------------+--------+
  134. 4 rows in set (0.00 sec)
  135.  
  136. 13. mysql> select e_name, p_name from employee, project, work_project where salary=(select MAX(salary) from employee) AND emp_id=eid AND pro_id=p_id;
  137. +--------+----------------------+
  138. | e_name | p_name |
  139. +--------+----------------------+
  140. | Bikash | INFORMATION SECURITY |
  141. +--------+----------------------+
  142. 1 row in set (0.00 sec)
  143.  
  144. 14. mysql> select e_name, p_name from project, work_project, employee where DATEDIFF('2020-02-14', e_date) > 0 AND pro_id=p_id AND eid=emp_id;
  145. +-----------+--------------------------------+
  146. | e_name | p_name |
  147. +-----------+--------------------------------+
  148. | Gajendra | Campus Fire Alarm System |
  149. | Rakesh | Campus Fire Alarm System |
  150. | Tapas | Campus Fire Alarm System |
  151. | Aadarsh | Guest House Renovation |
  152. | Chiranjit | Guest House Renovation |
  153. | Nilesh | Robotics and Autonomous System |
  154. | Anjali | Robotics and Autonomous System |
  155. | Nilesh | INFORMATION SECURITY |
  156. | Anjali | INFORMATION SECURITY |
  157. | Abhishek | INFORMATION SECURITY |
  158. | Bikash | INFORMATION SECURITY |
  159. | Malay | INFORMATION SECURITY |
  160. +-----------+--------------------------------+
  161. 12 rows in set (0.00 sec)
  162.  
  163.  
  164. 15. mysql> select p_name from project, work_project, employee where sex="F" AND pro_id=p_id AND eid=emp_id;
  165. +--------------------------------+
  166. | p_name |
  167. +--------------------------------+
  168. | Robotics and Autonomous System |
  169. | INFORMATION SECURITY |
  170. +--------------------------------+
  171. 2 rows in set (0.00 sec)
  172.  
  173. 16. mysql> select p_name, datediff(e_date, s_date) as df from project where datediff(e_date, s_date)=(select MAX(datediff(e_date, s_date)) from project);
  174. +----------------------+------+
  175. | p_name | df |
  176. +----------------------+------+
  177. | INFORMATION SECURITY | 946 |
  178. +----------------------+------+
  179. 1 row in set (0.00 sec)
  180.  
  181.  
  182. 17. mysql> select e_name from employee order by salary DESC limit 1,1;
  183. +----------+
  184. | e_name |
  185. +----------+
  186. | Gajendra |
  187. +----------+
  188. 1 row in set (0.01 sec)
Add Comment
Please, Sign In to add comment