Negate a column value : Select clause « Query Select « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> CREATE TABLE promotion(
  2    title_id     CHAR(3)      NOT NULL,
  3    advance      DECIMAL(9,2) NULL    ,
  4    royalty_rate DECIMAL(5,2) NULL);

Table created.

SQL>
SQL>
SQL> INSERT INTO promotion VALUES('T01',10000,0.05);

1 row created.

SQL> INSERT INTO promotion VALUES('T02',1000,0.06);

1 row created.

SQL> INSERT INTO promotion VALUES('T03',15000,0.07);

1 row created.

SQL> INSERT INTO promotion VALUES('T04',20000,0.08);

1 row created.

SQL> INSERT INTO promotion VALUES('T05',100000,0.09);

1 row created.

SQL> INSERT INTO promotion VALUES('T06',20000,0.08);

1 row created.

SQL> INSERT INTO promotion VALUES('T07',1000000,0.11);

1 row created.

SQL> INSERT INTO promotion VALUES('T08',0,0.04);

1 row created.

SQL> INSERT INTO promotion VALUES('T09',0,0.05);

1 row created.

SQL> INSERT INTO promotion VALUES('T10',NULL,NULL);

1 row created.

SQL> INSERT INTO promotion VALUES('T11',100000,0.07);

1 row created.

SQL> INSERT INTO promotion VALUES('T12',50000,0.09);

1 row created.

SQL> INSERT INTO promotion VALUES('T13',20000,0.06);

1 row created.

SQL>
SQL>
SQL> SELECT title_id,
  2         -advance AS "Advance"
  3    FROM promotion;

TIT    Advance
--- ----------
T01     -10000
T02      -1000
T03     -15000
T04     -20000
T05    -100000
T06     -20000
T07   -1000000
T08          0
T09          0
T10
T11    -100000

TIT    Advance
--- ----------
T12     -50000
T13     -20000

13 rows selected.

SQL>
SQL>
SQL> drop table promotion;

Table dropped.

SQL>
SQL>








2.2.Select clause
2.2.1.Performing Single Table SELECT Statements
2.2.2.Select employee first and last and sort by last name
2.2.3.List single column from a table
2.2.4.Use as to specify the alias name
2.2.5.Use function in select clause
2.2.6.Use more than one aggregate functions in a select statement
2.2.7.where clause
2.2.8.Compare with number
2.2.9.Concatenate string
2.2.10.Select from a Subquery
2.2.11.Select constant as a column
2.2.12.Negate a column value
2.2.13.Math calculation in select statement
2.2.14.Search for String Across Columns
2.2.15.Don't Perform the Same Calculation Over and Over
2.2.16.NO_INDEX function in select statement