Math calculation in select
SQL>
SQL> CREATE TABLE purchase (
2 product_name VARCHAR2(25),
3 product_price NUMBER(4,2),
4 sales_tax NUMBER(4,2),
5 purchase_date DATE,
6 salesperson VARCHAR2(3));
Table created.
SQL>
SQL> INSERT INTO purchase VALUES ('Product Name 1', 1, .08, '5-NOV-00', 'AB');
1 row created.
SQL> INSERT INTO purchase VALUES ('Product Name 2', 2.5, .21, '29-JUN-01', 'CD');
1 row created.
SQL> INSERT INTO purchase VALUES ('Product Name 3', 50.75, 4.19, '10-DEC-02', 'EF');
1 row created.
SQL> INSERT INTO purchase VALUES ('Product Name 4', 99.99, 8.25, '31-AUG-03', 'GH');
1 row created.
SQL>
SQL>
SQL>
SQL> SELECT product_name, sales_tax / product_price FROM purchase;
PRODUCT_NAME SALES_TAX/PRODUCT_PRICE
------------------------- -----------------------
Product Name 1 .08
Product Name 2 .084
Product Name 3 .082561576
Product Name 4 .082508251
4 rows selected.
SQL>
SQL>
SQL> DROP TABLE purchase;
Table dropped.
SQL>
SQL>
Related examples in the same category