Postingan

SUBQUERY

Gambar
SUBQUERY Subquery adalah sebuah perintah atau query dalam query, lebih jelasnya perintah SELECT didalam perintah SELECT, lihat analogi disamping kiri diamana query satu adalah sebuah query yang datanya akan bernilai sama dengan yang ada pada subquery.Sehingga bisa dikatakan query1 akan ditampilkan datanya diamana data tersebut merupakan hasil seleksi pada subquery.Adapun beberapa klausa yang digunakan dalam subquery ini adalah : WHERE  HAVING  FROM  adapun type-type dari sub query adalah : Single row yaitu return valuenya hanya satu misal : DIKDIK Single row subquery memberikan hasil hanya satu baris pada bagian subquery.Untuk single row subquery ini yang digunakan adalah operator pembandingan : = , > , >= , < , <= , atau <>.Contoh : select last_name, job_id from employees where job_id = (select job_id from employees where employee_id = 141); Multiple row yaitu return valuenya lebih dari satu misal : DIKDIK, PRASTYO Multiple Row Subq...

Fungsi Join Pada SQL Oracle

Gambar
Join merupakan penggambaran relasi yang terjadi antar suatu tabel dengan tabel lainya. Pada Oracle ada beberapa fungsi Join diantaranya adalah : - Natural Joins - Using Clause - On Clause - Full ( two-sided) outer joins Natural Joins Natural Joins digunakan untuk menampilkan fungsi join secara natural. Ada beberapa ketentuannya yakni nama harus sama, value harus sama dan tipe data harus sama. select department_id,department_name,location_id as Lokasi,city from departments  natural join locations Using Clause Using Clause digunakan untuk memodifikasi fungsi natural join jika terdapat kolom yang memiliki nama yang sama tetapi memiliki tipe data yang berbeda. select employees.employee_id,employees.last_name,departments.location_id,department_id  from employees  join departments using (department_id) On Clause On Clause digunakan untuk menentukan kolom yang memiliki spesifikasi tertentu yang akan digunakan untuk fungsi join. select e.las...

GROUP Functions

GROUP Functions Group functions are built-in SQL functions that operate on groups of rows and return one value for the entire group. These functions are:  COUNT, MAX, MIN, AVG, SUM, DISTINCT SQL COUNT ():  This function returns the number of rows in the table that satisfies the condition specified in the WHERE condition. If the WHERE condition is not specified, then the query returns the total number of rows in the table. For Example:  If you want the number of employees in a particular department, the query would be: SELECT COUNT (*) FROM employee  WHERE dept = 'Electronics';  The output would be '2' rows. If you want the total number of employees in all the department, the query would take the form: SELECT COUNT (*) FROM employee; The output would be '5' rows. SQL DISTINCT():  This function is used to select the distinct rows. For Example:  If you want to select all distinct department names from employee table, the query would ...

Single-Row Functions

Single-row functions return a single result row for every row of a queried table or view. These functions can appear in select lists,  WHERE  clauses,  START WITH  and  CONNECT   BY  clauses, and  HAVING  clauses. Numeric Functions Numeric functions accept numeric input and return numeric values. Most numeric functions return  NUMBER  values that are accurate to 38 decimal digits. The transcendental functions  COS ,  COSH ,  EXP ,  LN ,  LOG ,  SIN ,  SINH ,  SQRT ,  TAN , and  TANH  are accurate to 36 decimal digits. The transcendental functions  ACOS ,  ASIN ,  ATAN , and  ATAN2  are accurate to 30 decimal digits. The numeric functions are: ABS ACOS ASIN ATAN ATAN2 BITAND CEIL COS COSH EXP FLOOR LN LOG MOD NANVL POWER REMAINDER ROUND (number) SIGN SIN SINH SQRT TAN TANH TRUNC (number) WIDTH_BUCKET Character Functions Returning Character Value...