Right outer join : Outer Joins « Table Joins « Oracle PL / SQL

Oracle PL / SQL
1. Aggregate Functions
2. Analytical Functions
3. Char Functions
4. Constraints
5. Conversion Functions
6. Cursor
7. Data Type
8. Date Timezone
9. Hierarchical Query
10. Index
11. Insert Delete Update
12. Large Objects
13. Numeric Math Functions
14. Object Oriented Database
15. PL SQL
16. Regular Expressions
17. Report Column Page
18. Result Set
19. Select Query
20. Sequence
21. SQL Plus
22. Stored Procedure Function
23. Subquery
24. System Packages
25. System Tables Views
26. Table
27. Table Joins
28. Trigger
29. User Previliege
30. View
31. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL / SQL » Table Joins » Outer Joins 
Right outer join
  
SQL>
SQL> create table ord_item(
  2           order_no               integer
  3          ,product_id             integer
  4          ,quantity               number(4,0)
  5          ,item_price             number(7,2)
  6          ,total_order_item_price number(9,2)
  7          ,primary key (order_no, product_id)
  8  );

Table created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(1,   2,  1023.00 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(21123.00 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(25110.50 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(28117.48 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(38135.99 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(47119.95 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(55110.95 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(68122.95 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(71615.00 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(75110.50 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(78110.45 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(88135.95 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(98165.45 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(95110.50 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(103119.95 );

row created.

SQL> insert into ord_item(order_no, product_id, quantity, item_price)values(118130.00);

row created.

SQL>
SQL> create table product(
  2          product_id              integer           primary key
  3          ,price                  number(7,2)
  4          ,description            varchar2(75)
  5          ,onhand                 number(5,0)
  6          ,reorder                number(5,0)
  7          ,supplier_no            integer
  8  );

Table created.

SQL> insert into product(product_id, price, description, onhand, reorder)values (1,2.50,'Oracle',100,20);

row created.

SQL> insert into product(product_id, price, description, onhand, reorder)values (2,23.00,'SQL Server',null,null);

row created.

SQL> insert into product(product_id, price, description, onhand, reorder)values (3,null,'MySQL',null,null);

row created.

SQL> insert into product(product_id, price, description, onhand, reorder)values (4,1.50,'DB2',50,10);

row created.

SQL> insert into product(product_id, price, description, onhand, reorder)values (5,10.50,'Java',100,20);

row created.

SQL> insert into product(product_id, price, description, onhand, reorder)values (6,45.00,'C++',null,null);

row created.

SQL> insert into product(product_id, price, description, onhand, reorder)values (7,19.99,'Javascript',3,5);

row created.

SQL> insert into product(product_id, price, description, onhand, reorder)values (8,4.50,'Ruby',null,null);

row created.

SQL>
SQL>
SQL>
SQL> SELECT description, nvl(quantity,0)
  2  FROM ord_item RIGHT OUTER JOIN product
  3  USING (product_id);

DESCRIPTION                                                                 NVL(QUANTITY,0)
--------------------------------------------------------------------------- ---------------
SQL Server                                                                               10
Oracle                                                                                    1
Java                                                                                      1
Ruby                                                                                      1
Ruby                                                                                      1
Javascript                                                                                1
Java                                                                                      1
Ruby                                                                                      1
Oracle                                                                                    6
Java                                                                                      1
Ruby                                                                                      1
Ruby                                                                                      1
Ruby                                                                                      1
Java                                                                                      1
MySQL                                                                                     1
Ruby                                                                                      1
C++                                                                                       0
DB2                                                                                       0

18 rows selected.

SQL>
SQL> drop table product;

Table dropped.

SQL> drop table ord_item;

Table dropped.

SQL>
SQL> --

   
  
Related examples in the same category
1. Outer Joins demo
2. Understanding Outer Joins: j.empno = e.empno (+)
3. Understanding Outer Joins: e.empno (+) = j.empno
4. Use an ANSI outer join and use the NVL function to convert nulls to the string "N/A".
5. Demo the ANSI outer join
6. Inner and Outer Joins(room and class)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.