Académique Documents
Professionnel Documents
Culture Documents
Ename
Job
MGR
Hiredate
17-Dec80
20-Feb81
22-Feb81
2-Apr-81
28-Sep81
1-May81
9-Jun-81
19-Apr81
17-Nov81
8-Sep-81
23-May81
3-Dec-81
3-Dec-81
23-Jan82
7369
SMITH
CLERK
7902
7499
ALLEN
SALESMAN
7698
7521
7566
WARD
JONES
SALESMAN
MANAGER
7698
7839
7654
MARTIN
SALESMAN
7698
7698
7782
BLAKE
CLARK
MANAGER
MANAGER
7839
7839
7788
SCOTT
ANALYST
7566
7839
7844
KING
TURNER
PRESIDENT
SALESMAN
7698
7876
7900
7902
ADAMS
AMES
FORD
CLERK
CLERK
ANALYST
7788
7698
7566
7934
MILLER
CLERK
7782
Dept No
Dname
10
20
30
40
ACCOUNTING
RESEARCH
SALES
OPERATIONS
LOC
NEW
YORK
DALLAS
CHICAGO
BOSTON
PNO
P1
P1
P1
P2
EMPNO
7379
7566
7788
7369
WORK_HRS
10
12
8
8
PNO
P1
P2
P3
P4
P2
P3
P4
7902
7788
7499
15
24
22
P5
P6
P7
Sal
Comm
800
DeptNo
20
26000
2600
10
28000
42000
2800
5000
50
40
20
38000
40000
5000
5000
20
30
40
95000
32000
3200
50
40
18000
21000
23000
50
30
50
15000
10
PNAME
Amarpali
Maruti
Intel
Gaur City
Godrej
City
Ford
GE
BUDGET
85000
250000
60000
25000
S_DATE
12/1/2013
1/2/2013
21/03/2013
1/7/2015
35000
125000
25000
1/8/2015
19/02/2014
13/07/2015
P5
P4
P5
P6
P6
P7
P8
P9
7900
7566
7654
7782
7876
7900
7876
7934
14
24
22
15
36
56
15
18
P8
Kirloskar
75000
1/2/2014
WHERE Syntax
SELECT column_name,column_name
FROM table_name
WHERE column_name operator value;
Operator
=
<>
>
<
>=
Description
Equal
Not equal. Note: In some versions of SQL this
operator may be written as !=
Greater than
Less than
Greater than or equal
<=
BETWEEN
LIKE
IN
PATTERN MATCHING
SQL LIKE Operator
LIKE Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern;
AGGREGATE FUNCTIONS
The Summary values are calculated from the data in
particular column using SQL aggregate functions.They can
also be applied to to all rows in a table or to a subset of the
table specified by a WHERE Clause.SQL includes following
functions.
GROUP BY Syntax
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name;
GROUP BY
GROUP BY Statement- The GROUP BY statement is
used in conjunction with the aggregate functions to
group the result-set by one or more columns.
GROUP BY Syntax
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name;
ORDER BY Syntax
SELECT column_name, column_name
FROM table_name
ORDER BY column_name ASC|DESC, column_name ASC|DESC;
NESTED QUERY
Q1.Display the name of emp getting max salary.
Q4.Name of Emp getting salary more than the avg sal of all
emp in DeptNo10.
JOIN QUERY
Joins Statement- An SQL JOIN clause is used to combine rows from two or
more tables, based on a common field between them.The most common type of
join is: SQL INNER JOIN (simple join). An SQL INNER JOIN return all
rows from multiple tables where the join condition is met.
Different SQL JOINs
Before we continue with examples, we will list the types of the different SQL JOINs you can
use:
INNER JOIN: Returns all rows when there is at least one match in BOTH
tables
LEFT JOIN: Return all rows from the left table, and the matched rows from
the right table
RIGHT JOIN: Return all rows from the right table, and the matched rows
from the left table
FULL JOIN: Return all rows when there is a match in ONE of the tables