Advertisement
brandblox

Assignemnt 3

Oct 6th, 2023
1,126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.56 KB | None | 0 0
  1. CREATE TABLE emp (
  2.     id INT PRIMARY KEY,
  3.     name VARCHAR2(50),
  4.     salary NUMBER(10, 2),
  5.     city VARCHAR2(50)
  6. );
  7.  
  8. --Insert Values
  9. INSERT ALL
  10.  INSERT INTO emp (id, name, salary, city)
  11.  VALUES (1, 'John', 1500.00, 'Kolkata')
  12.  INSERT INTO emp (id, name, salary, city)
  13.  VALUES (2, 'Alice', 1200.00, 'Mumbai')
  14.  INSERT INTO emp (id, name, salary, city)
  15.  VALUES (3, 'Bob', 2000.00, 'Delhi')
  16.  INSERT INTO emp (id, name, salary, city)
  17.  VALUES (4, 'Carol', 2500.00, 'Kolkata')
  18.  INSERT INTO emp (id, name, salary, city)
  19.  VALUES (5, 'David', 800.00, 'Mumbai')
  20.  INSERT INTO emp (id, name, salary, city)
  21.  VALUES (6, 'Eve', 3000.00, 'Kolkata')
  22. SELECT 1 FROM DUAL;
  23.  
  24.  
  25. --Show all the values of the emp table.
  26.  SELECT * FROM emp;
  27.  
  28. --Show the name and id of all employees.
  29.  SELECT name, id FROM emp;
  30.  
  31. --Show all the salaries.
  32.  SELECT salary FROM emp;
  33.  
  34. -- Show only unique salaries.
  35.  SELECT DISTINCT salary FROM emp;
  36.  
  37.  
  38. --Show the name of all employees who are staying in Kolkata.
  39.  SELECT name FROM emp WHERE city = 'Kolkata';
  40.  
  41. --Show the name of all employees who are getting a salary more than 1000.
  42.  SELECT name FROM emp WHERE salary > 1000;
  43.  
  44. --Show the name of all employees who are earning at least 1000 and staying in Kolkata.
  45.  SELECT name FROM emp WHERE salary >= 1000 AND city = 'Kolkata';
  46.  
  47. --Show the name of all employees who are earning at least 1000 and at most 3000.
  48.  SELECT name FROM emp WHERE salary BETWEEN 1000 AND 3000;
  49.  
  50. --Show the name of all employees who are staying in Kolkata and Mumbai.
  51.  SELECT name FROM emp WHERE city IN ('Kolkata', 'Mumbai');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement