Reference one column more than once : Query Select Columns « Select Query « Oracle PL / SQL

Home
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
Oracle PL / SQL » Select Query » Query Select Columns 
Reference one column more than once
   

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> -- product Table Inserts:
SQL> insert into product(product_id, price, description, onhand, reorder)values (1,2.50,'Happy Birthday',100,20);

row created.

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

row created.

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

row created.

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

row created.

SQL>
SQL>
SQL> select description, price, price * .068 as tax,
  2         price * 1.068 as "Total"
  3    from product;

DESCRIPTION
---------------------------------------------------------------------------
     PRICE        TAX      Total
---------- ---------- ----------
Happy Birthday
       2.5        .17       2.67

Happy Birthday
        23      1.564     24.564

Happy New Year


Happy New Year
       1.5       .102      1.602


rows selected.

SQL>
SQL> drop table product;

Table dropped.

   
    
    
  
Related examples in the same category
1.Query returning all rows and all columns from the table
2.Indicate the column names in query command
3.Returning a Single Column.sql
4.Reference renamed column in order by
5.Renaming a column with a longer name
6.Return course name for an employee id
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.