Академический Документы
Профессиональный Документы
Культура Документы
Ename
Job
MGR
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
PRESIDENT
7844
KING
TURNE
R
SALESMAN
7698
7876
ADAMS
CLERK
7788
7900
AMES
CLERK
7698
7902
FORD
ANALYST
7566
7934
MILLER
CLERK
7782
10
20
Dname
ACCOUNTIN
G
RESEARCH
30
40
SALES
OPERATIONS
LOC
NEW
YORK
DALLAS
CHICAG
O
BOSTON
EMPNO
7379
7566
WORK_HRS
10
12
Dept
No
PNO
P1
P1
Hiredate
17-Dec80
20-Feb81
22-Feb81
2-Apr-81
28-Sep81
1-May81
9-Jun-81
19-Apr81
17-Nov81
8-Sep81
23-May81
3-Dec81
3-Dec81
23-Jan82
PNO
P1
P2
Sal
Comm
800
DeptNo
20
26000
2600
10
28000
42000
2800
5000
50
40
20
38000
40000
5000
5000
20
30
40
95000
32000
50
3200
40
18000
50
21000
30
23000
50
15000
10
PNAME
Amarpali
Maruti
BUDGE
T
85000
250000
S_DATE
12/1/2013
1/2/2013
60000
21/03/201
3
25000
1/7/2015
P5
Intel
Gaur
City
Godrej
City
35000
24
P6
Ford
125000
22
14
24
22
15
36
56
15
18
P7
P8
GE
Kirloskar
25000
75000
1/8/2015
19/02/201
4
13/07/201
5
1/2/2014
P1
7788
P3
P2
7369
P4
P2
7902
15
P3
7788
P4
P5
P4
P5
P6
P6
P7
P8
P9
7499
7900
7566
7654
7782
7876
7900
7876
7934
INSERT SYNTAX-
value1,value2,value3,...);
(&value1,&value2,&value3,&Value4,..);
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
<=
Less than or equal
BETWEEN Between an inclusive range
LIKE
Search for a pattern
IN
To specify multiple possible values for a column
PATTERN MATCHING
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;
Q1. Find the Total Salary of all Emp.
GROUP BY
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.
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