Professional Documents
Culture Documents
WEEK-2B
“WHERE” CLAUSE
BETWEEN, LIKE ,IN, NULL
> GREATER THAN
< SMALLER THAN
= EQUAL TO
!= NOT EQUAL TO
CAR
SELECT CAR FROM CAR OPEL
WHERE TOYOTA
PRICE BETWEEN 20000 and 30000 NISSAN
EMP
ID CAR
ID CAR
1 BMW
SELECT ID,CAR FROM CAR 2 AUDI
WHERE id =! 3 4 TOYOTA
5 NISSAN
TABLE NAME : CAR
CAR
CAR
NISSAN
SELECT CAR FROM CAR BMW
WHERE PRICE >=27000 AUDI
TOYOTA
TABLE NAME : CAR
ID CAR
SELECT ID,CAR FROM CAR
4 TOYOTA
WHERE CAR LIKE ‘%T_’
TABLE NAME : CAR
ID
SELECT ID FROM CAR
2
WHERE DISCOUNT IS NULL
4
ID
SELECT ID FROM CAR
WHERE DISCOUNT IS NOT NULL 1
3
5
SELECT * FROM EMP
WHERE SAL BETWEEN 1100 AND 1500
ORDER BY ENAME DESC ;
LOGICAL OPERATORS
NOT
Returns TRUE if the following condition is FALSE.
Returns FALSE if it is TRUE.
AND
Returns TRUE if the both component conditions are TRUE.
Returns FALSE if either is FALSE
OR
Returns TRUE if either component condition is TRUE.
Returns FALSE if both are FALSE
TABLE NAME : CAR
ID CAR
SELECT ID,CAR FROM CAR 3 OPEL
WHERE NOT ID < 3 4 TOYOTA
5 NISSAN
id Car Price Discount % CAR
1 BMW 50.000 2
2 AUDI 15.000 5
3 OPEL 25.000 8
4 TOYOTA 28.000 4
5 NISSAN 27.000 5
CAR CAR
OPEL OPEL
TOYOTA NISSAN
NISSAN AUDI
AND
CAR
NISSAN
OPEL
id Car Price Discount % CAR
1 BMW 50.000 2
2 AUDI 15.000 5
3 OPEL 25.000 8
4 TOYOTA 28.000 4
5 NISSAN 27.000 5
CAR CAR
OPEL OPEL
TOYOTA NISSAN
NISSAN CAR AUDI
OPEL
TOYOTA
NISSAN
AUDI
EXTRA
DISTINCT : Allows you to remove duplicates from the result set.
It can be only used with SELECT statements.
DELETE WITH A
SQL>DELETE FROM EMP WHERE SAL=800;
TASKS
1- List employee name that start with “B”
2- List employee name ends with “S”
3- List employee work in department no=20 or department no=30
4- List employee whose salary is greater than or equal to 600
5- List employee whose salary is smaller than 1500 and department no=30
6- List all salesman and manager
7- List employee whose empno is between 7500 and 7700
8- List the employee which have not got any commision.
9- List only department numbers.
10- List employee which are not working as CLERK.
11- List employee whose hiredate is between 01-JAN-1979 AND 01-MAR-1982
12- Second letter of ENAME is “A”
13- List HIREDATE is less than 1977
14- List Employee not working on Depertmant no : 10
15- List the last letter of ENAME is “N”
16- List ENAME whose salary is not equal to 1000 and 2000