Advertisement
brandblox

lab assignment(07/11/23)

Nov 7th, 2023
1,112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.15 KB | None | 0 0
  1. CREATE TABLE employee_29(
  2. emp_no NUMBER(10) PRIMARY KEY,
  3. ename VARCHAR2(30),
  4. dept_no NUMBER(3),
  5. contact NUMBER(10) CONSTRAINT uc_contact UNIQUE,
  6. address VARCHAR2(200)
  7. );
  8.  
  9. INSERT ALL
  10.   INTO employee_29 (emp_no, ename, dept_no, contact, address) VALUES (1000001, 'Rajesh', 101, 9876543210, '123, ABC Street')
  11.   INTO employee_29 (emp_no, ename, dept_no, contact, address) VALUES (2000002, 'Suresh', 102, 8765432109, '456, XYZ Street')
  12.   INTO employee_29 (emp_no, ename, dept_no, contact, address) VALUES (3000003, 'Amit', 103, 7654321098, '789, PQR Street')
  13.   INTO employee_29 (emp_no, ename, dept_no, contact, address) VALUES (4000005, 'Priya', 104, 6543210987, '321, LMN Street')
  14.   INTO employee_29 (emp_no, ename, dept_no, contact, address) VALUES (5000006, 'Anita', 105, 5432109876, '654, EFG Street')
  15. SELECT * FROM dual;
  16.  
  17. SELECT * FROM EMPLOYEE_29;
  18.  
  19. SELECT Ename,Contact FROM employee_29;
  20.  
  21. SELECT dept_no, COUNT(*) AS num_employees
  22. FROM employee_29
  23. GROUP BY dept_no;
  24.  
  25. SELECT AVG(LENGTH(contact)) AS avg_contact_length
  26. FROM employee_29;
  27.  
  28. SELECT *
  29. FROM employee_29
  30. ORDER BY dept_no, ename;
  31.  
  32. SELECT *
  33. FROM employee_29
  34. WHERE ename LIKE '%A%';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement