Retrieving Data PDF
Retrieving Data PDF
Retrieving Data PDF
BASIS DATA
Table 1
Selection
Table 1
Join
Join
Table 1 Table 2
Basic Syntax
SELECT select_list
[ INTO new_table ]
FROM table_source
[ WHERE search_condition ]
[ GROUP BY group_by_expression ]
[ HAVING search_condition ]
[ ORDER BY order_expression [ ASC | DESC ] ]
Example :
Example :
SELECT employee_id,first_name,last_name,salary
FROM hr.employees;
SELECT kode_cabang,nama_cabang,alamat_cabang
FROM cabang_bank;
Writing SQL Statements
SQL statements are not case-sensitive.
SQL statements can be on one or more lines.
Keywords cannot be abbreviated or split across lines.
Clauses are usually placed on separate lines.
Indents are used to enhance readability.
In Query Analyzer, SQL statements can optionally be terminated by a
semicolon (;). Semicolons are required if you execute multiple SQL
statements.
Arithmetic Expression
Create expressions with number and date data
by using arithmetic operators.
Operator Description
+ Penjumlahan
- Pengurangan
* Perkalian
/ Pembagian
Using Arithmatic Expression
SELECT first_name,salary,salary+300
FROM employees;
SELECT first_name,salary,salary*0.1
FROM employees;
SELECT employee_id,first_name,salary,salary-100
FROM employees;
Operator Precedence Rules
SELECT
no_rekening, saldo, 12 * saldo + 300000
FROM rekening;
SELECT
no_rekening, saldo, 12*(salary + 300000)
FROM employees;
Defining a Null Value
A null is a value that is unavailable, unassigned, unknown, or
inapplicable.
A null is not the same as a zero or a blank space.
SELECT no_rekening, saldo
FROM rekening;
SELECT no_rekening, saldo, 12 * saldo
FROM rekening;
Null Values in Arithmetic Expressions
SELECT nama_nasabah +
alamat_nasabah AS “Nasabah”
FROM nasabah;
Duplicate Rows
The default display of queries is all rows, including duplicate
rows.
SELECT kode_cabang 1
FROM rekening;