Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE emp (
- id INT PRIMARY KEY,
- name VARCHAR2(50),
- salary NUMBER(10, 2),
- city VARCHAR2(50)
- );
- --Insert Values
- INSERT ALL
- INSERT INTO emp (id, name, salary, city)
- VALUES (1, 'John', 1500.00, 'Kolkata')
- INSERT INTO emp (id, name, salary, city)
- VALUES (2, 'Alice', 1200.00, 'Mumbai')
- INSERT INTO emp (id, name, salary, city)
- VALUES (3, 'Bob', 2000.00, 'Delhi')
- INSERT INTO emp (id, name, salary, city)
- VALUES (4, 'Carol', 2500.00, 'Kolkata')
- INSERT INTO emp (id, name, salary, city)
- VALUES (5, 'David', 800.00, 'Mumbai')
- INSERT INTO emp (id, name, salary, city)
- VALUES (6, 'Eve', 3000.00, 'Kolkata')
- SELECT 1 FROM DUAL;
- --Show all the values of the emp table.
- SELECT * FROM emp;
- --Show the name and id of all employees.
- SELECT name, id FROM emp;
- --Show all the salaries.
- SELECT salary FROM emp;
- -- Show only unique salaries.
- SELECT DISTINCT salary FROM emp;
- --Show the name of all employees who are staying in Kolkata.
- SELECT name FROM emp WHERE city = 'Kolkata';
- --Show the name of all employees who are getting a salary more than 1000.
- SELECT name FROM emp WHERE salary > 1000;
- --Show the name of all employees who are earning at least 1000 and staying in Kolkata.
- SELECT name FROM emp WHERE salary >= 1000 AND city = 'Kolkata';
- --Show the name of all employees who are earning at least 1000 and at most 3000.
- SELECT name FROM emp WHERE salary BETWEEN 1000 AND 3000;
- --Show the name of all employees who are staying in Kolkata and Mumbai.
- SELECT name FROM emp WHERE city IN ('Kolkata', 'Mumbai');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement